Procházet zdrojové kódy

feature: 解决多个设备蓝牙切换效果不明显的问题

332777428@qq.com před 6 měsíci
rodič
revize
98fd3824f9
1 změnil soubory, kde provedl 12 přidání a 1 odebrání
  1. 12 1
      pages/index/index.js

+ 12 - 1
pages/index/index.js

@@ -556,7 +556,7 @@ Page({
 
   ///点击item
   // [{"deviceId":"BLUFI_7cdfa1fcbb24","name":"BLUFI_7cdfa1fcbb24","state":"online","ProdModel":"MW-2AX(WIFI-N)","devName":"猫王小王子OTR-X"}]
-  onTapItem(e) {
+  async onTapItem(e) {
     var that = this;
     var isLogin = that.getIsLogin();
     if (!isLogin) {
@@ -583,6 +583,17 @@ Page({
     if (index === deviceListSelect && device.state === "online") {
       route_util.jumpParam('/pages/deviceDetail/detail', JSON.stringify(device))
     } else if (device.state === "offline") {
+
+      var deviceList = that.getDeviceList();
+      var deviceListSelect = that.getDeviceListSelect();
+      if (deviceListSelect != null && deviceList.length > deviceListSelect) {
+        var currentDevice = deviceList[deviceListSelect];
+        await that.disconnect(currentDevice);
+        that.setData({
+          deviceListSelect: null,
+        });
+      }
+
       device.name = device.devName;
       BtHelper.getInstance().connect(device, function (isConnected, d) {
         if (isConnected) {