Browse Source

后台断开脑机结束游戏优化

chaooo 1 năm trước cách đây
mục cha
commit
53ec8af894

+ 0 - 2
src/components/connection/brains/connecting.vue

@@ -222,8 +222,6 @@ export default {
         </text>
       </van-col>
     </van-row>
-    <van-toast id="van-toast"/>
-    <van-dialog id="van-dialog"/>
   </div>
 </template>
 

+ 0 - 2
src/components/connection/brains/scan.vue

@@ -198,8 +198,6 @@ export default {
       </van-col>
     </van-row>
     <button class="cu-btn lg cu-btn-primary text-white text-center scan_button margin-tb" @click="openScan">扫码连接脑机</button>
-    <van-toast id="van-toast"/>
-    <van-dialog id="van-dialog"/>
   </div>
 </template>
 <style scoped></style>

+ 0 - 3
src/components/connection/index.vue

@@ -237,9 +237,6 @@ export default {
         </van-popup>
       </div>
     </div>
-    <van-dialog id="van-dialog"/>
-    <van-toast id="van-toast"/>
-    <van-notify id="van-notify"/>
   </div>
 </template>
 

+ 0 - 2
src/components/connection/toys/selected.vue

@@ -249,8 +249,6 @@ export default {
       </div>
       <img src="https://img.shuimuai.com/web/boy2.png" alt="" class="connected_boy2"/>
     </van-overlay>
-    <van-toast id="van-toast" />
-
     <van-popup
       :show="start_show"
       closeable

+ 0 - 1
src/components/index/cards.vue

@@ -109,7 +109,6 @@ export default {
         <text class="text-yellow">{{ userinfo.free_time }}</text>
       </text>
     </view>
-    <van-toast id="van-toast"/>
   </div>
 </template>
 

+ 0 - 1
src/components/index/login.vue

@@ -225,7 +225,6 @@ export default {
       <span @click="changeCheck" class="checkbox" :class="{checked:protocolChecked}"></span><text @click="changeCheck" class="text-gray">已阅读并同意</text>
       <text class="text-primary" @click="protocolShow(true)">《用户隐私协议》</text>
     </view>
-    <van-toast id="van-toast"/>
     <!-- 用户协议弹窗-->
     <van-popup :show="protocol_show" @close="protocolShow(false)" position="bottom" round>
       <div class="protocol_content padding-lr">

+ 2 - 1
src/pages/index/main.json

@@ -9,6 +9,7 @@
     "van-field": "../../../static/vant/field/index",
     "van-button": "../../../static/vant/button/index",
     "van-count-down": "../../../static/vant/count-down/index",
-    "van-dialog": "../../../static/vant/dialog/index"
+    "van-dialog": "../../../static/vant/dialog/index",
+    "van-notify": "../../../static/vant/notify/index"
   }
 }

+ 18 - 26
src/utils/connection.js

@@ -470,7 +470,7 @@ export default {
             onOpened() {
               setTimeout(() => {
                 $this.endTheGame();
-                //clearInterval(control_close_intv)
+                that.clearStatus($this);
               }, 2000)
             }
           });
@@ -514,27 +514,25 @@ export default {
               that.reconnect(res.deviceId, $this)
             }
           });
-          // control_close = true
-          // connect_toy = false;
         } else {
-          //关闭脑控
-          // connect_toy = false;
-          game_store.setters.setGameStatus(0);
-          // 清空链接得设备
-          ble_store.setters.clearDeviceToy();
-          $this.connect_toy = 0;
-          //$this.connect_show = false;
-          $this.device_bg = false;
-          $this.device_status = 0;
-          // $this.device = {}
-          //$this.toy_UUID = "";
-          $this.$forceUpdate();
-          wx.closeBluetoothAdapter();
-          // version = "";
+          that.clearStatus($this);
         }
       }
     });
   },
+  /**
+   * 清除状态
+   * @param $this
+   */
+  clearStatus($this){
+    wx.closeBluetoothAdapter();
+    game_store.setters.setGameStatus(0);
+    ble_store.setters.clearDeviceToy();
+    $this.device_bg = false;
+    $this.device_status = 0;
+    $this.connect_toy = 0;
+    $this.$forceUpdate();
+  },
 
   /**
    * todo:重新连接蓝牙
@@ -571,6 +569,7 @@ export default {
         })
         if ($connect_count >= 3) {
           $this.endTheGame();
+          that.clearStatus($this);
           clearInterval($rec)
         }
         $connect_count += 1;
@@ -613,21 +612,14 @@ export default {
           Toast.success({
             message: "断开蓝牙连接成功",
           });
-          ble_store.setters.clearDeviceToy();
-          wx.closeBluetoothAdapter();
           LOG_WECHAT($code, "断开蓝牙连接成功", deviceId);
         },
         fail(err) {
           LOG_WECHAT_ERROR($code, "断开蓝牙连接"+deviceId+"失败error:", JSON.stringify(err));
         },
         complete() {
-          //$this.device = {};
-          //$this.toy_UUID = "";
-          $this.device_bg = false;
-          $this.connect_toy = 0;
-          $this.device_status = 0;
-          $this.$forceUpdate();
-          //
+          // 清除状态
+          that.clearStatus($this);
         },
       });
     },500);