Przeglądaj źródła

Revert "feature:修改黑胶设备的掉线监听问题"

This reverts commit 73cba7f7b9867c01ea4fd06cb63aec27d786976f.
zeng.chen 5 miesięcy temu
rodzic
commit
3ee36fc7fb
2 zmienionych plików z 29 dodań i 31 usunięć
  1. 10 28
      pages/index/index.js
  2. 19 3
      pages/piano/cropper/cropper.js

+ 10 - 28
pages/index/index.js

@@ -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)

+ 19 - 3
pages/piano/cropper/cropper.js

@@ -530,9 +530,24 @@ Page({
     });
     that.data._imgTopPic = image.pic
   },
-  disconnectDevCallback() {
-    route_util.goBackHomePage()
-    // 设备断开连接回调,请重新连接设备
+  disconnect(event) {
+    let _this = this;
+    console.log("断开连接--", event.commonValue, event.deviceId);
+    if (event.deviceId === _this.data._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) {
+            route_util.goBackHomePage()
+          }
+        }
+      })
+    }
+    // 设备断开连接,请重新连接设备
   },
 
   /**
@@ -568,6 +583,7 @@ Page({
       switch (name) {
         case EnumCmdEvent.onoffline:
           wx.hideLoading();
+          _this.disconnect(event)
           break;
         case EnumCmdEvent.wallpaper:
           //0x78