|
@@ -80,7 +80,6 @@ Page({
|
|
|
deviceListSelect: null,
|
|
|
deviceList: [],
|
|
|
_willConnectBle: null,
|
|
|
- _hasShowModal: null,
|
|
|
// deviceList: [{
|
|
|
// "connectType": 3,
|
|
|
// "devName": "猫王小王子OTR-X",
|
|
@@ -837,27 +836,7 @@ 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);
|
|
@@ -879,11 +858,10 @@ Page({
|
|
|
console.log("有蓝牙设备上线")
|
|
|
that.stopIntervalId1();
|
|
|
} else {
|
|
|
- let onLineBle = deviceList.find(item => {
|
|
|
- return item.state == "online" && item.connectType === 1
|
|
|
+ let disDevice = deviceList.find(item => {
|
|
|
+ return item.state == "online" && item.connectType === 3
|
|
|
})
|
|
|
- if (!onLineBle) {
|
|
|
- // 没有在线的蓝牙
|
|
|
+ if (!disDevice) {
|
|
|
that.startBleTimer(isFirst);
|
|
|
}
|
|
|
}
|
|
@@ -897,13 +875,17 @@ 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)
|