蓝牙设备均添加可主动断开蓝牙

This commit is contained in:
liub
2026-02-13 16:42:15 +08:00
parent 27097fecc4
commit 1aa11a7a38
9 changed files with 467 additions and 171 deletions

View File

@ -14,11 +14,11 @@
<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)">
@ -54,9 +54,9 @@
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item">
<view class="item" @click.top="bleStatuToggle">
<text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
</view>
<view class="item">
<text class="lbl">信道:{{formData.sta_Channel}}</text>
@ -175,15 +175,15 @@
</view>
<view class="text">朝右</view>
</view>
</view>
<view class="line"></view>
<view class="modeSetting">
<view class="arrow" @click.stop="ArrowSet('red_front')"
:class="formData.sta_ArrowType=='red_front'?'redactive':''">
<view class="outCircle">
@ -191,7 +191,7 @@
<view class="text">红色</view>
</view>
</view>
</view>
<view class="arrow" @click.stop="ArrowSet('green_back')"
:class="formData.sta_ArrowType=='green_back'?'greenactive':''">
@ -200,10 +200,10 @@
<view class="text">绿色</view>
</view>
</view>
</view>
</view>
</view>
<view class="lamp noPadding">
@ -295,7 +295,9 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
import request, { baseURL } from '@/utils/request.js';
import request, {
baseURL
} from '@/utils/request.js';
import Common from '@/utils/Common.js';
import {
colors as groupColors
@ -323,7 +325,7 @@ import request, { baseURL } from '@/utils/request.js';
apiType: 'listA'
}],
title: 'BJQ4877'
},
ShowEditChannel: false,
pageHide: false,
@ -403,9 +405,9 @@ import request, { baseURL } from '@/utils/request.js';
sta_ArrowType: '', //箭头方向
warnTime: 0,
sta_Channel: 31,
sta_ArrowMode:'',
sta_ArrowMode: '',
groups: [
]
},
dic: {
@ -422,7 +424,7 @@ import request, { baseURL } from '@/utils/request.js';
activeImg: '/static/images/4877/fanActive.png'
}
]
},
device: {
id: "",
@ -480,7 +482,7 @@ import request, { baseURL } from '@/utils/request.js';
// 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') {
@ -492,7 +494,7 @@ import request, { baseURL } from '@/utils/request.js';
}
});
}
let checkIds = uni.getStorageSync("4877CheckColor_" + data.data.id);
if (checkIds && checkIds.length) {
let groups = groupColors.filter(v => {
@ -508,7 +510,7 @@ import request, { baseURL } from '@/utils/request.js';
these.formData.groups = groups;
}
let arr = [{
topic: 'C/4877_Groups_' + these.device.id,
@ -556,6 +558,7 @@ import request, { baseURL } from '@/utils/request.js';
these.formData.deviceId = f.deviceId;
these.formData.warnTime = null;
these.formData.sta_SOSType = 'sos_off';
these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
});
@ -573,9 +576,50 @@ import request, { baseURL } from '@/utils/request.js';
this.Status.pageHide = false;
},
computed: {
getbleStatu() {
if (this.formData.bleStatu === true) {
return '已连接';
}
if (this.formData.bleStatu === 'connecting') {
return '连接中';
}
if (this.formData.bleStatu === 'dicconnect') {
return '正在断开';
}
if (this.formData.bleStatu === 'err') {
return '连接异常';
}
return '未连接';
}
},
methods: {
bleStatuToggle() {
let f = this.getDevice();
if (!f) {
this.showBleUnConnect();
return;
}
if (this.formData.bleStatu === true) {
this.formData.bleStatu = 'dicconnect';
ble.disconnectDevice(f.deviceId).finally(r => {
this.formData.bleStatu = false;
});
return;
}
if (this.formData.bleStatu === false || this.formData.bleStatu === 'err') {
these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
}).catch(ex => {
these.formData.bleStatu = 'err';
});
return;
}
},
handleRightClick(item, s) {
if (item && item.callback) {
item.callback(item, s);
@ -583,7 +627,7 @@ import request, { baseURL } from '@/utils/request.js';
uni.showModal({
content: '敬请期待'
})
}
},
navigatorBack() {
@ -612,11 +656,11 @@ import request, { baseURL } from '@/utils/request.js';
let str = rec.receive.payloadString;
let json = JSON.parse(str);
if('ins_channel' in json){
this.formData.sta_Channel=json.ins_channel;
if ('ins_channel' in json) {
this.formData.sta_Channel = json.ins_channel;
these.setBleFormData();
}
}
} catch (err) {
}
@ -636,8 +680,8 @@ import request, { baseURL } from '@/utils/request.js';
return false;
});
these.formData.groups = groups;
console.error("groups=",these.formData.groups);
these.formData.groups = groups;
console.error("groups=", these.formData.groups);
let checks = groups.map(item => {
return item.id
});
@ -655,9 +699,9 @@ 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",
@ -668,7 +712,7 @@ import request, { baseURL } from '@/utils/request.js';
})
return;
}
this.Status.ShowEditChannel = true;
this.showPop({
showPop: true, //是否显示弹窗
@ -736,9 +780,9 @@ 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",
@ -749,12 +793,12 @@ import request, { baseURL } from '@/utils/request.js';
})
return;
}
if (this.formData.sta_SOSType === 'sos') {
this.showMsg("设备强制报警中,请先关闭报警")
return;
}
let f = this.getDevice();
if (!f) {
this.showBleUnConnect();
@ -763,7 +807,7 @@ import request, { baseURL } from '@/utils/request.js';
if (this.formData.sta_ArrowMode === val) {
return;
}
var json = {
ins_right_side: val
}
@ -800,8 +844,8 @@ import request, { baseURL } from '@/utils/request.js';
});
},
groupCheck() {
if (!this.permissions.includes('54') && this.Status.apiType !== 'listA') {
if (!this.permissions.includes('54') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
@ -882,9 +926,9 @@ if (!this.permissions.includes('54') && this.Status.apiType !== 'listA') {
// });
},
groupSetting(item, index) {
if (!this.permissions.includes('54') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
@ -895,7 +939,7 @@ if (!this.permissions.includes('54') && this.Status.apiType !== 'listA') {
})
return;
}
if (this.formData.sta_SOSType === 'sos') {
this.showMsg("设备强制报警中,请先关闭报警")
return;
@ -942,8 +986,8 @@ if (!this.permissions.includes('54') && this.Status.apiType !== 'listA') {
},
sosSetting(item, index) {
if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
@ -1076,6 +1120,7 @@ if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
showLoading(this, {
text: "蓝牙恢复可用,正在连接设备"
});
these.formData.bleStatu = 'connecting';
ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true;
updateLoading(these, {
@ -1822,22 +1867,23 @@ if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
letter-spacing: 0.14rpx;
}
.modeSetting .arrow .outCircle .text {
margin-top:0rpx !important;
margin-top: 0rpx !important;
}
.arrowContent .line {
width:calc(100% - 60rpx);
height: 0rpx;
border-bottom:1px solid #ffffff30;
margin: 30rpx ;
}
.arrowContent .line {
width: calc(100% - 60rpx);
height: 0rpx;
border-bottom: 1px solid #ffffff30;
margin: 30rpx;
}
.modeSetting .arrow .outCircle {
width: 120rpx;
height: 120rpx;
@ -1881,33 +1927,33 @@ if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
border-radius: 50%;
}
.modeSetting .arrow.redactive .outCircle {
border: 4rpx solid #EC2A2A;
padding: 4rpx;
}
.modeSetting .arrow.redactive .item {
background: #EC2A2A;
border-radius: 50%;
}
.modeSetting .arrow.greenactive .outCircle {
border: 4rpx solid #00BD00;
padding: 4rpx;
}
.modeSetting .arrow.greenactive .item {
background: #00BD00;
border-radius: 50%;
}
.modeSetting .arrow.redactive .item .text,
.modeSetting .arrow.greenactive .item .text{
color:#FFFFFFde !important;
.modeSetting .arrow.greenactive .item .text {
color: #FFFFFFde !important;
}
@ -2202,29 +2248,29 @@ if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
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;
@ -2240,33 +2286,33 @@ if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
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;