Pārlūkot izejas kodu

fix:增加wifi设备下线的通知

zeng.chen 2 mēneši atpakaļ
vecāks
revīzija
9a4aeb4374
1 mainītis faili ar 10 papildinājumiem un 7 dzēšanām
  1. 10 7
      pages/pageA/index/index.js

+ 10 - 7
pages/pageA/index/index.js

@@ -292,7 +292,16 @@ Page({
         case "message_onoffline":
           constant.lexinConnect.searchOnlineDevice(payloads, function (list) {
             that.updateDeviceList(list, false, false);
-            that.stopIntervalId1()
+            let hasOnline = that.data.deviceList.find(item => {
+              return item.state === 'online';
+            });
+            if (hasOnline) {
+              console.log("停止蓝牙监听1:",)
+              that.stopIntervalId1()
+            } else {
+              console.log("开启蓝牙监听1:",)
+              that.startBleTimer(true, false);
+            }
           }, function () {
             var indexPage = that.data.indexPage;
             that.setData({
@@ -300,9 +309,7 @@ Page({
               deviceListSelect: null,
               indexPage: indexPage == 1 ? 0 : indexPage,
             });
-            console.log("开启蓝牙监听1:",)
 
-            that.startBleTimer(true, false);
           }, function () {
             var indexPage = that.data.indexPage;
             that.setData({
@@ -310,10 +317,6 @@ Page({
               deviceListSelect: null,
               indexPage: indexPage == 1 ? 0 : indexPage,
             });
-            console.log("开启蓝牙监听2:",)
-
-            that.startBleTimer(true, false);
-
           });
           break;