670控制页加入从分享进入时的权限控制
This commit is contained in:
21
pages.json
21
pages.json
@ -246,14 +246,31 @@
|
||||
"navigationBarTitleText": "历史记录"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"path": "pages/7305/BJQ7305",
|
||||
"style": {
|
||||
"navigationBarTitleText": "BJQ7305"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/Share/shareIndex",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分享"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/Share/shareManager",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分享管理"
|
||||
}
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "pages/common/Share/sharePermission",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分享设备"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
],
|
||||
"tabBar": {
|
||||
|
||||
@ -404,7 +404,8 @@
|
||||
},
|
||||
rgb565Data: [],
|
||||
videoHexArray: [],
|
||||
picPath: ""
|
||||
picPath: "",
|
||||
permissions:[]//权限列表
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@ -436,7 +437,15 @@
|
||||
var device = data.data;
|
||||
these.Status.apiType = data.apiType;
|
||||
these.device = device;
|
||||
|
||||
if(data.apiType!=='listA'){
|
||||
Comment.getdeviceShareId(data.data.id).then(res=>{
|
||||
if(res.code==200){
|
||||
if(res.data.permission){
|
||||
these.permissions=res.data.permission.split(',');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (these.device.deviceImei) {
|
||||
these.initMQ();
|
||||
}
|
||||
@ -595,13 +604,16 @@
|
||||
} else if (s === 1) {
|
||||
console.log("分享");
|
||||
uni.navigateTo({
|
||||
url: '/pages/6170/share/index',
|
||||
url: '/pages/common/Share/shareIndex',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
debugger;
|
||||
let json={persissonType:'670'};
|
||||
Object.assign(json,this.device);
|
||||
res.eventChannel.emit('share', {
|
||||
data: this.device,
|
||||
data:json
|
||||
});
|
||||
}
|
||||
})
|
||||
@ -1188,8 +1200,12 @@
|
||||
setTimeout(task, 0);
|
||||
},
|
||||
GearSetting: function(type) { //档位设置
|
||||
if(!this.permissions.includes('41') && this.Status.apiType!=='listA'){
|
||||
console.log("无操作权限");
|
||||
return;
|
||||
}
|
||||
if (this.formData.modeCurr == type) {
|
||||
type = "close";
|
||||
return;
|
||||
}
|
||||
showLoading(this, {
|
||||
text: "请稍候..."
|
||||
|
||||
98
pages/common/Share/shareIndex.vue
Normal file
98
pages/common/Share/shareIndex.vue
Normal file
@ -0,0 +1,98 @@
|
||||
<template>
|
||||
<view class="share">
|
||||
<!-- 内容区域 -->
|
||||
<view class="content">
|
||||
<!-- 分享设备 -->
|
||||
<view class="section" @click="shareDevice">
|
||||
<text class="section-title">分享设备</text>
|
||||
</view>
|
||||
<!-- 分享管理 -->
|
||||
<view class="section" @click="shareManagement">
|
||||
<text class="section-title">分享管理</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
itemInfo:""
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 分享设备
|
||||
shareDevice(){
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/Share/sharePermission',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('shareDevice', {
|
||||
data: this.itemInfo,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 分享管理
|
||||
shareManagement(){
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/Share/shareManager',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('shareManagement', {
|
||||
data: this.itemInfo,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'shareDevice' 事件,获取传过来的数据
|
||||
eventChannel.on('share', (data) => {
|
||||
console.log(data,'datat');
|
||||
this.itemInfo = data.data;
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.share {
|
||||
padding: 30rpx;
|
||||
background: #121212;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
/* 根据实际情况设置状态栏高度 */
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 20px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 20px;
|
||||
padding:50rpx;
|
||||
border-radius: 16rpx;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
351
pages/common/Share/shareManager.vue
Normal file
351
pages/common/Share/shareManager.vue
Normal file
@ -0,0 +1,351 @@
|
||||
<template>
|
||||
<view class="share">
|
||||
<!-- 下拉刷新区域 -->
|
||||
<mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption" :down="downOption">
|
||||
<view class="device-title">已分享用户</view>
|
||||
<view class="" v-if="deviceList.length>0">
|
||||
<view class="device-info" v-for="(item, index) in deviceList" :key="index">
|
||||
<view class="device-header" @click.stop="handleFile(item)">
|
||||
<view class="deviceIMG">
|
||||
<image src="@/static/images/common/user.png" mode="aspectFit" class="IMG"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备名:{{item.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="ID">{{item.phonenumber}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="device-delete">
|
||||
<text class="delete" @click.stop="handleDelete(item)">移除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="noDATA">
|
||||
<view> <uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
|
||||
</view>
|
||||
暂无数据
|
||||
</view>
|
||||
</mescroll-uni>
|
||||
|
||||
<!-- 删除弹框 -->
|
||||
<view class="agreement-mask" v-if="deleteShow" @click="closePopup('delete')">
|
||||
<view class="agreement-popup" @click.stop>
|
||||
<view class="popup-content">
|
||||
<image src="/static/images/common/delel.png" mode="" class="svg"></image>
|
||||
<uni-icon class="trash"></uni-icon>
|
||||
<view>
|
||||
<view class="popup-Title">确定移除该用户!</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="btn agreeBtn" @click="handleBtn">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
deviceShareList,
|
||||
deviceShareDelete
|
||||
} from '@/api/6170/share.js'
|
||||
import MescrollUni from 'mescroll-uni/mescroll-uni.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MescrollUni
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
deviceList: [],
|
||||
deleteShow: false,
|
||||
delelteItemInfo: '',
|
||||
itemInfo: '',
|
||||
mescroll: null, // mescroll实例对象
|
||||
downOption: {
|
||||
auto: false // 不自动加载
|
||||
},
|
||||
upOption: {
|
||||
auto: false, // 不自动加载
|
||||
noMoreSize: 5, // 如果列表已无数据,可设置列表的总数量要大于等于5条才显示无更多数据
|
||||
empty: {
|
||||
tip: '暂无相关数据'
|
||||
}
|
||||
},
|
||||
page: 1, // 当前页码
|
||||
size: 10, // 每页条数
|
||||
total: 0 // 总数据量
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// mescroll组件初始化的回调,可获取到mescroll对象
|
||||
mescrollInit(mescroll) {
|
||||
this.mescroll = mescroll;
|
||||
},
|
||||
// 下拉刷新的回调
|
||||
downCallback() {
|
||||
// 重置分页参数
|
||||
this.page = 1;
|
||||
this.getData(this.itemInfo.id).then(res => {
|
||||
// 数据请求成功后,隐藏下拉刷新的状态
|
||||
this.mescroll.endSuccess();
|
||||
}).catch(() => {
|
||||
// 请求失败,隐藏下拉刷新的状态
|
||||
this.mescroll.endErr();
|
||||
})
|
||||
},
|
||||
// 上拉加载的回调
|
||||
upCallback() {
|
||||
this.getData(this.itemInfo.id).then(res => {
|
||||
// 根据是否有数据来决定是否显示无更多数据的提示
|
||||
const hasNext = this.deviceList.length < this.total;
|
||||
this.mescroll.endSuccess(this.deviceList.length, hasNext);
|
||||
}).catch(() => {
|
||||
// 请求失败,隐藏上拉加载的状态
|
||||
this.mescroll.endErr();
|
||||
})
|
||||
},
|
||||
// 点击弹框外的区域关闭
|
||||
closePopup(type) {
|
||||
if (type === 'delete') {
|
||||
this.deleteShow = false;
|
||||
}
|
||||
},
|
||||
// 删除
|
||||
handleDelete(item) {
|
||||
console.log(item, 'www');
|
||||
this.deleteShow = true
|
||||
this.delelteItemInfo = item
|
||||
},
|
||||
handleBtn() {
|
||||
let allId = this.delelteItemInfo.id
|
||||
deviceShareDelete(allId).then((res) => {
|
||||
if (res.code = 200) {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
this.deleteShow = false
|
||||
// 删除后刷新列表
|
||||
this.page = 1;
|
||||
this.getData(this.itemInfo.id).then(() => {
|
||||
this.mescroll.resetUpScroll();
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
getData(val) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let data = {
|
||||
deviceId: val,
|
||||
pageNum: this.page,
|
||||
pageSize: this.size,
|
||||
}
|
||||
deviceShareList(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.total = res.total;
|
||||
if (this.page === 1) {
|
||||
// 如果是第一页,直接替换数据
|
||||
this.deviceList = res.rows;
|
||||
} else {
|
||||
// 如果不是第一页,追加数据
|
||||
this.deviceList = this.deviceList.concat(res.rows);
|
||||
}
|
||||
resolve(res);
|
||||
} else {
|
||||
reject(res);
|
||||
}
|
||||
}).catch(err => {
|
||||
reject(err);
|
||||
})
|
||||
})
|
||||
},
|
||||
// 跳转分享详情
|
||||
handleFile(item) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/6170/deviceControl/index",
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: item,
|
||||
apiType: 'listB' // 自定义标识 // 自定义标识,详情哪里根据这个参数不同信息
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'shareDevice' 事件,获取传过来的数据
|
||||
eventChannel.on('shareManagement', (data) => {
|
||||
console.log(data, 'data1t111');
|
||||
this.itemInfo = data.data;
|
||||
// 初始化加载数据
|
||||
this.page = 1;
|
||||
this.getData(this.itemInfo.id).then(() => {
|
||||
// 数据加载完成后,如果需要可以手动触发下拉刷新结束
|
||||
if (this.mescroll) {
|
||||
this.mescroll.endSuccess();
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.share {
|
||||
padding: 30rpx;
|
||||
background: #121212;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.device-title {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
padding-top: 10rpx;
|
||||
position: relative;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.device-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-size: 32rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-left: 25rpx;
|
||||
line-height: 50rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ID {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.deviceIMG {
|
||||
/* width: 100rpx; */
|
||||
/* height: 100rpx; */
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.device-delete {
|
||||
text-align: end;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.noDATA {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
transform: translate(-0%, 100%);
|
||||
}
|
||||
|
||||
.delete {
|
||||
border-radius: 32px;
|
||||
background: rgba(255, 200, 78, 0.06);
|
||||
display: inline-block;
|
||||
width: 152rpx;
|
||||
height: 60rpx;
|
||||
text-align: center;
|
||||
line-height: 60rpx;
|
||||
color: rgba(224, 52, 52, 1);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.IMG {
|
||||
width: 120rpx;
|
||||
height: 100rpx;
|
||||
margin-left: 17%;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 18px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
/* 遮罩层 */
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.popup-Title {
|
||||
color: rgba(255, 255, 255, 0.86);
|
||||
text-align: center;
|
||||
padding: 30rpx 0rpx;
|
||||
}
|
||||
|
||||
.popup-buttons {
|
||||
display: flex;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 60%;
|
||||
background: rgba(56, 57, 52, 0.4);
|
||||
border-radius: 40rpx;
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
border: 1px solid rgba(224, 52, 52, 0.3);
|
||||
}
|
||||
|
||||
.svg {
|
||||
width: 58rpx;
|
||||
height: 58rpx;
|
||||
}
|
||||
|
||||
/* 通用按钮样式 */
|
||||
.btn {
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 24rpx;
|
||||
margin: 10rpx auto;
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
/* 同意按钮 */
|
||||
.agreeBtn {
|
||||
background: rgba(224, 52, 52, 1);
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
border: none;
|
||||
width: 170rpx !important;
|
||||
}
|
||||
</style>
|
||||
421
pages/common/Share/sharePermission.vue
Normal file
421
pages/common/Share/sharePermission.vue
Normal file
@ -0,0 +1,421 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 设备信息 -->
|
||||
<view class="device-info">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="itemInfo.devicePic" mode="aspectFit" class="IMG"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{itemInfo.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="ID">ID: {{itemInfo.deviceImei}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 功能权限 -->
|
||||
<view class="permissions">
|
||||
<view class="permissions-title">功能权限</view>
|
||||
<view :checked="allSelected" class="allSelect" @click="toggleAllSelection()">全选</view>
|
||||
<text class="permissions-title"></text>
|
||||
<view class="permission-item" v-for="(item, index) in permissions" :key="index"
|
||||
@click="toggleSelection(index)">
|
||||
<view class="checkbox" :class="{ checked: item.checked }">
|
||||
<uni-icons v-if="item.checked" type="checkmarkempty" size="18" color="rgb(0, 0, 0)"></uni-icons>
|
||||
</view>
|
||||
<view> {{ item.label }}</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 被分享人信息 -->
|
||||
<view class="recipient-info">
|
||||
<view class="recipient-title">被分享人信息</view>
|
||||
<input type="number" v-model="phone" placeholder="输入手机号" class="phone-input" :maxlength="11" />
|
||||
<view class="verification-code">
|
||||
<input type="number" v-model="code" placeholder="短信验证码" class="code-input" :maxlength="6" />
|
||||
<view class="get-code-btn" :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
||||
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 分享按钮 -->
|
||||
<button class="share-btn" @click="shareUp">分享</button>
|
||||
<!-- 分享弹框 -->
|
||||
<view class="agreement-mask" v-if="shareShow" @click="closePopup('share')">
|
||||
<view class="agreement-popup" @click.stop>
|
||||
<view class="popup-content">
|
||||
<image src="/static/images/common/success.png" mode="aspectFit" class="svg"></image>
|
||||
<view>
|
||||
<view class="popup-Title">设备分享成功</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="btn agreeBtn" @click="handleBtn">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
deviceShareId,
|
||||
deviceShareCode,
|
||||
deviceShareAdd
|
||||
} from '@/api/6170/share.js'
|
||||
|
||||
import Common from '@/utils/Common.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
allSelected: false,
|
||||
shareShow: false,
|
||||
showView: false,
|
||||
isCounting: false,
|
||||
countdown: 0,
|
||||
permissions: [],//分享的权限,先从Common.js中取,后续可能改成从接口取
|
||||
deviceInfo: {},
|
||||
phone: '',
|
||||
code: '',
|
||||
itemInfo: ''
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
closePopup() {
|
||||
this.shareShow = false
|
||||
},
|
||||
toggleAllSelection() {
|
||||
this.allSelected = !this.allSelected;
|
||||
this.permissions.forEach(permission => permission.checked = this.allSelected);
|
||||
},
|
||||
toggleSelection(index) {
|
||||
this.$set(this.permissions[index], 'checked', !this.permissions[index].checked);
|
||||
this.allSelected = this.permissions.every(permission => permission.checked);
|
||||
},
|
||||
|
||||
// 获取验证码
|
||||
async getPhoneCode() {
|
||||
const phoneNumber = this.phone
|
||||
const myreg = /^1[3456789]\d{9}$/;
|
||||
if (!phoneNumber) {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
} else if (!myreg.test(phoneNumber)) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
await deviceShareCode({
|
||||
phonenumber: this.phone
|
||||
})
|
||||
// 更新倒计时状态
|
||||
this.isCounting = true;
|
||||
this.showView = true;
|
||||
this.countdown = 60
|
||||
const timer = setInterval(() => {
|
||||
this.countdown--
|
||||
if (this.countdown <= 0) {
|
||||
clearInterval(timer)
|
||||
this.isCounting = false;
|
||||
this.showView = false;
|
||||
}
|
||||
}, 1000)
|
||||
uni.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
})
|
||||
} catch (error) {}
|
||||
},
|
||||
// 分享按钮提交
|
||||
async shareUp() {
|
||||
if (this.phone == '') {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
} else if (this.code == '') {
|
||||
uni.showToast({
|
||||
title: '验证码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
}else if (!this.permissions.some(permission => permission.checked)) {
|
||||
uni.showToast({
|
||||
title: '请选择至少一个功能权限',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '分享中'
|
||||
});
|
||||
debugger;
|
||||
console.log("iteminfo=",this.itemInfo)
|
||||
const selectedPermissions = this.permissions.filter(permission => permission.checked).map(
|
||||
permission =>
|
||||
permission.value);
|
||||
const res = await deviceShareAdd({
|
||||
phonenumber: this.phone,
|
||||
smsCode: this.code,
|
||||
deviceId: this.itemInfo.id,
|
||||
permission: selectedPermissions.join(',')
|
||||
})
|
||||
if (res.code == 200) {
|
||||
this.shareShow = true
|
||||
uni.hideLoading()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: error.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
handleBtn() {
|
||||
this.shareShow = false
|
||||
uni.navigateBack({
|
||||
delta:3
|
||||
});
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'shareDevice' 事件,获取传过来的数据
|
||||
eventChannel.on('shareDevice', (data) => {
|
||||
console.log('收到数据:',data);
|
||||
this.itemInfo = data.data;
|
||||
this.permissions=Common.getPermissions(this.itemInfo.persissonType);
|
||||
})
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
width: 100%;
|
||||
background: #121212;
|
||||
min-height: 100vh;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.device-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-size: 32rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-left: 25rpx;
|
||||
line-height: 50rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ID {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
padding-top: 10rpx;
|
||||
position: relative;
|
||||
}
|
||||
.deviceIMG {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 16rpx;
|
||||
position: relative;
|
||||
background-color: rgba(42, 42, 42, 0.6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.IMG {
|
||||
width: 68rpx;
|
||||
height: 50rpx;
|
||||
margin-left: 17%;
|
||||
}
|
||||
.title {
|
||||
font-size: 18px;
|
||||
color: white;
|
||||
}
|
||||
.device-info {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
.allSelect {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
float: right;
|
||||
}
|
||||
.device-icon {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
}
|
||||
.device-id,
|
||||
.device-serial {
|
||||
color: white;
|
||||
}
|
||||
.permissions {
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
padding: 10px;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
.permissions-title {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-size: 30rpx;
|
||||
/* padding: 30rpx 0rpx; */
|
||||
}
|
||||
.checkbox {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
border: 2rpx solid rgba(255, 255, 255, 0.5);
|
||||
margin-right:30rpx;
|
||||
border-radius: 4rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.checkbox.checked {
|
||||
background-color: rgb(187, 230, 0);
|
||||
border-color: rgb(187, 230, 0);
|
||||
}
|
||||
.permission-item {
|
||||
margin-top:35rpx;
|
||||
display: flex;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
line-height: 60rpx;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
.recipient-info {
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.recipient-title {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-size: 30rpx;
|
||||
}
|
||||
.phone-input {
|
||||
width: 100%;
|
||||
margin-top: 20rpx;
|
||||
padding: 40rpx 0;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.06);
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
.verification-code {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.06);
|
||||
padding: 40rpx 0;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
.get-code-btn {
|
||||
margin-top: 10px;
|
||||
background-color: transparent;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-size: 30rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.share-btn {
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
padding: 5rpx;
|
||||
border-radius: 91rpx;
|
||||
background: rgba(187, 230, 0, 1);
|
||||
}
|
||||
|
||||
/* 遮罩层 */
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.popup-Title {
|
||||
color: rgba(255, 255, 255, 0.86);
|
||||
text-align: center;
|
||||
padding: 30rpx 0rpx;
|
||||
}
|
||||
|
||||
.popup-buttons {
|
||||
display: flex;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 60%;
|
||||
background: rgba(56, 57, 52, 0.4);
|
||||
border-radius: 40rpx;
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
border: 1px solid rgba(187, 230, 0, 0.3);
|
||||
}
|
||||
.svg {
|
||||
width: 58rpx;
|
||||
height:58rpx;
|
||||
}
|
||||
/* 通用按钮样式 */
|
||||
.btn {
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 24rpx;
|
||||
margin: 10rpx auto;
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
/* 同意按钮 */
|
||||
.agreeBtn {
|
||||
background: rgba(187, 230, 0, 1);
|
||||
color: #232323;
|
||||
border: none;
|
||||
width: 170rpx !important;
|
||||
}
|
||||
</style>
|
||||
440
utils/Common.js
440
utils/Common.js
@ -1,218 +1,284 @@
|
||||
var cfg={
|
||||
Version:'Uat',//Dev:开发环境,Uat:Uat环境,Relese正式环境
|
||||
DevApi:'http://192.168.110.54:8000/',//开发环境
|
||||
UatApi:'http://114.55.111.217/',//UAT环境
|
||||
ReleseApi:'http://relese:3169/api/'//Relese环境
|
||||
}
|
||||
import request from "@/utils/request.js";
|
||||
export default {
|
||||
baseURL : cfg.Version=='Dev'?cfg.DevApi:(cfg.Version=='Uat'?cfg.UatApi:cfg.ReleseApi),
|
||||
guid:function generateUUID() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
const r = Math.random() * 16 | 0;
|
||||
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
},
|
||||
alert: function(title, content, callback) {
|
||||
if(!title){
|
||||
title='提示'
|
||||
}
|
||||
if(!content){
|
||||
content=title;
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: title,
|
||||
content: content,
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback(res);
|
||||
}
|
||||
guid: function generateUUID() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
const r = Math.random() * 16 | 0;
|
||||
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
},
|
||||
alert: function(title, content, callback) {
|
||||
if (!title) {
|
||||
title = '提示'
|
||||
}
|
||||
if (!content) {
|
||||
content = title;
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: title,
|
||||
content: content,
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
showLoading:function(title,mask){
|
||||
uni.showLoading({
|
||||
title:title,
|
||||
mask:mask,
|
||||
})
|
||||
},
|
||||
hideLoading:function(){
|
||||
uni.hideLoading();
|
||||
},
|
||||
showToast:function(title,mask,duration,callback){
|
||||
if(!duration){
|
||||
duration=1500;
|
||||
}
|
||||
if(mask==undefined){
|
||||
mask=false;
|
||||
}
|
||||
uni.showToast({
|
||||
title:title,
|
||||
mask:mask,
|
||||
duration:duration,
|
||||
callback:callback,
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
GetData:function(url,data,method,contentType,succ,err,complete){
|
||||
var these=this;
|
||||
if(!url){
|
||||
console.error("url为空");
|
||||
return;
|
||||
}
|
||||
|
||||
if(url.toLowerCase().indexOf('http://')==-1 || url.toLowerCase().indexOf('https://')==-1){
|
||||
if(url.indexOf('/')==0){
|
||||
url=url.substr(1,url.length-1);
|
||||
|
||||
if (callback) {
|
||||
callback(res);
|
||||
}
|
||||
let ServerPath=these.DevApi;
|
||||
if(these.Version==='Dev'){
|
||||
ServerPath=these.DevApi;
|
||||
}
|
||||
else if(these.Version==='Uat'){
|
||||
ServerPath=these.UatApi;
|
||||
}
|
||||
else if(these.Version==='Relese'){
|
||||
ServerPath=these.ReleseApi;
|
||||
}else{
|
||||
these.DevApi
|
||||
}
|
||||
url=ServerPath+url;
|
||||
}
|
||||
|
||||
var these=this;
|
||||
if(!method){
|
||||
method='POST';
|
||||
});
|
||||
},
|
||||
|
||||
showLoading: function(title, mask) {
|
||||
uni.showLoading({
|
||||
title: title,
|
||||
mask: mask,
|
||||
})
|
||||
},
|
||||
hideLoading: function() {
|
||||
uni.hideLoading();
|
||||
},
|
||||
showToast: function(title, mask, duration, callback) {
|
||||
if (!duration) {
|
||||
duration = 1500;
|
||||
}
|
||||
if (mask == undefined) {
|
||||
mask = false;
|
||||
}
|
||||
uni.showToast({
|
||||
title: title,
|
||||
mask: mask,
|
||||
duration: duration,
|
||||
callback: callback,
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
GetData: function(url, data, method, contentType, succ, err, complete) {
|
||||
var these = this;
|
||||
if (!url) {
|
||||
console.error("url为空");
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.toLowerCase().indexOf('http://') == -1 || url.toLowerCase().indexOf('https://') == -1) {
|
||||
if (url.indexOf('/') == 0) {
|
||||
url = url.substr(1, url.length - 1);
|
||||
}
|
||||
method=method.toUpperCase();
|
||||
|
||||
if(!contentType){
|
||||
contentType='application/json;charset=UTF-8';
|
||||
let ServerPath = these.DevApi;
|
||||
if (these.Version === 'Dev') {
|
||||
ServerPath = these.DevApi;
|
||||
} else if (these.Version === 'Uat') {
|
||||
ServerPath = these.UatApi;
|
||||
} else if (these.Version === 'Relese') {
|
||||
ServerPath = these.ReleseApi;
|
||||
} else {
|
||||
these.DevApi
|
||||
}
|
||||
|
||||
these.checkLAN(
|
||||
|
||||
function(){
|
||||
these.showLoading('请稍候..',true);
|
||||
setTimeout(function(){
|
||||
url = ServerPath + url;
|
||||
}
|
||||
|
||||
var these = this;
|
||||
if (!method) {
|
||||
method = 'POST';
|
||||
}
|
||||
method = method.toUpperCase();
|
||||
|
||||
if (!contentType) {
|
||||
contentType = 'application/json;charset=UTF-8';
|
||||
}
|
||||
|
||||
these.checkLAN(
|
||||
|
||||
function() {
|
||||
these.showLoading('请稍候..', true);
|
||||
setTimeout(function() {
|
||||
uni.request({
|
||||
url:url,
|
||||
data:data,
|
||||
header:{
|
||||
"Content-Type":contentType
|
||||
url: url,
|
||||
data: data,
|
||||
header: {
|
||||
"Content-Type": contentType
|
||||
},
|
||||
method:method,
|
||||
timeout:60000,
|
||||
dataType:'json',
|
||||
success:function(json){
|
||||
|
||||
if(succ){
|
||||
method: method,
|
||||
timeout: 60000,
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
|
||||
if (succ) {
|
||||
succ(json);
|
||||
}
|
||||
},
|
||||
fail:function(ex){
|
||||
|
||||
if(err){
|
||||
fail: function(ex) {
|
||||
|
||||
if (err) {
|
||||
err(ex);
|
||||
}
|
||||
},
|
||||
complete:function(){
|
||||
|
||||
if(complete){
|
||||
complete: function() {
|
||||
|
||||
if (complete) {
|
||||
complete();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},0);
|
||||
|
||||
|
||||
}, 0);
|
||||
|
||||
}
|
||||
|
||||
,function(){
|
||||
|
||||
,
|
||||
function() {
|
||||
these.showToast('无网络连接');
|
||||
});
|
||||
},
|
||||
checkLAN:function(succ,error){
|
||||
uni.getNetworkType({
|
||||
success: (res) => {
|
||||
const networkType = res.networkType;
|
||||
|
||||
|
||||
// 判断网络是否连接
|
||||
if (networkType === 'none') {
|
||||
},
|
||||
checkLAN: function(succ, error) {
|
||||
uni.getNetworkType({
|
||||
success: (res) => {
|
||||
const networkType = res.networkType;
|
||||
|
||||
|
||||
// 判断网络是否连接
|
||||
if (networkType === 'none') {
|
||||
console.error('无网络连接')
|
||||
if(error){
|
||||
error();
|
||||
}
|
||||
}else{
|
||||
if(succ){
|
||||
if (error) {
|
||||
error();
|
||||
}
|
||||
} else {
|
||||
if (succ) {
|
||||
succ();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('获取网络状态失败:', err);
|
||||
if(error){
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('获取网络状态失败:', err);
|
||||
if (error) {
|
||||
error();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
DateFormat: function(date, format) {
|
||||
if(!date){
|
||||
date=new Date();
|
||||
}
|
||||
if(!format){
|
||||
format='yyyy-MM-dd HH:mm:ss';
|
||||
}
|
||||
// 处理参数默认值
|
||||
if (typeof date === 'string' || typeof date === 'number') {
|
||||
date = new Date(date);
|
||||
}
|
||||
date = date instanceof Date ? date : new Date();
|
||||
format = format || 'yyyy-MM-dd';
|
||||
|
||||
// 检查日期是否有效
|
||||
if (isNaN(date.getTime())) {
|
||||
return 'Invalid Date';
|
||||
}
|
||||
|
||||
// 定义格式化映射
|
||||
const formatMap = {
|
||||
'yyyy': date.getFullYear(),
|
||||
'MM': String(date.getMonth() + 1).padStart(2, '0'),
|
||||
'dd': String(date.getDate()).padStart(2, '0'),
|
||||
'HH': String(date.getHours()).padStart(2, '0'),
|
||||
'mm': String(date.getMinutes()).padStart(2, '0'),
|
||||
'ss': String(date.getSeconds()).padStart(2, '0'),
|
||||
'SSS': String(date.getMilliseconds()).padStart(3, '0'),
|
||||
'M': date.getMonth() + 1,
|
||||
'd': date.getDate(),
|
||||
'H': date.getHours(),
|
||||
'm': date.getMinutes(),
|
||||
's': date.getSeconds(),
|
||||
'S': date.getMilliseconds()
|
||||
};
|
||||
|
||||
// 替换格式字符串中的占位符
|
||||
return format.replace(/(yyyy|MM|dd|HH|mm|ss|SSS|M|d|H|m|s|S)/g, (match) => {
|
||||
return formatMap[match];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
DateFormat: function(date, format) {
|
||||
if (!date) {
|
||||
date = new Date();
|
||||
}
|
||||
if (!format) {
|
||||
format = 'yyyy-MM-dd HH:mm:ss';
|
||||
}
|
||||
// 处理参数默认值
|
||||
if (typeof date === 'string' || typeof date === 'number') {
|
||||
date = new Date(date);
|
||||
}
|
||||
date = date instanceof Date ? date : new Date();
|
||||
format = format || 'yyyy-MM-dd';
|
||||
|
||||
// 检查日期是否有效
|
||||
if (isNaN(date.getTime())) {
|
||||
return 'Invalid Date';
|
||||
}
|
||||
|
||||
// 定义格式化映射
|
||||
const formatMap = {
|
||||
'yyyy': date.getFullYear(),
|
||||
'MM': String(date.getMonth() + 1).padStart(2, '0'),
|
||||
'dd': String(date.getDate()).padStart(2, '0'),
|
||||
'HH': String(date.getHours()).padStart(2, '0'),
|
||||
'mm': String(date.getMinutes()).padStart(2, '0'),
|
||||
'ss': String(date.getSeconds()).padStart(2, '0'),
|
||||
'SSS': String(date.getMilliseconds()).padStart(3, '0'),
|
||||
'M': date.getMonth() + 1,
|
||||
'd': date.getDate(),
|
||||
'H': date.getHours(),
|
||||
'm': date.getMinutes(),
|
||||
's': date.getSeconds(),
|
||||
'S': date.getMilliseconds()
|
||||
};
|
||||
|
||||
// 替换格式字符串中的占位符
|
||||
return format.replace(/(yyyy|MM|dd|HH|mm|ss|SSS|M|d|H|m|s|S)/g, (match) => {
|
||||
return formatMap[match];
|
||||
});
|
||||
},
|
||||
getdeviceShareId(id) {//获取设备分享信息
|
||||
return request({
|
||||
url: `/app/deviceShare/${id}`,
|
||||
method: 'get',
|
||||
})
|
||||
},
|
||||
getPermissions(type) {
|
||||
if (!type) {
|
||||
return undefined;
|
||||
}
|
||||
let array = [{
|
||||
value: "1",
|
||||
label: "灯光模式",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670']
|
||||
},
|
||||
{
|
||||
value: "2",
|
||||
label: "激光模式",
|
||||
checked: false,
|
||||
type: ['210', '6170']
|
||||
},
|
||||
{
|
||||
value: "3",
|
||||
label: "开机画面",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670']
|
||||
},
|
||||
{
|
||||
value: "4",
|
||||
label: "人员信息登记",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670']
|
||||
},
|
||||
{
|
||||
value: "5",
|
||||
label: "发送信息",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670']
|
||||
},
|
||||
{
|
||||
value: "6",
|
||||
label: "产品信息",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670']
|
||||
}, {
|
||||
value: "41",
|
||||
label: "静电探测",
|
||||
checked: false,
|
||||
type: ['670']
|
||||
}, {
|
||||
value: "42",
|
||||
label: "SOS",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670']
|
||||
}
|
||||
]
|
||||
|
||||
let arr=[];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
let item = array[i];
|
||||
if(!item){
|
||||
continue;
|
||||
}
|
||||
if(!item.type){
|
||||
continue;
|
||||
}
|
||||
let typeContais=item.type.find(v=>{
|
||||
return v.includes(type);
|
||||
});
|
||||
if(typeContais){
|
||||
let json={};
|
||||
Object.assign(json,item);
|
||||
arr.push(json);
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
import config from '../config/index.js';
|
||||
const env = 'production'; //production development //开发of线上 改这里就行
|
||||
const env = 'development'; //production development //开发of线上 改这里就行
|
||||
const BASE = config[env];
|
||||
const request = (options) => {
|
||||
console.log("options"+JSON.stringify(options),BASE.BASE_URL)
|
||||
|
||||
@ -62,7 +62,7 @@ function checkAndUpdateWgt(updateUrl) {
|
||||
data: {
|
||||
currentVersion: currentVersion,
|
||||
platform: uni.getSystemInfoSync().platform,
|
||||
appId:"xhyc"
|
||||
appId:"xhyc"
|
||||
},
|
||||
success: (res) => {
|
||||
// console.log("res=>",res)
|
||||
|
||||
Reference in New Issue
Block a user