فهرست منبع

feature: 填充当前图片

Damon 7 ماه پیش
والد
کامیت
bad631b044
2فایلهای تغییر یافته به همراه14 افزوده شده و 9 حذف شده
  1. 12 8
      pages/index/index.js
  2. 2 1
      pages/index/index.wxml

+ 12 - 8
pages/index/index.js

@@ -131,8 +131,10 @@ Page({
     // BtHelper.getInstance().initBluetoothAdapter();
     var deviceList = wx.getStorageSync("deviceList") || "";
     if (!strings.isEmpty(deviceList)) {
-      var list = JSON.parse(deviceList);
-      that.updateDeviceList(list, true);
+      try {
+        var list = JSON.parse(deviceList);
+        that.updateDeviceList(list, true);
+      } catch (e) {}
       // that.tryConnectBle()
     }
 
@@ -194,11 +196,13 @@ Page({
                 var item = dList[i];
                 if (item.connectType == 1 && tempItem.state == "online") {
                   item.name = item.devName;
-                  BtHelper.getInstance().connect(item, function (data) {
-                    if (data) {
-                      that.addConnectBlueDevice(item);
-                    }
-                  });
+                  if (that.data.deviceListIndex == null) {
+                    BtHelper.getInstance().connect(item, function (data) {
+                      if (data) {
+                        that.addConnectBlueDevice(item);
+                      }
+                    });
+                  }
                   break;
                 }
               }
@@ -965,7 +969,7 @@ Page({
       });
     }
     ///断开蓝牙连接
-    await BtHelper.getInstance().disconnect();
+    // await BtHelper.getInstance().disconnect();
     that.actionDevice(0);
   },
 

+ 2 - 1
pages/index/index.wxml

@@ -23,7 +23,8 @@
         <block wx:key="key" wx:for-item="item" wx:for-index="index" wx:for="{{deviceList}}">
           <view class="item_public" style="width: calc(100vw - {{item.state && item.state === 'online'&&deviceListIndex === index ?76:70}}rpx);border: {{item.state && item.state === 'online'&&deviceListIndex === index  ? '8rpx solid #6546A3' : item.state && item.state === 'online'?'2rpx solid #6546A3':'2rpx solid #F2F5F7'}}; margin-left: {{item.state && item.state === 'online'&&deviceListIndex === index  ?0:4}}rpx;" data-item="{{item}}" data-index="{{index}}" bind:tap="onTapItem">
 
-            <image class="item_public_image" src="./../../img/min.png" style="opacity: {{item.state && item.state === 'online' ? '1' : '0.5'}};"></image>
+            <image wx:if="{{item.connectType==3}}" class="item_public_image" src="./../../img/min.png" style="opacity: {{item.state && item.state === 'online' ? '1' : '0.5'}};"></image>
+            <image wx:else class="item_public_image" src="{{item.img}}" style="opacity: {{item.state && item.state === 'online' ? '1' : '0.5'}};" mode="aspectFit" lazy-load="true" webp="true"></image>
             <view class="item_public_right" style="margin-right: 26rpx; opacity: {{item.state && item.state === 'online' ? '1' : '0.5'}};">
               <view style="height: 190rpx; margin-top: 37rpx; margin-left: 32rpx; flex-direction: column; display: flex;">
                 <view style="flex: 1;">