初步完成返回游戏功能,待测试完善
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import AppBackground from "@/components/AppBackground.vue";
|
||||
import Header from "@/components/Header.vue";
|
||||
import ScreenHint from "@/components/ScreenHint.vue";
|
||||
import { getCurrentGameAPI } from "@/apis";
|
||||
import { debounce } from "@/util";
|
||||
defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
@@ -29,20 +31,21 @@ defineProps({
|
||||
const isIos = ref(true);
|
||||
const showHint = ref(false);
|
||||
const hintType = ref(0);
|
||||
onMounted(() => {
|
||||
const deviceInfo = uni.getDeviceInfo();
|
||||
isIos.value = deviceInfo.osName === "ios";
|
||||
});
|
||||
const showGlobalHint = (type) => {
|
||||
hintType.value = type;
|
||||
showHint.value = true;
|
||||
};
|
||||
uni.$showHint = showGlobalHint;
|
||||
|
||||
const backToGame = async () => {
|
||||
onMounted(() => {
|
||||
const deviceInfo = uni.getDeviceInfo();
|
||||
isIos.value = deviceInfo.osName === "ios";
|
||||
});
|
||||
onShow(() => {
|
||||
uni.$showHint = showGlobalHint;
|
||||
showHint.value = false;
|
||||
});
|
||||
const backToGame = debounce(async () => {
|
||||
const result = await getCurrentGameAPI();
|
||||
console.log(111, result);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -18,7 +18,7 @@ const props = defineProps({
|
||||
const getContentHeight = () => {
|
||||
if (props.mode === "tall") return "47vw";
|
||||
if (props.mode === "square") return "74vw";
|
||||
return '36vw'
|
||||
return "36vw";
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, watch, onUnmounted } from "vue";
|
||||
import { ref, watch, onMounted, onUnmounted } from "vue";
|
||||
const props = defineProps({
|
||||
start: {
|
||||
type: Boolean,
|
||||
@@ -33,11 +33,14 @@ watch(
|
||||
(newVal) => {
|
||||
if (newVal.includes("红队")) barColor.value = "#FF6060";
|
||||
if (newVal.includes("蓝队")) barColor.value = "#5FADFF";
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.seq,
|
||||
() => [props.seq, props.total],
|
||||
() => {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
remain.value = props.total;
|
||||
@@ -77,7 +80,16 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
const updateRemain = (value) => {
|
||||
remain.value = Math.floor(value);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
uni.$on("update-ramain", updateRemain);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off("update-ramain", updateRemain);
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user