瀏覽代碼

feature: 加上权限认证

Damon 8 月之前
父節點
當前提交
67775e760c
共有 6 個文件被更改,包括 274 次插入298 次删除
  1. 11 1
      app.json
  2. 175 163
      devices/ble_manager.js
  3. 34 62
      devices/bt_helper.js
  4. 14 36
      pages/connectBle/connectBle.js
  5. 38 31
      pages/index/index.js
  6. 2 5
      pages/index/index.wxml

+ 11 - 1
app.json

@@ -41,9 +41,19 @@
     "getFuzzyLocation"
   ],
 
+  "deviceOrientation": "portrait",
   "permission": {
     "scope.userLocation": {
-      "desc": "你的位置信息将用于小程序蓝牙功能"
+      "desc": "你的旧版本的位置信息将用于小程序位置接口的效果展示"
+    },
+    "scope.userFuzzyLocation": {
+      "desc": "你的模糊位置信息将用于小程序位置接口的效果展示"
+    },
+    "scope.bluetooth": {
+      "desc": "需要蓝牙进行连接手柄"
+    },
+    "scope.userInfo": {
+      "desc": "需要用户同意授权隐私信息,确保蓝牙功能可用"
     }
   }
 

+ 175 - 163
devices/ble_manager.js

@@ -10,82 +10,159 @@ class bleManager {
   }
 
   // 初始化蓝牙适配器
