练习流程修改

This commit is contained in:
kron
2026-01-07 15:12:30 +08:00
parent 1f75045db4
commit 23cd5bd835
3 changed files with 50 additions and 91 deletions

View File

@@ -11,13 +11,16 @@ import BowPower from "@/components/BowPower.vue";
import TestDistance from "@/components/TestDistance.vue";
import BubbleTip from "@/components/BubbleTip.vue";
import audioManager from "@/audioManager";
import { createPractiseAPI } from "@/apis";
import { createPractiseAPI, getPractiseAPI } from "@/apis";
import { generateCanvasImage, wxShare, debounce } from "@/util";
import { MESSAGETYPES } from "@/constants";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { user } = storeToRefs(store);
const start = ref(false);
const scores = ref([]);
const total = 36;
@@ -35,6 +38,11 @@ const onReady = async () => {
}, 300);
};
const onOver = async () => {
start.value = false;
practiseResult.value = await getPractiseAPI(practiseId.value);
};
async function onReceiveMessage(messages = []) {
messages.forEach((msg) => {
if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
@@ -46,18 +54,9 @@ async function onReceiveMessage(messages = []) {
showGuide.value = false;
}, 3000);
}
}
}
if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
if (practiseId.value && practiseId.value === msg.practice.id) {
setTimeout(() => {
start.value = false;
practiseResult.value = {
...msg.practice,
arrows: JSON.parse(msg.practice.arrows),
lvl: msg.lvl,
};
}, 1500);
if (scores.value.length === total) {
setTimeout(onOver, 1500);
}
}
}
});
@@ -106,7 +105,12 @@ onBeforeUnmount(() => {
<view>
<TestDistance v-if="!practiseId" />
<block v-if="practiseId">
<ShootProgress :start="start" :tips="`请连续射${total}支箭`" />
<ShootProgress
:tips="`请连续射${total}支箭`"
:start="start"
:total="360"
:onStop="onOver"
/>
<view class="user-row">
<Avatar :src="user.avatar" :size="35" />
<BubbleTip v-if="showGuide" type="normal2">