浏览代码

feature: 处理在线蓝牙点击真连接

Damon 8 月之前
父节点
当前提交
2743d9118b
共有 2 个文件被更改,包括 10 次插入10 次删除
  1. 2 3
      pages/connectBle/connectBle.js
  2. 8 7
      pages/index/index.js

+ 2 - 3
pages/connectBle/connectBle.js

@@ -63,19 +63,18 @@ Page({
 
 
   connectToDvice() {
   connectToDvice() {
     var that = this;
     var that = this;
+    console.log("gasdfadsfqwwerqweqrqr=====111==" + data);
     BtHelper.getInstance().connect(that.data.connectDevice, function (data) {
     BtHelper.getInstance().connect(that.data.connectDevice, function (data) {
       console.log("连接成功:", data)
       console.log("连接成功:", data)
       that.setStatus(data ? 3 : 4)
       that.setStatus(data ? 3 : 4)
       if (data) {
       if (data) {
-        // 蓝牙模式
         that.data.connectDevice.connectType = 1
         that.data.connectDevice.connectType = 1
-        // 在线
         that.data.connectDevice.state = 'online'
         that.data.connectDevice.state = 'online'
         var connectDevice = that.data.connectDevice;
         var connectDevice = that.data.connectDevice;
         getCurrentPages()[0].addConnectBlueDevice(connectDevice);
         getCurrentPages()[0].addConnectBlueDevice(connectDevice);
         route_util.goBackRoute(route_constant.indexRoot);
         route_util.goBackRoute(route_constant.indexRoot);
       }
       }
-    })
+    });
   },
   },
 
 
   ///连接设备按钮
   ///连接设备按钮

+ 8 - 7
pages/index/index.js

@@ -660,13 +660,14 @@ Page({
     } else if (item.state === "offline") {
     } else if (item.state === "offline") {
       console.log("去连接蓝牙")
       console.log("去连接蓝牙")
     } else {
     } else {
-      console.log("去添加蓝牙")
-      that.addConnectBlueDevice({
-        deviceId: item.deviceId,
-        name: item.devName,
-        state: item.state,
-        clientType: item.ProdModel ?? item.clientType,
-        mac: item.mac,
+      console.log("gasdfadsfqwwerqweqrqr=====00==" + JSON.stringify(item));
+      ///item
+      // {"connectType":1,"deviceId":"E4:9F:80:09:40:EC","name":"E4:9F:80:09:40:EC","state":"online","ProdModel":"MW-SR1(4G_WIFI)","devName":"猫王音响x阿基米德 SR1 妙播收音机"}
+      item.name = item.devName;
+      BtHelper.getInstance().connect(item, function (data) {
+        if (data) {
+          that.addConnectBlueDevice(item);
+        }
       });
       });
     }
     }
   },
   },