Bläddra i källkod

5/28更新c端小程序(扫码连不到时候没有停止搜索)

Luhan1997 4 år sedan
förälder
incheckning
772e15d061
1 ändrade filer med 11 tillägg och 5 borttagningar
  1. 11 5
      src/components/device/device.vue

+ 11 - 5
src/components/device/device.vue

@@ -203,6 +203,7 @@ export default {
     },
     //扫描连接蓝牙
     scan_to_bluetooth() {
+      console.log("在扫码时是否存在deviceId?:", this._deviceId);
       wx.scanCode({
         onlyFromCamera: true,
         success: (res) => {
@@ -310,6 +311,7 @@ export default {
         game_store.setters.clearDeviceToy();
         $this.connect_toy = $status;
         $this.connect_show = false;
+        $this._deviceId = "";
         wx.closeBLEConnection({
           deviceId: $this._deviceId,
           success(res) {
@@ -356,9 +358,13 @@ export default {
             wx.stopBluetoothDevicesDiscovery();
             $this.change_device_status(0);
             Toast.fail("设备未连接到");
-            console.log('设备未连接到device_status的状态为:',$this.device_status)
+            // console.log(
+            //   "设备未连接到device_status的状态为:",
+            //   $this.device_status
+            // );
           }
         }, 5000);
+        // 小乌龟
         wx.onBluetoothDeviceFound((res) => {
           res.devices.forEach((device) => {
             if (!device.name && !device.localName) {
@@ -448,7 +454,7 @@ export default {
   onShow() {
     //判断是否游戏中
     let $game_status = game_store.getters.getGameStatus();
-    console.log("游戏中:"+$game_status);
+    console.log("游戏中:" + $game_status);
     if ($game_status == 3) {
       //不在游戏状态
       $this.connect_toy = 0;
@@ -461,12 +467,12 @@ export default {
       //   $this.change_device_status(0);
       // }
       // 状态为0的时候重置为0 小乌龟
-    }else if ($game_status == 0){
-      $this.connect_toy = 0 ;
+    } else if ($game_status == 0) {
+      $this.connect_toy = 0;
       $this.connect_show = false;
       $this.device_status = 0;
       bluetooth.watch_bluetooth_status($this);
-     
+
       // console.log('我是在游戏中断开,我触发了嘛~',$this.connect_toy, $this.connect_show,$this.device_status );
     }
   },