个人12支练习流程修改
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import { MESSAGETYPES } from "@/constants";
|
import { MESSAGETYPES } from "@/constants";
|
||||||
import { getDirectionText } from "@/util";
|
import { getDirectionText } from "@/util";
|
||||||
@@ -48,6 +48,7 @@ const currentRound = ref(props.currentRound);
|
|||||||
const currentRoundEnded = ref(false);
|
const currentRoundEnded = ref(false);
|
||||||
const ended = ref(false);
|
const ended = ref(false);
|
||||||
const halfTime = ref(false);
|
const halfTime = ref(false);
|
||||||
|
const wait = ref(0);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.tips,
|
() => props.tips,
|
||||||
@@ -108,6 +109,13 @@ watch(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const tipContent = computed(() => {
|
||||||
|
if (halfTime.value) {
|
||||||
|
return props.battleId ? "中场休息" : `中场休息(${wait.value}秒)`;
|
||||||
|
}
|
||||||
|
return props.start && remain.value === 0 ? "时间到!" : props.tips;
|
||||||
|
});
|
||||||
|
|
||||||
const updateRemain = (value) => {
|
const updateRemain = (value) => {
|
||||||
if (timer.value) clearInterval(timer.value);
|
if (timer.value) clearInterval(timer.value);
|
||||||
remain.value = Math.round(value);
|
remain.value = Math.round(value);
|
||||||
@@ -154,8 +162,21 @@ async function onReceiveMessage(messages = []) {
|
|||||||
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||||
currentRoundEnded.value = true;
|
currentRoundEnded.value = true;
|
||||||
} else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
} else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
||||||
halfTime.value = true;
|
if (props.battleId) {
|
||||||
audioManager.play("中场休息");
|
halfTime.value = true;
|
||||||
|
audioManager.play("中场休息");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (wait.value !== msg.wait) {
|
||||||
|
wait.value = msg.wait;
|
||||||
|
if (msg.wait === 20) {
|
||||||
|
halfTime.value = true;
|
||||||
|
audioManager.play("中场休息");
|
||||||
|
}
|
||||||
|
if (msg.wait === 0) {
|
||||||
|
halfTime.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
audioManager.play("比赛结束");
|
audioManager.play("比赛结束");
|
||||||
} else if (msg.constructor === MESSAGETYPES.FinalShoot) {
|
} else if (msg.constructor === MESSAGETYPES.FinalShoot) {
|
||||||
@@ -188,7 +209,7 @@ onBeforeUnmount(() => {
|
|||||||
<view class="container" :style="{ display: show ? 'block' : 'none' }">
|
<view class="container" :style="{ display: show ? 'block' : 'none' }">
|
||||||
<view>
|
<view>
|
||||||
<image src="../static/shooter.png" mode="widthFix" />
|
<image src="../static/shooter.png" mode="widthFix" />
|
||||||
<text>{{ start && remain === 0 ? "时间到!" : tips }}</text>
|
<text>{{ tipContent }}</text>
|
||||||
<button hover-class="none" @click="updateSound">
|
<button hover-class="none" @click="updateSound">
|
||||||
<image
|
<image
|
||||||
:src="`../static/sound${sound ? '' : '-off'}-yellow.png`"
|
:src="`../static/sound${sound ? '' : '-off'}-yellow.png`"
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ const practiseResult = ref({});
|
|||||||
const practiseId = ref("");
|
const practiseId = ref("");
|
||||||
const showGuide = ref(false);
|
const showGuide = ref(false);
|
||||||
const tips = ref("");
|
const tips = ref("");
|
||||||
|
const wait = ref(0);
|
||||||
|
|
||||||
const onReady = async () => {
|
const onReady = async () => {
|
||||||
const result = await createPractiseAPI(total);
|
const result = await createPractiseAPI(total);
|
||||||
@@ -54,8 +55,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
|
||||||
if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
|
|
||||||
if (practiseId.value && practiseId.value === msg.practice.id) {
|
if (practiseId.value && practiseId.value === msg.practice.id) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
start.value = false;
|
start.value = false;
|
||||||
@@ -66,6 +66,10 @@ async function onReceiveMessage(messages = []) {
|
|||||||
};
|
};
|
||||||
}, 1500);
|
}, 1500);
|
||||||
}
|
}
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
||||||
|
wait.value = msg.wait;
|
||||||
|
if (msg.wait === 20) uni.$emit("update-ramain", 0);
|
||||||
|
if (msg.wait === 0) uni.$emit("update-ramain", 60);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -122,6 +126,7 @@ onBeforeUnmount(() => {
|
|||||||
}轮`
|
}轮`
|
||||||
}`"
|
}`"
|
||||||
:start="start"
|
:start="start"
|
||||||
|
:total="60"
|
||||||
/>
|
/>
|
||||||
<view class="user-row">
|
<view class="user-row">
|
||||||
<Avatar :src="user.avatar" :size="35" />
|
<Avatar :src="user.avatar" :size="35" />
|
||||||
@@ -135,6 +140,7 @@ onBeforeUnmount(() => {
|
|||||||
:totalRound="start ? total / 4 : 0"
|
:totalRound="start ? total / 4 : 0"
|
||||||
:currentRound="currentRound"
|
:currentRound="currentRound"
|
||||||
:scores="scores"
|
:scores="scores"
|
||||||
|
:stop="wait > 0"
|
||||||
/>
|
/>
|
||||||
<ScorePanel2 :scores="scores.map((s) => s.ring)" />
|
<ScorePanel2 :scores="scores.map((s) => s.ring)" />
|
||||||
<ScoreResult
|
<ScoreResult
|
||||||
|
|||||||
@@ -105,11 +105,7 @@ onBeforeUnmount(() => {
|
|||||||
<view>
|
<view>
|
||||||
<TestDistance v-if="!practiseId" />
|
<TestDistance v-if="!practiseId" />
|
||||||
<block v-if="practiseId">
|
<block v-if="practiseId">
|
||||||
<ShootProgress
|
<ShootProgress :start="start" :tips="`请连续射${total}支箭`" />
|
||||||
:start="start"
|
|
||||||
:tips="`请连续射${total}支箭`"
|
|
||||||
:total="120"
|
|
||||||
/>
|
|
||||||
<view class="user-row">
|
<view class="user-row">
|
||||||
<Avatar :src="user.avatar" :size="35" />
|
<Avatar :src="user.avatar" :size="35" />
|
||||||
<BubbleTip v-if="showGuide" type="normal2">
|
<BubbleTip v-if="showGuide" type="normal2">
|
||||||
|
|||||||
Reference in New Issue
Block a user