Explorar el Código

更新扫码未打开脑环和连接别人连接过的脑环会一直出现连接状态

Luhan1997 hace 4 años
padre
commit
8070001bb0

+ 18 - 1
src/components/device/device.vue

@@ -339,7 +339,12 @@ export default {
     },
     //打开蓝牙搜索
     onBluetoothDeviceFound() {
-      console.log("打开蓝牙搜索");
+      console.log(
+        "打开蓝牙搜索 device_status",
+        $this.device_status,
+        "是否有id _deviceId",
+        $this._deviceId
+      );
       try {
         // 5秒后判断 这5秒在搜索设备,搜索到就赋值给_deviceId
         setTimeout(() => {
@@ -347,6 +352,10 @@ export default {
             wx.stopBluetoothDevicesDiscovery();
             $this.change_device_status(0);
             Toast.fail("未连接到设备");
+          } else if ($this.device_status == 1) {
+            wx.stopBluetoothDevicesDiscovery();
+            $this.change_device_status(0);
+            Toast.fail("设备未打开");
           }
         }, 5000);
         wx.onBluetoothDeviceFound((res) => {
@@ -363,6 +372,8 @@ export default {
               game_store.setters.setDeviceId(device.deviceId);
               $this._deviceId = device.deviceId;
 
+              console.log("蓝牙搜索状态 device_status", $this.device_status);
+
               $this.createBLEConnection();
             }
           });
@@ -373,6 +384,12 @@ export default {
     },
     // 停止蓝牙搜索
     stopBluetoothDevicesDiscovery() {
+      console.log(
+        "脑环被占用的情况下我能获取到吗?",
+        $this.device_status,
+        "是否有id _deviceId",
+        $this._deviceId
+      );
       wx.stopBluetoothDevicesDiscovery();
     },
     //连接低功耗蓝牙设备。

+ 25 - 14
src/components/device/unconnect.vue

@@ -1,42 +1,53 @@
 <template>
   <div>
     <van-row>
-      <van-col span="11" class="text-gray text-sm left" offset="1">
+      <van-col
+        span="11"
+        class="text-gray text-sm left"
+        offset="1"
+      >
         <view>1.打开手机蓝牙和位置信息</view>
         <view>2.长按头环侧面按钮启动头环</view>
         <view>3.点击扫码开始连接</view>
       </van-col>
 
-      <van-col span="8" offset="2">
-        <img src="https://img.shuimuai.com/lanyashuimu.png" class="connect_img"/>
+      <van-col
+        span="8"
+        offset="2"
+      >
+        <img
+          src="https://img.shuimuai.com/lanyashuimu.png"
+          class="connect_img"
+        />
       </van-col>
     </van-row>
-    <button class="cu-btn lg cu-btn-primary text-white text-center scan_button margin-tb" @click="open_scan">扫码连接智脑环
+    <button
+      class="cu-btn lg cu-btn-primary text-white text-center scan_button margin-tb"
+      @click="open_scan"
+    >扫码连接智脑环
     </button>
-    <van-toast id="van-toast"/>
+    <van-toast id="van-toast" />
 
   </div>
 </template>
 
 <script>
-
-var $this
+var $this;
 export default {
   name: "unconnect",
   data() {
-    return {}
+    return {};
   },
   methods: {
     open_scan() {
-      this.$emit('open_scan')
-    }
+      this.$emit("open_scan");
+    },
   },
   created() {
-    $this = this
+    $this = this;
   },
-  onShow() {
-  }
-}
+  onShow() {},
+};
 </script>
 
 <style scoped>

+ 3 - 3
src/pages/index/index.vue

@@ -227,9 +227,9 @@ export default {
       user_store.setters.set_token($token);
       user_store.setters.set_login(true);
       this.is_login = user_store.getters.get_login_status();
-      wx.navigateTo({
-        url: "/pages/payment/main",
-      });
+      // wx.navigateTo({
+      //   url: "/pages/payment/main",
+      // });
     }
   },
   created() {

+ 3 - 3
src/pages/start/index.vue

@@ -8,7 +8,7 @@
           offset="2"
         >
           <view class="text-sm">
-            <text class="title">游玩时间</text>
+            <text class="title">本次游玩时间</text>
           </view>
           <view class="text-lg   padding-top">
             <text class="count_down_text">{{ played_time_text }}</text>
@@ -81,7 +81,7 @@
             <text class="text-default">设备电量</text>
           </div>
         </van-col>
-        <van-col span="2">
+        <!-- <van-col span="2">
           <div class="flex flex-direction align-center justify-center">
             <view>
               <text>-{{ rssi }}dbm</text>
@@ -90,7 +90,7 @@
               <text class="text-default">信号强度</text>
             </view>
           </div>
-        </van-col>
+        </van-col> -->
       </van-row>
     </div>