蓝牙设备添加分享功能

This commit is contained in:
liub
2026-01-29 16:52:52 +08:00
parent dae3561235
commit 23fe40902b
8 changed files with 852 additions and 64 deletions

View File

@ -1,5 +1,25 @@
<template>
<view class="content contentBg">
<uni-nav-bar class="nvbar" leftIcon="left" @clickLeft="navigatorBack">
<view slot="left">
<uni-icons type="back" size="23" color="#FFFFFF"></uni-icons>
</view>
<view slot="default" class="center uninavebartext">
{{Status.navbar.title}}
</view>
<view slot="right">
<view class="navbarRight center">
<view class="imgContent" :class="{'visibilityHidden':Status.apiType!=item.apiType}"
@click.stop="handleRightClick(item,index)" v-for="item,index in Status.navbar.icons">
<image class="img" :src="item.src" mode="aspectFit"></image>
<view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view>
</view>
</view>
</view>
</uni-nav-bar>
<view class="eq">
<view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)">
<image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image>
@ -276,6 +296,7 @@
updateLoading
} from '@/utils/loading.js'
import request, { baseURL } from '@/utils/request.js';
import Common from '@/utils/Common.js';
import {
colors as groupColors
} from '@/api/4877/BJQ4877.js';
@ -294,6 +315,16 @@ import request, { baseURL } from '@/utils/request.js';
data() {
return {
Status: {
apiType: '',
navbar: {
icons: [{
src: '/static/images/common/shape.png',
callback: this.gotoShare,
apiType: 'listA'
}],
title: 'BJQ4877'
},
ShowEditChannel: false,
pageHide: false,
Pop: {
@ -355,6 +386,7 @@ import request, { baseURL } from '@/utils/request.js';
},
usrToggle: true,
},
permissions: [],
formData: {
img: '/static/images/common/BJQ4877.png',
sta_PowerPercent: '',
@ -446,7 +478,21 @@ import request, { baseURL } from '@/utils/request.js';
eventChannel.on('detailData', function(data) {
// console.log("收到父页面的参数:" + JSON.stringify(data));
let device = data.data;
these.device = device;
these.Status.apiType = data.apiType;
these.Status.navbar.title = device.deviceName;
if (data.apiType !== 'listA') {
Common.getdeviceShareId(data.data.id).then(res => {
if (res.code == 200) {
if (res.data.permission) {
these.permissions = res.data.permission.split(',');
}
}
});
}
let checkIds = uni.getStorageSync("4877CheckColor_" + data.data.id);
if (checkIds && checkIds.length) {
let groups = groupColors.filter(v => {
@ -462,8 +508,7 @@ import request, { baseURL } from '@/utils/request.js';
these.formData.groups = groups;
}
var device = data.data;
these.device = device;
let arr = [{
topic: 'C/4877_Groups_' + these.device.id,
@ -531,6 +576,36 @@ import request, { baseURL } from '@/utils/request.js';
},
methods: {
handleRightClick(item, s) {
if (item && item.callback) {
item.callback(item, s);
} else {
uni.showModal({
content: '敬请期待'
})
}
},
navigatorBack() {
uni.navigateBack();
},
gotoShare(item, s) {
uni.navigateTo({
url: '/pages/common/share/index',
events: {
ack: function(data) {}
},
success: (res) => {
let json = {
persissonType: '4877'
};
Object.assign(json, this.device);
res.eventChannel.emit('share', {
data: json
});
}
})
},
getChannel(rec) {
console.error("收到MQ信道保留消息:", rec);
try {
@ -580,6 +655,20 @@ import request, { baseURL } from '@/utils/request.js';
},
ShowChannelEdit() {
if (!this.permissions.includes('55') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
this.Status.ShowEditChannel = true;
this.showPop({
showPop: true, //是否显示弹窗
@ -647,6 +736,20 @@ import request, { baseURL } from '@/utils/request.js';
},
ArrowModeSet(val) {
if (!this.permissions.includes('53') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
if (this.formData.sta_SOSType === 'sos') {
this.showMsg("设备强制报警中,请先关闭报警")
return;
@ -697,7 +800,18 @@ import request, { baseURL } from '@/utils/request.js';
});
},
groupCheck() {
if (!this.permissions.includes('54') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
uni.navigateTo({
url: '/pages/4877/BJQ4877CheckColor',
events: {
@ -768,6 +882,20 @@ import request, { baseURL } from '@/utils/request.js';
// });
},
groupSetting(item, index) {
if (!this.permissions.includes('54') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
if (this.formData.sta_SOSType === 'sos') {
this.showMsg("设备强制报警中,请先关闭报警")
return;
@ -814,7 +942,18 @@ import request, { baseURL } from '@/utils/request.js';
},
sosSetting(item, index) {
if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
let f = this.getDevice();
if (!f) {
this.showBleUnConnect();
@ -2063,4 +2202,73 @@ import request, { baseURL } from '@/utils/request.js';
text-align: center;
}
.navbarRight {
width: 40px;
height: 100%;
}
.navbarRight .imgContent {
width: 36rpx;
height: 36rpx;
position: relative;
}
.navbarRight .imgContent:first-child {
width: 38rpx !important;
height: 38rpx !important;
margin-top: -2rpx;
}
.navbarRight .imgContent .baber {
position: absolute;
z-index: 100;
width: 30rpx;
height: 30rpx;
line-height: 30rpx;
right: -15rpx;
top: -15rpx;
border-radius: 50%;
background: #f12828;
color: #ffffff;
font-family: 'PingFang SC';
font-style: Regular;
font-size: 20rpx;
font-weight: 400;
text-align: center;
overflow: hidden;
white-space: nowrap;
}
.navbarRight .imgContent .img {
width: 100%;
height: 100%;
box-sizing: border-box;
position: relative;
}
.navbarRight .imgContent .img:last-child {
padding: 1rpx;
}
.nvbar {
top: 0px;
}
/deep/ .uni-navbar--fixed {
top: 0px;
}
.uninavebartext {
width: 100%;
font-size: 32rpx;
}
</style>