Damon 7 месяцев назад
Родитель
Сommit
f4695c2293
4 измененных файлов с 36 добавлено и 24 удалено
  1. 7 6
      pages/index/index.js
  2. 5 4
      pages/index/index.wxml
  3. 1 3
      utils/lexin/connect.js
  4. 23 11
      utils/lexin/message.js

+ 7 - 6
pages/index/index.js

@@ -120,7 +120,7 @@ Page({
   // 回调
   mqttCallback(type, option) {
     // console.log("gadsfadsfadsfa==888===" + type);
-    console.log("weqrweqrwqwerqer====22==" + type);
+    // console.log("weqrweqrwqwerqer====22==" + type);
     var that = this;
     let payloads = null;
     if (option && option.payload) {
@@ -148,7 +148,7 @@ Page({
         // PlayState:  ///播放状态:0默认状态,1播放状态,2暂停状态, 3停止状态,4缓冲状态。
       case "message":
         if (payloads) {
-          var payloadType = payloadType;
+          var payloadType = payloads.type;
           var other = payloads.other;
 
           ///获取频道位置
@@ -684,13 +684,14 @@ Page({
   ///设置设备相关信息
   setDeviceInfor(other) {
     var that = this;
-    var ProdModel = other.ProdModel;
-    var Power = other.Power;
     // 接收设备当前信息
-    that.getchannelData(ProdModel);
+    that.getchannelData(other.ProdModel);
+    console.log("gasdfqwerqweqr===111==" + JSON.stringify(other));
     // 电量
+    console.log("gasdfqwerqweqr===00==" + JSON.stringify(other.Power));
+    var battery = lexin_message.getDeviceInfo(other.Power);
     that.setData({
-      battery: that._battery(Power),
+      battery: battery,
     })
     // 当前设备木有设置定时
     that.setData({

+ 5 - 4
pages/index/index.wxml

@@ -34,16 +34,17 @@
               <view style="height: 190rpx; margin-top: 37rpx; margin-left: 32rpx; flex-direction: column; display: flex;">
                 <view style="flex: 1;">
                   <view style="display: flex;">
-                    <view style="color: #333333; font-size: 28rpx; flex: 1;padding-right: 5rpx;">
+                    <view style="color: #333333; font-size: 28rpx;flex: 1;padding-right: 5rpx;">
                       {{item.devName}}
                     </view>
-
                     <image mode="heightFix" src="./../../img/add_device_arrow.png" style="width: 48rxp;height: 48rpx; opacity: {{item.state && item.state === 'online'&&deviceListSelect === index ? '1' : '0'}};"></image>
-
                   </view>
                   <view style="color: #666666; font-size: 24rpx;display: flex; flex-direction: row; align-items: center;">
                     <image mode="heightFix" src="{{item.connectType==3?'./../../images/device/wifi_black.png':'./../../images/device/blue_black.png'}}" style="width: 28rxp;height: 28rpx; padding-right: 10rpx; opacity: {{item.state && item.state === 'online' ? '1' : '0.7'}};"></image>
-                    <view> {{item.state && item.state === "online" ? (item.connectType==3?"Wif在线":"蓝牙在线") : "离线"}}</view>
+                    <view> {{item.state && item.state === "online" ? (item.connectType==3?"Wifi在线":"蓝牙在线") : "离线"}}</view>
+                    <view wx:if="{{item.ProdModel}}" style="color: #666666; font-size: 24rpx;">
+                      ({{item.ProdModel}})
+                    </view>
                   </view>
                 </view>
                 <view style="align-items: center; justify-content: center; vertical-align: middle;width: 280rpx;height: 64rpx;background-color: #F2F5F7;  border-radius: 52rpx; text-align: center; justify-content: center;  display: flex;" data-index="{{index}}" catchtap="deleteDevice">

+ 1 - 3
utils/lexin/connect.js

@@ -63,8 +63,6 @@ function _connectToDevice(resetCallback) {
     if (!strings.isEmpty(deviceList)) {
       var autoConnected = getCurrentPages()[0].getAutoConnected();
       var connectDeviceIding = getCurrentPages()[0].getConnectDeviceIding();
-
-      console.log("呃呃呃呃呃呃呃==000===" + connectDeviceIding);
       /// 还没有自动连接采用第一个
       if (!autoConnected) {
         for (var i = 0; i < deviceList.length; i++) {
@@ -80,10 +78,10 @@ function _connectToDevice(resetCallback) {
       for (var i = 0; i < deviceList.length; i++) {
         var device = deviceList[i];
         var deviceId = device.deviceId;
-        console.log("呃呃呃呃呃呃呃==111===" + deviceId + "===" + connectDeviceIding);
         if (deviceId == connectDeviceIding) {
           console.log("呃呃呃呃呃呃呃==22222===" + deviceId + "===" + connectDeviceIding);
           if (device.connectType == 3 && device.state === "online") {
+            console.log("呃呃呃呃呃呃呃==333===" + deviceId + "===" + connectDeviceIding);
             getCurrentPages()[0].actionDevice(device);
           }
           break;

Разница между файлами не показана из-за своего большого размера
+ 23 - 11
utils/lexin/message.js