修复有时候蓝牙配对成功依然提示未连接的异常
This commit is contained in:
@ -43,7 +43,7 @@
|
||||
<text class="lbl">设备名称</text>
|
||||
<text class="value valueFont">{{device.deviceName}}</text>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">Mac地址</text>
|
||||
@ -62,9 +62,9 @@
|
||||
<text class="value valueFont">{{formData.sta_system}}</text>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
<ProParams :id="device.id"></ProParams>
|
||||
<MsgBox ref="msgPop" />
|
||||
<global-loading ref="loading" />
|
||||
@ -97,7 +97,7 @@
|
||||
var ble = null;
|
||||
var recei = null;
|
||||
var mq = null;
|
||||
var pagePath=null;
|
||||
var pagePath = null;
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -193,11 +193,11 @@
|
||||
onUnload() {
|
||||
console.log("页面卸载,释放资源");
|
||||
let statusTopic = `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
|
||||
if(ble){
|
||||
ble.removeAllCallback(pagePath);
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
if (ble) {
|
||||
ble.removeAllCallback(pagePath);
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
}
|
||||
|
||||
|
||||
if (mq) {
|
||||
mq.unsubscribe(statusTopic);
|
||||
mq.disconnect();
|
||||
@ -213,7 +213,7 @@
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
|
||||
|
||||
these = this;
|
||||
recei = BleReceive.getBleReceive();
|
||||
ble = BleTool.getBleTool();
|
||||
@ -248,14 +248,7 @@
|
||||
if (these.device.deviceImei) {
|
||||
these.initMQ();
|
||||
}
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
if (v.macAddress == device.deviceMac) {
|
||||
console.log("找到设备了", v);
|
||||
these.formData.deviceId = v.deviceId;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
let f =these.getDevice();
|
||||
if (!f) {
|
||||
these.showBleUnConnect();
|
||||
these.getDetail();
|
||||
@ -282,7 +275,7 @@
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});
|
||||
});
|
||||
|
||||
@ -309,7 +302,7 @@
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -377,7 +370,7 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
@ -433,8 +426,8 @@
|
||||
updateLoading(these, {
|
||||
text: ex.msg
|
||||
})
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
}).finally(() => {
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
@ -442,7 +435,7 @@
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
prevPage() {
|
||||
uni.navigateBack({
|
||||
|
||||
@ -472,7 +465,27 @@
|
||||
})
|
||||
}
|
||||
},
|
||||
getDevice: function() {
|
||||
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
let flag = v.macAddress == these.device.deviceMac;
|
||||
if (!flag && v.device) {
|
||||
flag = v.device.id == these.device.id;
|
||||
}
|
||||
if (flag) {
|
||||
these.formData.deviceId = v.deviceId;
|
||||
}
|
||||
return flag;
|
||||
});
|
||||
|
||||
// #ifdef WEB
|
||||
f = {
|
||||
deviceId: '123'
|
||||
}
|
||||
// #endif
|
||||
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user