添加游戏结束,隐藏返回按钮
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { ref, onMounted, onUnmounted } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import { isGamingAPI, getCurrentGameAPI } from "@/apis";
|
||||
const props = defineProps({
|
||||
@@ -20,6 +20,15 @@ const onClick = async () => {
|
||||
const result = await getCurrentGameAPI();
|
||||
}
|
||||
};
|
||||
const gameOver = () => {
|
||||
show.value = false;
|
||||
};
|
||||
onMounted(() => {
|
||||
uni.$on("game-over", gameOver);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
uni.$off("game-over", gameOver);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -23,7 +23,6 @@ function createWebSocket(token, onMessage) {
|
||||
// 接收消息
|
||||
uni.onSocketMessage((res) => {
|
||||
const data = JSON.parse(res.data);
|
||||
// console.log(res);
|
||||
if (data.event === "pong" || !data.data.updates) return;
|
||||
if (onMessage) onMessage(data.data.updates);
|
||||
const msg = data.data.updates[0];
|
||||
@@ -50,6 +49,9 @@ function createWebSocket(token, onMessage) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||
uni.$emit("game-over");
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.PaySuccess) {
|
||||
console.log(1111111, msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user