소스 검색

feature: 多个设备连接,进入唤醒界面会出现设备已断开连接的问题

Damon 7 달 전
부모
커밋
7228c8d619
3개의 변경된 파일33개의 추가작업 그리고 21개의 파일을 삭제
  1. 3 1
      pages/deviceConnect3/deviceConnect3.wxml
  2. 19 20
      pages/deviceWake/deviceWake.js
  3. 11 0
      pages/index/index.js

+ 3 - 1
pages/deviceConnect3/deviceConnect3.wxml

@@ -4,9 +4,11 @@
   <nav-bar bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{nvabarData}}'>
   </nav-bar>
   <view class="roterps">
+
     <view class="devicePic">
-      <image style="width: 320rpx; height: 240rpx;" mode="scaleToFill" src="{{imageUrl}}"></image>
+      <image mode="widthFix" src="{{imageUrl}}"></image>
     </view>
+
     <view class="lodRuter" wx:if="{{ruterStatus === 0}}">
       <text>正在连接中,请保持设备开机状态…</text>
       <progress color="#6547A3" percent="{{percent}}" show-info stroke-width="3" />

+ 19 - 20
pages/deviceWake/deviceWake.js

@@ -19,7 +19,6 @@ Page({
     alarm_id_0_time: "00:00:00",
     switch2Checked: false,
     deviceMac: null,
-    devicerStatus: false, // false 已断开连接
     alarm_id_0: {}, // 休眠
     alarm_id_1: {}, // 唤醒
     timeindex: 1,
@@ -69,11 +68,16 @@ Page({
 
   onLoad(options) {
     var that = this;
-    var clientType = options.clientType;
+
     var deviceId = options.deviceId;
-    that.data.deviceId = deviceId;
+    var clientType = options.clientType;
     var deviceMac = lexin_util.getDeviceMacId(deviceId);
+
+    that.data.deviceId = deviceId;
+    that.data.deviceMac = deviceMac;
+    that.data.clientType = clientType;
     // var deviceMac = `AIrSMArT_${deviceId.split(lexin_devices.leXin)[1]}`;
+
     deviceWakedetail({
       clientType: clientType,
       deviceMac: deviceMac,
@@ -84,12 +88,9 @@ Page({
         });
       }
     })
-    that.data.clientType = options.clientType
-    that.data.deviceMac = lexin_util.getDeviceMacId(options.deviceId);
-    // that.data.deviceMac = `AIrSMArT_${options.deviceId.split(lexin_devices.leXin)[1]}`;
     app.PubMsg({
       type: "get_dev_info",
-      DstDeviceName: that.data.deviceMac
+      DstDeviceName: deviceMac
     });
 
     // 赋值按钮回调
@@ -117,22 +118,20 @@ Page({
     if (option) {
       payloads = JSON.parse(option.payload);
     };
-    console.log(payloads)
+
     switch (type) {
       case "message_onoffline":
         if (payloads.state !== "online") {
-          wx.showToast({
-            title: '设备已断开连接',
-            icon: 'none',
-            duration: 2000
-          });
-          that.setData({
-            devicerStatus: false,
-          })
-        } else {
-          that.setData({
-            devicerStatus: true,
-          })
+          var pages = getCurrentPages();
+          var deviceId = pages[0].getCurrentDeviceId();
+          var deviceMacId = lexin_util.getDeviceMacId(deviceId);
+          if (deviceMacId == that.data.deviceMac) {
+            wx.showToast({
+              title: '设备已断开连接',
+              icon: 'none',
+              duration: 2000
+            });
+          }
         }
         break;
       case "message":

+ 11 - 0
pages/index/index.js

@@ -805,6 +805,17 @@ Page({
     return actionIndex;
   },
 
+  /// 获取当前的deviceId
+  getCurrentDeviceId() {
+    var that = this;
+    var deviceList = that.getDeviceList();
+    var deviceListSelect = that.getDeviceListSelect();
+    if (deviceListSelect === null || deviceList.length <= deviceListSelect) {
+      return "";
+    };
+    return deviceList[deviceListSelect].deviceId;
+  },
+
   ///设置设备相关信息
   setDeviceInfor(other) {
     var that = this;