返回游戏流程完善
This commit is contained in:
@@ -303,5 +303,7 @@ const simulShoot2 = async () => {
|
||||
height: 60px;
|
||||
left: calc(50% - 100px);
|
||||
top: calc(50% - 30px);
|
||||
z-index: 99;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -67,7 +67,7 @@ const getContentHeight = () => {
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 10;
|
||||
z-index: 999;
|
||||
}
|
||||
.container > view:first-child {
|
||||
display: flex;
|
||||
|
||||
@@ -89,7 +89,7 @@ watch(
|
||||
);
|
||||
|
||||
watch(
|
||||
() => [props.seq, props.total],
|
||||
() => [props.seq],
|
||||
() => {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
remain.value = props.total;
|
||||
|
||||
@@ -1,48 +1,35 @@
|
||||
<script setup>
|
||||
import { ref, watch } from "vue";
|
||||
import { ref, watch, onMounted, onUnmounted } from "vue";
|
||||
const props = defineProps({
|
||||
seq: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
countdown: {
|
||||
type: Number,
|
||||
default: 15,
|
||||
},
|
||||
callBack: {
|
||||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
const show = ref(false);
|
||||
const count = ref(0);
|
||||
const count = ref(props.countdown);
|
||||
const timer = ref(null);
|
||||
watch(
|
||||
() => props.seq,
|
||||
() => {
|
||||
if (props.seq > 0) {
|
||||
if (show.value) return;
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
count.value = props.countdown;
|
||||
show.value = true;
|
||||
timer.value = setInterval(() => {
|
||||
if (count.value === 0) {
|
||||
show.value = false;
|
||||
clearInterval(timer.value);
|
||||
props.callBack();
|
||||
} else {
|
||||
count.value -= 1;
|
||||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
show.value = false;
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
);
|
||||
const updateTimer = (value) => {
|
||||
count.value = Math.round(value);
|
||||
};
|
||||
onMounted(() => {
|
||||
setTimeout(() => {
|
||||
show.value = true;
|
||||
timer.value = setInterval(() => {
|
||||
if (count.value === 0) {
|
||||
show.value = false;
|
||||
clearInterval(timer.value);
|
||||
} else {
|
||||
count.value -= 1;
|
||||
}
|
||||
}, 1000);
|
||||
}, 300);
|
||||
uni.$on("update-timer", updateTimer);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
uni.$off("update-timer", updateTimer);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user