蓝牙设备均添加可主动断开蓝牙
This commit is contained in:
@ -58,9 +58,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">设备状态</text>
|
||||
@ -147,7 +147,7 @@
|
||||
</view>
|
||||
|
||||
|
||||
<view style="padding-bottom: 20rpx;">
|
||||
<view style="padding-bottom: 20rpx;">
|
||||
|
||||
|
||||
<view class="proinfo lamp">
|
||||
@ -489,8 +489,11 @@
|
||||
|
||||
these.formData.bleStatu = false;
|
||||
these.formData.deviceId = f.deviceId;
|
||||
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';
|
||||
});
|
||||
these.formData.sta_IntrusTime = 0;
|
||||
these.formData.sta_sosadd = "";
|
||||
@ -530,10 +533,25 @@
|
||||
}
|
||||
});
|
||||
return active;
|
||||
},
|
||||
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: {
|
||||
getLinkedCnt() {//获取在线设备的数量
|
||||
getLinkedCnt() { //获取在线设备的数量
|
||||
|
||||
let f = this.getDevice();
|
||||
// #ifdef APP-PLUS
|
||||
@ -552,11 +570,11 @@
|
||||
let buffer = {
|
||||
ins_Quantity: "query"
|
||||
};
|
||||
ble.sendString(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(res=>{
|
||||
setTimeout(()=>{
|
||||
ble.sendString(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(res => {
|
||||
setTimeout(() => {
|
||||
this.getWarns();
|
||||
},1500);
|
||||
}).catch(()=>{
|
||||
}, 1500);
|
||||
}).catch(() => {
|
||||
this.getWarns();
|
||||
})
|
||||
}
|
||||
@ -591,12 +609,12 @@
|
||||
uni.getStorage({
|
||||
key: linkKey,
|
||||
success(res) {
|
||||
console.error("获取到联机数据",res);
|
||||
console.error("获取到联机数据", res);
|
||||
let data = res.data;
|
||||
let fs = data.filter(v => {
|
||||
return !v.read
|
||||
});
|
||||
console.error("未读联机数据",fs);
|
||||
console.error("未读联机数据", fs);
|
||||
succ(fs);
|
||||
},
|
||||
fail(ex) {
|
||||
@ -609,12 +627,12 @@
|
||||
let fs = [];
|
||||
|
||||
if (results[0].status == 'fulfilled') {
|
||||
fs=fs.concat(results[0].value);
|
||||
fs = fs.concat(results[0].value);
|
||||
}
|
||||
if (results[1].status == 'fulfilled') {
|
||||
fs=fs.concat(results[1].value);
|
||||
fs = fs.concat(results[1].value);
|
||||
}
|
||||
console.error("获取到未读消息",fs);
|
||||
console.error("获取到未读消息", fs);
|
||||
these.$set(these.Status.navbar.icons[0], "math", fs.length);
|
||||
});
|
||||
|
||||
@ -994,12 +1012,14 @@ console.error("获取到未读消息",fs);
|
||||
showLoading(this, {
|
||||
text: "蓝牙恢复可用,正在连接设备"
|
||||
});
|
||||
this.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(these.formData.deviceId).then(() => {
|
||||
these.formData.bleStatu = true;
|
||||
updateLoading(these, {
|
||||
text: '连接成功'
|
||||
});
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
updateLoading(these, {
|
||||
text: ex.msg
|
||||
})
|
||||
@ -1031,9 +1051,9 @@ console.error("获取到未读消息",fs);
|
||||
let json = recei.ReceiveData(receive, device, pagePath, recArr);
|
||||
|
||||
console.log("json=", json)
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
this.getWarns();
|
||||
},500);
|
||||
}, 500);
|
||||
|
||||
|
||||
let active = -1;
|
||||
@ -1216,6 +1236,32 @@ console.error("获取到未读消息",fs);
|
||||
return f;
|
||||
},
|
||||
|
||||
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') {
|
||||
this.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;
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
setBleFormData() {
|
||||
ble.data.LinkedList.find((v) => {
|
||||
|
||||
Reference in New Issue
Block a user