|
@@ -80,6 +80,7 @@ Page({
|
|
|
deviceListSelect: null,
|
|
|
deviceList: [],
|
|
|
_willConnectBle: null,
|
|
|
+ _hasShowModal: null,
|
|
|
// deviceList: [{
|
|
|
// "connectType": 3,
|
|
|
// "devName": "猫王小王子OTR-X",
|
|
@@ -836,7 +837,27 @@ Page({
|
|
|
|
|
|
that.addNotification()
|
|
|
},
|
|
|
-
|
|
|
+ disconnectDev(event, device) {
|
|
|
+ let _this = this;
|
|
|
+ console.log("断开连接--", event.commonValue, event.deviceId);
|
|
|
+ if (event.deviceId === device.deviceId && event.commonValue === "offline" && !_this.data._hasShowModal) {
|
|
|
+ _this.data._hasShowModal = true
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '设备断开连接,请重新连接设备',
|
|
|
+ showCancel: false,
|
|
|
+ success: function (res) {
|
|
|
+ _this.data._hasShowModal = false;
|
|
|
+ if (res.confirm) {
|
|
|
+ if (getCurrentPages()[getCurrentPages().length - 1].disconnectDevCallback) {
|
|
|
+ getCurrentPages()[getCurrentPages().length - 1].disconnectDevCallback();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 设备断开连接,请重新连接设备
|
|
|
+ },
|
|
|
addNotification() {
|
|
|
let that = this;
|
|
|
event_bus.removeNotification(CmdEvent.eventName, that);
|
|
@@ -858,10 +879,11 @@ Page({
|
|
|
console.log("有蓝牙设备上线")
|
|
|
that.stopIntervalId1();
|
|
|
} else {
|
|
|
- let disDevice = deviceList.find(item => {
|
|
|
- return item.state == "online" && item.connectType === 3
|
|
|
+ let onLineBle = deviceList.find(item => {
|
|
|
+ return item.state == "online" && item.connectType === 1
|
|
|
})
|
|
|
- if (!disDevice) {
|
|
|
+ if (!onLineBle) {
|
|
|
+ // 没有在线的蓝牙
|
|
|
that.startBleTimer(isFirst);
|
|
|
}
|
|
|
}
|
|
@@ -875,17 +897,13 @@ Page({
|
|
|
// }
|
|
|
// });
|
|
|
if (!disDevice) {
|
|
|
- console.log("没有在线的")
|
|
|
+ console.log("没有找到在线的对应的蓝牙设备")
|
|
|
return;
|
|
|
}
|
|
|
+ that.disconnectDev(event, disDevice)
|
|
|
disDevice.state = event.commonValue;
|
|
|
console.log("首页设备状态变化", disDevice.state, disDevice.deviceId)
|
|
|
|
|
|
- let hasOnline = deviceList.find(item => {
|
|
|
- return item.state == "online" && item.connectType == 1
|
|
|
- })
|
|
|
- console.log("发现有在线的", hasOnline)
|
|
|
-
|
|
|
if (event.commonValue == "online") {
|
|
|
// BtHelper.getInstance().connect()
|
|
|
console.log("首页上线连接", disDevice)
|