Parcourir la source

调整游戏中能登陆同一个账号的bug

yerong il y a 4 ans
Parent
commit
99a7b96569
3 fichiers modifiés avec 32 ajouts et 3 suppressions
  1. 24 2
      src/pages/start/index.vue
  2. 4 1
      src/utils/bluetooth.js
  3. 4 0
      src/utils/user.js

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

@@ -124,6 +124,7 @@
 import mpvueEcharts from 'mpvue-echarts'
 import echarts from '../../../static/echarts.min';
 import util, {formatSeconds} from '../../utils/index'
+import userjs from '../../utils/user'
 import bluetooth from "../../utils/bluetooth";
 import game_store from "@/store/game";
 import Toast from '../../../static/vant/toast/toast';
@@ -341,7 +342,7 @@ export default {
       }
       $this.timeData = $datetime
       $this.played_time += 1
-      if ($this.played_time % 60 == 0){
+      if ($this.played_time % 60 == 0) {
         $this.post_data()
       }
     },
@@ -361,6 +362,27 @@ export default {
           $this.attList = []
           $this.medList = []
         } else {
+          bluetooth.shutdownSendControl($this._deviceId, $this._serviceId, $this._characteristicId)
+          //停止控制游戏
+          const countDown = $this.$mp.page.selectComponent('.control-count-down');
+          countDown.pause();
+          //取消监听低功耗蓝牙设备
+          wx.offBLECharacteristicValueChange()
+          Toast.success('已成功断开')
+          //设置游戏状态为 停止游戏
+          game_store.setters.setGameStatus(3)
+          //游戏结束重置游戏时间
+          wx.removeStorageSync('play_time')
+          wx.removeStorageSync('hide_time')
+          //游戏结束重置游戏模式
+          game_store.setters.setMode(0)
+          //删除游戏得id
+          game_store.setters.removeToyHex()
+          //关闭游戏常亮
+          wx.setKeepScreenOn({
+            keepScreenOn: false
+          })
+          userjs.do_logout($this)
         }
       })
     },
@@ -436,7 +458,7 @@ export default {
       let $played_time = $this.played_time = game_store.getters.getPlayedTime() ? game_store.getters.getPlayedTime() : 0
 
       //判断可玩时长超出了时间 就直接结束游戏
-      if ($played_time>=($play_time * 1000)) {
+      if ($played_time >= ($play_time * 1000)) {
         $this.game_finished()
       }
 

+ 4 - 1
src/utils/bluetooth.js

@@ -600,12 +600,15 @@ export default {
     wx.onBLECharacteristicValueChange(
       (characteristic) => {
         let hexStr = that.ab2hex(characteristic.value)
-
+        console.log(hexStr)
         if (hexStr.substr(0, 6) == '555520') {
           //当s1为 00时 数据有效
           let $s1 = hexStr.substr(8, 2)
           // console.log("监听脑环是否带正:", $s1 == '00')
+
           $this.device_bg = ($s1 == '00')
+          console.log($s1)
+          console.log(parseInt('0x'+$s1))
         }
 
         //  监听脑环电量

+ 4 - 0
src/utils/user.js

@@ -54,3 +54,7 @@ function do_logout($this) {
     }
   })
 }
+
+export default {
+  do_logout
+}