|
@@ -75,6 +75,9 @@
|
|
|
<div class="close" v-if="start" @click="getExitGame"></div>
|
|
|
<ActionConfirmWindow ref="actionConfirmRef" @confirmExit="getExitGame({ type: 1 })" @confirmStart="getStartGame">
|
|
|
</ActionConfirmWindow>
|
|
|
+ <div class="time" v-if="timerNum > 0">
|
|
|
+ <div>{{ timerNum }}</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -113,8 +116,10 @@ const data = reactive<any>({
|
|
|
start: false,//是否开始游戏
|
|
|
areaStateList: [],//各游戏就绪状态
|
|
|
resumeGame: false,//游戏结束显示继续游戏
|
|
|
+ timer: null,
|
|
|
+ timerNum: null,
|
|
|
});
|
|
|
-const { projectList, wsState, bodyposeState, deviceInfo, currentGame, currentGameArea, start, areaStateList, resumeGame } = toRefs(data);
|
|
|
+const { projectList, wsState, bodyposeState, deviceInfo, currentGame, currentGameArea, start, areaStateList, resumeGame, timer, timerNum } = toRefs(data);
|
|
|
|
|
|
/**
|
|
|
* 监听数据变化
|
|
@@ -280,6 +285,8 @@ const getExitGame = (data: any) => {
|
|
|
currentGame.value = "";
|
|
|
start.value = false;
|
|
|
resumeGame.value = false;
|
|
|
+ clearInterval(timer.value);
|
|
|
+ timer.value = null;
|
|
|
} else if (data.type == 2) {
|
|
|
//游戏结束显示下一场
|
|
|
let myIndex = areaStateList.value.findIndex((item: any) => {
|
|
@@ -295,6 +302,8 @@ const getExitGame = (data: any) => {
|
|
|
currentGame.value = "";
|
|
|
start.value = false;
|
|
|
resumeGame.value = false;
|
|
|
+ clearInterval(timer.value);
|
|
|
+ timer.value = null;
|
|
|
}).finally(() => {
|
|
|
});
|
|
|
}
|
|
@@ -307,7 +316,7 @@ const getStartGame = (data: any) => {
|
|
|
areaStateList.value = data;
|
|
|
start.value = false;
|
|
|
resumeGame.value = false;
|
|
|
- setTimeout(()=>{
|
|
|
+ setTimeout(() => {
|
|
|
start.value = true;
|
|
|
})
|
|
|
};
|
|
@@ -316,12 +325,39 @@ const getStartGame = (data: any) => {
|
|
|
* 继续游戏
|
|
|
*/
|
|
|
const getResumeGame = () => {
|
|
|
+ areaStateList.value.forEach((item: any, index: number) => {
|
|
|
+ areaStateList.value[index].gameover = false;
|
|
|
+ })
|
|
|
resumeGame.value = false;
|
|
|
- // start.value = false;
|
|
|
- actionConfirmRef.value.getOpen(currentGame.value, currentGameArea.value);
|
|
|
+
|
|
|
+ timerNum.value = 5;
|
|
|
+ speckText(timerNum.value);
|
|
|
+ timer.value = setInterval(() => {
|
|
|
+ timerNum.value--;
|
|
|
+ speckText(timerNum.value);
|
|
|
+ if (timerNum.value == 0) {
|
|
|
+ clearInterval(timer.value);
|
|
|
+ timer.value = null;
|
|
|
+ if (currentGame.value == 'game_basketball') {
|
|
|
+ basketballLeftRef.value.getResumeGame();
|
|
|
+ basketballRightRef.value.getResumeGame();
|
|
|
+ }
|
|
|
+ if (currentGame.value == 'game_football') {
|
|
|
+ footballLeftRef.value.getResumeGame();
|
|
|
+ footballRightRef.value.getResumeGame();
|
|
|
+ }
|
|
|
+ if (currentGame.value == 'game_fruit') {
|
|
|
+ fruitRef.value.getResumeGame();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+
|
|
|
+
|
|
|
};
|
|
|
|
|
|
onBeforeMount(async () => {
|
|
|
+ //初始化语音
|
|
|
+ initSpeech();
|
|
|
getInit();
|
|
|
});
|
|
|
|
|
@@ -545,6 +581,21 @@ $waiPadding: 6.51rem;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+.time {
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background: rgba(0, 0, 0, 0.5);
|
|
|
+ color: #ffffff;
|
|
|
+ font-size: 7rem;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ z-index: 998;
|
|
|
+}
|
|
|
+
|
|
|
::v-deep(.menu) {
|
|
|
.swiper-horizontal {
|
|
|
width: 100%;
|