Explorar o código

修改了蓝牙模块

智方网络_吖荣 %!s(int64=4) %!d(string=hai) anos
pai
achega
a505f791b2
Modificáronse 3 ficheiros con 5 adicións e 28 borrados
  1. 0 21
      src/components/device/device.vue
  2. 2 6
      src/pages/start/index.vue
  3. 3 1
      src/utils/bluetooth.js

+ 0 - 21
src/components/device/device.vue

@@ -279,26 +279,6 @@ export default {
               },
             });
 
-            // wx.openBluetoothAdapter({
-            //   success(res) {
-            //     console.log("初始化蓝牙模块res信息:", res);
-            //     //判断已经打开连接了
-            //     if (res["errMsg"] == "openBluetoothAdapter:ok") {
-            //       $this.startBluetoothDevicesDiscovery();
-            //     }
-            //   },
-            //   fail(err) {
-            //     if (err["errCode"] == 10001) {
-            //       Toast.fail({
-            //         message: "请打开蓝牙和位置信息!",
-            //       });
-            //     } else {
-            //       Toast.fail({
-            //         message: "蓝牙连接失败",
-            //       });
-            //     }
-            //   },
-            // });
           }
         },
       });
@@ -317,7 +297,6 @@ export default {
       $this.choose_toy_window.show = true;
 
       bluetooth.sendEnd();
-
     },
     // 选好玩具
     choose_ok() {

+ 2 - 6
src/pages/start/index.vue

@@ -254,6 +254,7 @@ export default {
     //游戏结束方法
     game_finished() {
       bluetooth.sendEnd();
+      
       $this.$emit("closePop", true);
       //取消监听低功耗蓝牙设备
       wx.offBLECharacteristicValueChange();
@@ -279,12 +280,7 @@ export default {
         forbidClick: true,
         mask: true,
         message: "正在生成报告...",
-        duration: 0,
-        onClose() {
-          for (var i = 0; i < 3; i++) {
-              bluetooth.sendEnd();
-          }
-        },
+        duration: 0
       });
     },
     to_report() {

+ 3 - 1
src/utils/bluetooth.js

@@ -258,7 +258,9 @@ export default {
         if ($this.toy_item["hex"]) {
           let $hex = $this.toy_item["hex"].substr($this.toy_item["hex"].length - 2, 2);
           if (hexStr.substr(8, 2) == $hex) {
-            console.log("已连接到"+$this.toy_item.name);
+            wx.showToast({
+              title:"已连接到"+$this.toy_item.name
+            });
             $this.change_toy_connect_status(2);
           }else if(hexStr.substr(8, 2) == "00"){
                     $this.change_toy_connect_status(3);