-  async initBluetoothAdapter(callback) {
+  initBluetoothAdapter() {
     var that = this
+    wx.openBluetoothAdapter({
+      success: (res) => {
+        that.isAvailable = true;
+      },
+      fail: (err) => {
+        that.isAvailable = false;
+      }
+    });
+    wx.onBluetoothAdapterStateChange(function (res) {
+      that.isAvailable = res.available;
+    })
+  }
+
+  // 获取蓝牙权限
+  async getBluetoothPermission() {
+    var that = this;
+    console.log("gadsfasdfqwwerqewrqr");
     return new Promise((resolve, reject) => {
-      wx.openBluetoothAdapter({
-        success: (res) => {
-          that.isAvailable = true;
-          if (callback) {
-            callback(true);
-          }
-          resolve(true);
+      wx.getSetting({
+        success(res) {
+          if (res.authSetting["scope.bluetooth"]) {
+            that.hasPermission = true;
+            getApp().globalData.scopeBluetooth = true;
+            resolve(true);
+          } else if (res.authSetting["scope.bluetooth"] === undefined) {
+            that.hasPermission = false;
+            getApp().globalData.scopeBluetooth = false;
+            resolve(false);
+            wx.authorize({
+              scope: "scope.bluetooth",
+              complete() {
+                that.getBluetoothPermission()
+              }
+            });
+          } else {
+            that.hasPermission = false;
+            that.globalData.scopeBluetooth = false;
+            wx.showModal({
+              title: '请打开系统蓝牙进行配网',
+              content: '如已打开蓝牙仍然弹框,请尝试重启小程序',
+              success(res) {
+                if (res.confirm) {
+                  console.log('用户点击确定')
+                  wx.openSetting({
+                    complete() {}
+                  })
+                } else if (res.cancel) {
+                  console.log('用户点击取消')
+                }
+              }
+            });
+            resolve(false);
+          };
         },
-        fail: (err) => {
-          that.isAvailable = false;
-          console.log('adapterState fail, now is', err)
-          if (callback) {
-            callback(false);
+        fail(err) {
+          resolve(false);
+        }
+      });
+    });
+  }
+
+  ///获取定位权限
+  async getLocalSetting() {
+    var that = this;
+    return new Promise((resolve, reject) => {
+      wx.getSetting({
+        success(res) {
+          if (res.authSetting["scope.userLocation"]) {
+            resolve(true);
+          } else if (res.authSetting["scope.userLocation"] === undefined) {
+            wx.authorize({
+              scope: "scope.userLocation",
+              success() {
+                resolve(that.getLocalSetting());
+              }
+            });
+          } else {
+            wx.showModal({
+              title: '请打开系统位置获取定位权限',
+              success(res) {
+                if (res.confirm) {
+                  wx.openSetting({
+                    complete() {}
+                  })
+                } else if (res.cancel) {}
+              }
+            })
+            reject(false);
           }
+        },
+        fail(err) {
           reject(false);
         }
       });
-      wx.onBluetoothAdapterStateChange(function (res) {
-        console.log('adapterState changed, now is', res)
-        // if (callback) {
-        //   callback(res.available ?? false);
-        // }
-        that.isAvailable = res.available;
-      })
     });
   }
 
   // 开始搜索蓝牙设备
-  async startScan(callBack, succeed) {
+  async startScan(callBack, boolean) {
     var that = this;
-    var open = await that.getLocalSetting();
-    if (!open) {
-      succeed(false);
-      return;
-    }
-
     if (!that.isAvailable) {
       wx.showToast({
         title: '请打开蓝牙',
         icon: 'none',
         duration: 2000
       });
-      succeed(false);
+      boolean(false);
       return;
     }
 
-    if (!that.hasPermission) {
+    var open = await that.getLocalSetting();
+    if (!open) {
       wx.showToast({
-        title: '请打开蓝牙权限',
+        title: '请打开定位权限',
         icon: 'none',
         duration: 2000
       });
-      succeed(false);
+      boolean(false);
       return;
     }
 
+    ///没有权限再获取
+    if (!that.hasPermission) {
+      var per = await that.getBluetoothPermission();
+      if (!per) {
+        wx.showToast({
+          title: '请打开蓝牙权限',
+          icon: 'none',
+          duration: 2000
+        });
+        boolean(false);
+        return;
+      }
+    }
     // services: ["ffc0", "ab00", "ffe5"],
     wx.startBluetoothDevicesDiscovery({
       allowDuplicatesKey: true,
       success: (res) => {
         if (res) {
+          console.log("gadsfasdfqwerqwerdfasdfqr==000===");
           wx.onBluetoothDeviceFound((devicesRes) => {
             for (var i = 0; i < devicesRes.devices.length; i++) {
               if (devicesRes.devices[i].name != "") {
                 if (devicesRes.devices[i].name === getApp().globalData.connectWillDevice.clientType) {
+                  console.log("gadsfasdfqwerqwerdfasdfqr=====" + devicesRes.devices[i].name);
                   callBack(devicesRes.devices[i]);
                   break;
                 }
               }
             }
           });
-        } else {
-          succeed(false);
         }
       },
       fail: (err) => {
@@ -96,21 +173,56 @@ class bleManager {
             duration: 2000
           });
         }
-        succeed(false);
+        boolean(false);
       }
     });
   }
 
+  // 停止搜索
+  stopSearch() {
+    return new Promise((resolve, reject) => {
+      wx.stopBluetoothDevicesDiscovery({
+        success: (res) => {
+          console.log('停止搜索成功:', res);
+          resolve(res);
+        },
+        fail: (err) => {
+          console.error('停止搜索失败:', err);
+          reject(new Error('停止搜索失败'));
+        }
+      });
+    });
+  }
+
   ///获取已经连接过手机的设备
-  getAllOnlineDevices(callBack) {
+  async getAllOnlineDevices(callBack) {
     var that = this;
+    if (!that.isAvailable) {
+      setTimeout(() => {
+        that.getAllOnlineDevices(callBack);
+      }, 3 * 1000);
+      return;
+    }
+
+    if (!that.hasPermission) {
+      var per = await that.getBluetoothPermission();
+      if (!per) {
+        setTimeout(() => {
+          that.getAllOnlineDevices(callBack);
+        }, 3 * 1000);
+        return;
+      }
+    }
+
+    that.getConnectedDevices();
     wx.getBluetoothDevices({
       success: (res) => {
-        if (res && res.devices.length > 0) {
+        // && res.devices.length > 0
+        if (res) {
           callBack(res.devices);
         }
         setTimeout(() => {
-          that.getAllOnlineDevices();
+          that.getAllOnlineDevices(callBack);
         }, 3 * 1000);
       },
       fail: (err) => {
@@ -121,129 +233,65 @@ class bleManager {
     });
   }
 
-  // 获取获取在蓝牙模块生效期间所有搜索到的蓝牙设备。包括经和本机处于连接状态的设备
-  getAllConnectedDevices() {
+  // 获取已连接的蓝牙设备
+  getConnectedDevices() {
     var that = this;
     if (!that.isAvailable && !that.hasPermission) {
       return [];
     }
 
     return new Promise((resolve, reject) => {
-      wx.getBluetoothDevices({
+      wx.getConnectedBluetoothDevices({
+        // services: ["FFC0", "ffc0", "FFC1", "FFC2", "ffc1", "ffc2", "AB00", "ab00", "AB01", "AB02", "FFF1", "fff1", "FFE2", "FFE5",],
+        // services: ["ab00", "ffe5", "1111", "FFC0", "FFC1", "FFF1", ],
+        // services: [],
+        // services: [
+        //     "0000ab00-0000-1000-8000-00805f9b34fb",
+        //     "0000ffc0-0000-1000-8000-00805f9b34fb",
+        //     "0000FFF0-0000-1000-8000-00805F9B34FB",
+        //     "0000FFF1-0000-1000-8000-00805F9B34FB",
+        //     "0000FFE5-0000-1000-8000-00805F9B34FB",
+        // ],
         success: (res) => {
+          console.log('已连接的蓝牙设备==11==:', newDevices);
           let newDevices = that.fiterDevice(res)
+          console.log('已连接的蓝牙设备==22==:', newDevices);
           resolve(newDevices);
         },
         fail: (err) => {
-          console.error('已扫描过的蓝牙设备失败:', err);
+          console.error('获取已连接的蓝牙设备失败:', err);
           reject([]);
         }
       });
     });
   }
 
-  // 停止搜索
-  stopScan() {
-    return new Promise((resolve, reject) => {
-      wx.stopBluetoothDevicesDiscovery({
-        success: (res) => {
-          console.log('停止搜索成功:', res);
-          resolve(res);
-        },
-        fail: (err) => {
-          console.error('停止搜索失败:', err);
-          reject(new Error('停止搜索失败'));
-        }
-      });
-    });
-  }
-
-  // 检查蓝牙权限
-  async checkBluetoothPermission(callback) {
-    // 获取蓝牙权限
-    var that = this;
-    const _app = getApp();
-    wx.getSetting({
-      success(res) {
-        if (res.authSetting["scope.bluetooth"]) {
-          _app.globalData.scopeBluetooth = true;
-          that.hasPermission = true;
-          if (callback) {
-            callback(true);
-          }
-        } else if (res.authSetting["scope.bluetooth"] === undefined) {
-          _app.globalData.scopeBluetooth = false;
-          that.hasPermission = false;
-          if (callback) {
-            callback(false);
-          }
-          wx.authorize({
-            scope: "scope.bluetooth",
-            complete() {
-              that.checkBluetoothPermission()
-            }
-          });
-        } else {
-          that.globalData.scopeBluetooth = false;
-          that.hasPermission = false;
-          if (callback) {
-            callback(false);
-          }
-          wx.showModal({
-            title: '请打开系统蓝牙进行配网',
-            content: '如已打开蓝牙仍然弹框,请尝试重启小程序',
-            success(res) {
-              if (res.confirm) {
-                console.log('用户点击确定')
-                wx.openSetting({
-                  complete() {}
-                })
-              } else if (res.cancel) {
-                console.log('用户点击取消')
-              }
-            }
-          });
-        };
-      }
-    })
-  }
-
-  closeBle() {
-    console.log('关闭蓝牙了')
-    wx.closeBluetoothAdapter();
-  }
-
-  // 获取已连接的蓝牙设备
-  getConnectedDevices() {
+  // 获取获取在蓝牙模块生效期间所有搜索到的蓝牙设备。包括已经和本机处于连接状态的设备。
+  getAllConnectedDevices() {
     var that = this;
     if (!that.isAvailable && !that.hasPermission) {
       return [];
     }
+
     return new Promise((resolve, reject) => {
-      wx.getConnectedBluetoothDevices({
-        // services: ["FFC0", "ffc0", "FFC1", "FFC2", "ffc1", "ffc2", "AB00", "ab00", "AB01", "AB02", "FFF1", "fff1", "FFE2", "FFE5",],
-        services: ["ab00", "ffe5", "1111", "FFC0", "FFC1", "FFF1", ],
-        // services: [],
-        // services: [
-        //     "0000ab00-0000-1000-8000-00805f9b34fb",
-        //     "0000ffc0-0000-1000-8000-00805f9b34fb",
-        //     "0000FFF0-0000-1000-8000-00805F9B34FB",
-        //     "0000FFF1-0000-1000-8000-00805F9B34FB",
-        //     "0000FFE5-0000-1000-8000-00805F9B34FB",
-        // ],
+      wx.getBluetoothDevices({
         success: (res) => {
           let newDevices = that.fiterDevice(res)
-          console.log('已连接的蓝牙设备:', newDevices);
           resolve(newDevices);
         },
         fail: (err) => {
-          console.error('获取已连接的蓝牙设备失败:', err);
+          console.error('已扫描过的蓝牙设备失败:', err);
           reject([]);
         }
       });
     });
   }
 
+  closeBle() {
+    console.log('关闭蓝牙了')
+    wx.closeBluetoothAdapter();
+  }
+
   // 断开与指定设备的连接
   disconnect() {
     var that = this;
@@ -303,42 +351,6 @@ class bleManager {
     });
   }
 
-  ///获取定位权限
-  async getLocalSetting() {
-    var that = this;
-    return new Promise((resolve, reject) => {
-      wx.getSetting({
-        success(res) {
-          if (res.authSetting["scope.userLocation"]) {
-            console.log("有定位权限")
-            resolve(true);
-          } else if (res.authSetting["scope.userLocation"] === undefined) {
-            wx.authorize({
-              scope: "scope.userLocation",
-              success() {
-                resolve(that.getLocalSetting());
-              }
-            });
-          } else {
-            wx.showModal({
-              title: '请打开系统位置获取定位权限',
-              success(res) {
-                if (res.confirm) {
-                  wx.openSetting({
-                    complete() {}
-                  })
-                } else if (res.cancel) {}
-              }
-            })
-            console.log("没有有定位权限")
-            reject(false);
-          }
-        },
-        fail(err) {}
-      });
-    });
-  }
-
   // 监听发现新设备的事件
   onBluetoothDeviceFound(callback) {
     var that = this;

+ 34 - 62
devices/bt_helper.js

@@ -73,35 +73,44 @@ class BtHelper {
     }, this)
   }
 
+  ///初始化蓝牙适配器
+  initBluetoothAdapter() {
+    var that = this;
+    that.bleManager.initBluetoothAdapter();
+  }
+
+  ///获取蓝牙权限
+  async getBluetoothPermission() {
+    var that = this;
+    await that.bleManager.getBluetoothPermission();
+  }
+
   ///搜索蓝牙设备
-  async search(callBack, connected) {
+  search(callBack, boolean) {
     var that = this;
     that.bleManager.startScan(
-      async function (c) {
-          callBack(c);
-        },
-        async function (c) {
-          connected(c);
-        },
+      function (c) {
+        callBack(c);
+      },
+      function (b) {
+        boolean(b);
+      }
     );
-    // console.log("gadsfadfqwerqwerqr==444====" + res);
-    ///失败
-    // if (!res) {
+  }
 
-    // }
-    // that.timer = null;
-    // that.timer = setTimeout(() => {
-    //   that.stopSearch();
-    //   if (stopCall) {
-    //     stopCall()
-    //   }
-    // }, 10000);
-    // console.log(res);
-    // return await that._helper.search();
+  ///停止搜索蓝牙设备
+  stopSearch() {
+    var that = this;
+    await that.bleManager.stopSearch();
   }
 
-  handleCommand(event, mDevice) {
+  ///获取所有在线连接过的设备
+  getAllOnlineDevices(callBack) {
+    var that = this;
+    that.bleManager.getAllOnlineDevices(callBack);
+  }
 
+  handleCommand(event, mDevice) {
     let name = event.cmdEvent;
     switch (name) {
       ///音量  设备控制手机
@@ -340,7 +349,7 @@ class BtHelper {
   async stopSearch() {
     clearTimeout(this.timer);
     this.timer = null;
-    await this.bleManager.stopScan();
+    await this.bleManager.stopSearch();
   }
 
   async _connectSuccess() {
@@ -353,7 +362,7 @@ class BtHelper {
     var that = this;
     clearTimeout(this.timer);
     this.timer = null;
-    this.bleManager.stopScan()
+    this.bleManager.stopSearch()
     var res = await this.bleManager.connectToDevice(data);
     console.log(res ? '连接成功' : '连接失败');
     // this.setData({ connectedDeviceId: deviceId });
@@ -398,6 +407,7 @@ class BtHelper {
         console.log('订阅数据:', charc.uuid);
         // 订阅的
         this.bleManager.notifyCharacteristicValueChange(charc.uuid, (res) => {
+          console.log("dfadsfqweerqewrq====" + JSON.stringify(res));
           BtParse.parseTLV(res);
         })
       }
@@ -447,44 +457,6 @@ class BtHelper {
   //     this.initBluetooth();
   //   }
 
-  async initBluetooth(callback) {
-    var that = this;
-    ///是否已打开蓝牙
-    var adpter = await that.bleManager.initBluetoothAdapter((res) => {
-      if (!res) {
-        wx.showToast({
-          title: '请开启蓝牙功能',
-          icon: 'none',
-        })
-        if (callback) {
-          callback(false, false)
-        }
-        return
-      }
-
-      ///获取蓝牙权限
-      console.log("gadsfadfqwerqwerqr==111====" + res);
-      that.bleManager.checkBluetoothPermission(function (per) {
-        if (!per) {
-          wx.showToast({
-            title: '没有蓝牙权限',
-            icon: 'none',
-          });
-          return;
-        }
-        if (callback) {
-          callback(adpter, per)
-        }
-      });
-    });
-  }
-
-  ///获取所有在线连接过的设备
-  getAllOnlineDevices(callBack) {
-    var that = this;
-    that.bleManager.getAllOnlineDevices(callBack);
-  }
-
   async getConnectedDevices() {
     var that = this;
     try {
@@ -776,7 +748,7 @@ class BtHelper {
   async closeBle() {
     var that = this;
     that.bleManager.closeBle();
-    await that.bleManager.stopScan();
+    await that.bleManager.stopSearch();
   }
 
 }

+ 14 - 36
pages/connectBle/connectBle.js

@@ -34,53 +34,31 @@ Page({
     });
     ///准备连接的设备
     app.globalData.connectWillDevice = that.data.connectDevice;
-    BtHelper.getInstance().initBluetooth(function (adapterState, hasPermission) {
-      console.log("蓝牙状态:", adapterState, hasPermission)
-      if (adapterState && hasPermission) {
-        that.startSearch();
-      } else {
-        ///搜索失败
-        that.setStatus(1);
-      }
-    })
-
-    // wx.getBluetoothDevices({
-    //   success: function (res) {
-    // res.devices
-    //     console.log('All discovered devices', JSON.stringify(res));
-    //   },
-    //   fail(err) {
-    //     console.log(err)
-    //   }
-    // })
-    // that.findAllDevice()
+    that.startSearch();
   },
 
-  async startSearch() {
+  startSearch() {
     var that = this;
-    that.setStatus(0)
+    that.setStatus(0);
+    ///搜索到对应的设备
     BtHelper.getInstance().search(
-      async function (c) {
-          console.log("gadfadfqwerqewqr==111==" + JSON.stringify(c));
-          that.setStatus(2);
-          BtHelper.getInstance().stopSearch();
-          that.data.connectDevice.deviceId = c.deviceId;
-          that.data.connectDevice.connectable = c.connectable;
-        },
-        async function (c) {
-
-        },
+      function (c) {
+        that.setStatus(2);
+        BtHelper.getInstance().stopSearch();
+        that.data.connectDevice.deviceId = c.deviceId;
+        that.data.connectDevice.connectable = c.connectable;
+      },
+      function (b) {
+        that.setStatus(1);
+      }
     );
-    // const connectedDevices = await that.getConnectedDevices()
-    // if (connectedDevices.length == 0) {
-    //   that.setStatus(1)
-    // }
   },
 
   connectToDvice() {
     toastUtil.show("开始连接设备")
     var that = this;
     //  搜索到
+    BtHelper.getInstance().stopSearch();
     BtHelper.getInstance().connect(that.data.connectDevice, function (data) {
       console.log("连接成功:", data)
       that.setStatus(data ? 3 : 4)

+ 38 - 31
pages/index/index.js

@@ -123,36 +123,42 @@ Page({
       })
     }
   },
+
   onDeviceLoad() {
     var that = this;
-    var devicelist = wx.getStorageSync("devicelist") || "";
-    if (!strings.isEmpty(devicelist)) {
-      var list = JSON.parse(devicelist);
+    BtHelper.getInstance().initBluetoothAdapter();
+
+    var deviceList = wx.getStorageSync("deviceList") || "";
+    if (!strings.isEmpty(deviceList)) {
+      var list = JSON.parse(deviceList);
       that.updateDeviceList(list, true);
-      that.tryConnectBle()
-
-      ///对比在线的蓝牙设备
-      var tempList = that.data.devicelist;
-      var isChanged = false;
-      BtHelper.getInstance().getAllOnlineDevices(function (devices) {
-        for (var i = 0; i < tempList.length; i++) {
-          var tempItem = tempList[i];
-          if (tempItem.connectType != 3) {
-            for (var j = 0; j < devices.length; j++) {
-              // "state":"online"
-              if (tempItem.deviceId === devices[j].deviceId) {
-                isChanged = true;
-                tempItem.state = "online";
-                break;
-              }
-            }
-          }
-        }
-      });
-      if (isChanged) {
-        that.updateDeviceList(list, false);
-      }
+      // that.tryConnectBle()
     }
+
+    // BtHelper.getInstance().getAllOnlineDevices(function (devices) {
+    //   ///对比在线的蓝牙设备
+    //   var isChanged = false;
+    //   var tempList = that.data.deviceList;
+    //   for (var i = 0; i < tempList.length; i++) {
+    //     var tempItem = tempList[i];
+    //     if (tempItem.connectType != 3) {
+    //       for (var j = 0; j < devices.length; j++) {
+    //         // "state":"online"
+    //         if (tempItem.deviceId === devices[j].deviceId) {
+    //           console.log("ggadsfqwerqwrqr===" + JSON.stringify(devices[j]));
+    //           isChanged = true;
+    //           tempItem.state = "online";
+    //           break;
+    //         }
+    //       }
+    //     }
+    //   }
+    //   console.log("gadfafqewrqrwerqr===fffff=" + isChanged);
+    //   if (isChanged) {
+    //     that.updateDeviceList(list, false);
+    //   }
+    // });
+
   },
 
   addNewDeviceId() {
@@ -704,7 +710,7 @@ Page({
               return id !== item.deviceId
             });
 
-            wx.setStorageSync("devicelist", JSON.stringify(deviceList));
+            wx.setStorageSync("deviceList", JSON.stringify(deviceList));
             that.setData({
               deviceList,
             });
@@ -728,7 +734,7 @@ Page({
           // 取消订阅
           app.unsubscribe(`/AIrSMArT_${that.data.deviceList[e.currentTarget.dataset.index].name.split("BLUFI_")[1]}/user/pub_response`);
 
-          wx.setStorageSync("devicelist", JSON.stringify(deviceList));
+          wx.setStorageSync("deviceList", JSON.stringify(deviceList));
           that.setData({
             deviceList,
             thisDeviceMac: null
@@ -839,7 +845,9 @@ Page({
 
   ///更新列表排序
   updateDeviceList(deviceList, isInit) {
-    if (deviceList.length == 0) return [];
+    if (deviceList.length == 0) {
+      return;
+    }
 
     var that = this;
     var finalList = [];
@@ -890,8 +898,7 @@ Page({
     finalList = finalList.concat(onNoLineWifiList);
     finalList = finalList.concat(onNoLineNoWifiList);
     // 更新缓存
-    wx.setStorageSync("devicelist", JSON.stringify(finalList));
-
+    wx.setStorageSync("deviceList", JSON.stringify(finalList));
     that.setData({
       deviceList: finalList
     });

+ 2 - 5
pages/index/index.wxml

@@ -17,16 +17,13 @@
       <image mode="heightFix" src="./../../img/add_device.png" style="width: 48rxp;height: 48rpx;"></image>
       <view style="color: white; margin-left: 8rpx; font-size: 32rpx;">添加设备</view>
     </view>
+    
     <scroll-view scroll-y="true" style="height: calc(100vh - 118rpx - 14rpx - 20rpx  - 88rpx - 64rpx - 58rpx - {{bannerList.length>0?296:0}}rpx -  {{navBarHeight}}px);margin-top: 22rpx;padding-top: 10rpx; ">
       <view wx:if="{{deviceList}}">
-        {{item.state && item.state === 'online'&&deviceListIndex === index }}
         <block wx:key="key" wx:for-item="item" wx:for-index="index" wx:for="{{deviceList}}">
-          {{item.state }}
-          {{item.state && item.state === 'online'}}
-          {{deviceListIndex }}
-          {{index }}
           {{item.state && item.state === 'online'&&deviceListIndex === index}}
           <view class="item_public" style="width: calc(100vw - 72rpx);border: {{item.state && item.state === 'online'&&deviceListIndex === index  ? '4rpx 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>
             <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;">