蓝牙按工厂要求修改,app隐藏时断开设备蓝牙,已配对设备显示实际连接的设备
# Conflicts: # App.vue
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
|
||||
<view class="list" style="margin-bottom: 30rpx;">
|
||||
|
||||
<view class="item " v-for="item, index in PairEquip" v-show="PairEquip.length>0">
|
||||
<view class="item " @click.stop="disConnect(item,index)" v-for="item, index in PairEquip" v-show="PairEquip.length>0">
|
||||
<view class="leftImg ">
|
||||
<image src="/static/images/common/bluetooth.png" class="titleIco filterNone"
|
||||
mode="heightFix">
|
||||
@ -164,7 +164,8 @@
|
||||
|
||||
},
|
||||
search: '', //筛选
|
||||
PairEquip: [], //本次已配对设备
|
||||
PairEquip: [], //已配对设备
|
||||
tmpLink:[],//本次已配对
|
||||
EquipMents: [], //搜索出来的设备
|
||||
device: null,
|
||||
item: {
|
||||
@ -192,9 +193,9 @@
|
||||
ble.StopSearch();
|
||||
ble.removeAllCallback(pagePath);
|
||||
if (!this.device && !this.Status.navigateTO) {
|
||||
if (this.PairEquip && this.PairEquip.length && this.PairEquip.length > 0) {
|
||||
if (this.tmpLink && this.tmpLink.length && this.tmpLink.length > 0) {
|
||||
console.error("页面卸载时,断开所有连接")
|
||||
let f = this.PairEquip.forEach((v) => {
|
||||
let f = this.tmpLink.forEach((v) => {
|
||||
ble.disconnectDevice(v.deviceId).catch(ex => {
|
||||
console.error("无法断开设备连接", ex);
|
||||
});
|
||||
@ -531,8 +532,7 @@
|
||||
|
||||
time = setTimeout(() => {
|
||||
these.EquipMents = [];
|
||||
console.error("1111111111")
|
||||
these.PairEquip = [];
|
||||
|
||||
|
||||
ble.StartSearch().then(result => {
|
||||
// console.log("开始搜索成功", result);
|
||||
@ -683,7 +683,7 @@
|
||||
|
||||
text: "等待设备上报Mac地址," + these.Status.time + 's'
|
||||
});
|
||||
console.log("11111111", this.Status.time);
|
||||
|
||||
clearInterval(this.Status.intval);
|
||||
this.Status.intval = null;
|
||||
|
||||
@ -745,12 +745,12 @@
|
||||
return;
|
||||
}
|
||||
// console.log("验证设备")
|
||||
// these.DeviceVerdict(item.deviceId);
|
||||
these.DeviceVerdict(item.deviceId);
|
||||
}
|
||||
let execLink = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
|
||||
|
||||
if (index > total) {
|
||||
reject({
|
||||
msg: "连接超时"
|
||||
@ -758,6 +758,7 @@
|
||||
return;
|
||||
}
|
||||
ble.LinkBlue(item.deviceId).then((res) => {
|
||||
this.tmpLink=[item];
|
||||
console.log("连接成功");
|
||||
ble.StopSearch();
|
||||
resolve(res);
|
||||
@ -793,6 +794,22 @@
|
||||
|
||||
|
||||
|
||||
},
|
||||
disConnect:function(item,index){
|
||||
// #ifdef H5|WEB
|
||||
|
||||
this.PairEquip.splice(index,1);
|
||||
|
||||
// #endif
|
||||
// #ifdef APP|APP-PLUS
|
||||
if(ble){
|
||||
ble.disconnectDevice(item.deviceId).catch(ex=>{
|
||||
console.error("无法断开连接",ex);
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -932,7 +949,7 @@
|
||||
position: absolute;
|
||||
top: 240rpx;
|
||||
left: 0rpx;
|
||||
/* border: 1px solid #BBE600; */
|
||||
z-index: 101;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user