|
@@ -291,6 +291,25 @@ export default {
|
|
|
$this.executed = true
|
|
|
}
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ let game_status = game_store.getters.getGameStatus()*1;
|
|
|
+ if (game_status === 1) {
|
|
|
+ $this.is_end = false;
|
|
|
+ $this.end_loading = false;
|
|
|
+ $this.total_time = game_store.getters.getOverPlayTime();
|
|
|
+ // 筛选模式
|
|
|
+ $this.mode = game_store.getters.getMode() * 1;
|
|
|
+ // 可玩时间 (剩余时长)
|
|
|
+ $this.play_time = game_store.getters.getPlayTime();
|
|
|
+ // 开始游戏
|
|
|
+ $this.startTheGame();
|
|
|
+ // 打开蓝牙监听
|
|
|
+ $this.$connection.watchBLEstatus($this);
|
|
|
+ }
|
|
|
+ if (game_status === 3) {
|
|
|
+ $this.endTheGame();
|
|
|
+ }
|
|
|
+ },
|
|
|
// 加载完成后、后台切到前台或重新进入页面时触发
|
|
|
onShow() {
|
|
|
game_store.setters.setHideStatus(false);
|
|
@@ -318,25 +337,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- mounted() {
|
|
|
- let game_status = game_store.getters.getGameStatus()*1;
|
|
|
- if (game_status === 1) {
|
|
|
- $this.is_end = false;
|
|
|
- $this.end_loading = false;
|
|
|
- $this.total_time = game_store.getters.getOverPlayTime();
|
|
|
- // 筛选模式
|
|
|
- $this.mode = game_store.getters.getMode() * 1;
|
|
|
- // 可玩时间 (剩余时长)
|
|
|
- $this.play_time = game_store.getters.getPlayTime();
|
|
|
- // 开始游戏
|
|
|
- $this.startTheGame();
|
|
|
- // 打开蓝牙监听
|
|
|
- $this.$connection.watchBLEstatus($this);
|
|
|
- }
|
|
|
- if (game_status === 3) {
|
|
|
- $this.endTheGame();
|
|
|
- }
|
|
|
- },
|
|
|
// // 页面从前台切换到后台或者去别的页面时候触发的
|
|
|
// onHide() {
|
|
|
// game_store.setters.setHideStatus(true);
|
|
@@ -369,7 +369,7 @@ export default {
|
|
|
// 四舍五入取整
|
|
|
game_store.setters.setHideTime(Math.round(new Date() / 1000));
|
|
|
}
|
|
|
- clearInterval($timeout);
|
|
|
+ // clearInterval($timeout);
|
|
|
},
|
|
|
methods: {
|
|
|
/**
|
|
@@ -491,11 +491,14 @@ export default {
|
|
|
countdownInterval(){
|
|
|
clearInterval($timeout)
|
|
|
$timeout = setInterval(() => {
|
|
|
- if ($this.play_time > 0) {
|
|
|
+ //判断是否游戏中
|
|
|
+ let game_status = game_store.getters.getGameStatus()*1;
|
|
|
+ if (game_status === 2 && $this.play_time > 0) {
|
|
|
// 自定义定时器
|
|
|
$this.play_time -= 1;
|
|
|
game_store.setters.setPlayedTime($this.total_time-$this.play_time);
|
|
|
$this.countdown_text = formatPlaySeconds($this.play_time);
|
|
|
+ console.log("%c游戏倒计时", "color:red;", $this.countdown_text);
|
|
|
} else {
|
|
|
clearInterval($timeout);
|
|
|
$this.endTheGame();
|