2025-05-08 22:05:53 +08:00
|
|
|
|
<script setup>
|
2025-06-05 21:32:15 +08:00
|
|
|
|
import { ref, onMounted, onUnmounted } from "vue";
|
2025-05-08 22:05:53 +08:00
|
|
|
|
import AppBackground from "@/components/AppBackground.vue";
|
|
|
|
|
|
import Header from "@/components/Header.vue";
|
2025-05-10 16:57:36 +08:00
|
|
|
|
import ShootProgress from "@/components/ShootProgress.vue";
|
|
|
|
|
|
import BowTarget from "@/components/BowTarget.vue";
|
|
|
|
|
|
import ScorePanel from "@/components/ScorePanel.vue";
|
|
|
|
|
|
import ScoreResult from "@/components/ScoreResult.vue";
|
2025-05-29 23:56:42 +08:00
|
|
|
|
import SButton from "@/components/SButton.vue";
|
|
|
|
|
|
import { createPractiseAPI } from "@/apis";
|
|
|
|
|
|
import { MESSAGETYPES } from "@/constants";
|
|
|
|
|
|
const start = ref(false);
|
2025-05-10 16:57:36 +08:00
|
|
|
|
const showScore = ref(false);
|
2025-05-29 23:56:42 +08:00
|
|
|
|
const scores = ref([]);
|
|
|
|
|
|
const total = 36;
|
2025-05-31 14:57:25 +08:00
|
|
|
|
const practiseResult = ref({});
|
|
|
|
|
|
const power = ref(0);
|
2025-05-10 16:57:36 +08:00
|
|
|
|
|
2025-05-29 23:56:42 +08:00
|
|
|
|
const onReady = async () => {
|
2025-06-05 21:32:15 +08:00
|
|
|
|
await createPractiseAPI(total);
|
2025-05-29 23:56:42 +08:00
|
|
|
|
start.value = true;
|
2025-06-05 21:32:15 +08:00
|
|
|
|
};
|
2025-05-29 23:56:42 +08:00
|
|
|
|
|
2025-06-05 21:32:15 +08:00
|
|
|
|
async function onReceiveMessage(content) {
|
|
|
|
|
|
const messages = JSON.parse(content).data.updates || [];
|
|
|
|
|
|
messages.forEach((msg) => {
|
|
|
|
|
|
if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
|
|
|
|
|
scores.value.push(msg.target);
|
|
|
|
|
|
if (scores.value.length === total) {
|
|
|
|
|
|
showScore.value = true;
|
2025-05-31 14:57:25 +08:00
|
|
|
|
}
|
2025-06-05 21:32:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
|
|
|
|
|
|
practiseResult.value = {
|
|
|
|
|
|
...msg.practice,
|
|
|
|
|
|
arrows: JSON.parse(msg.practice.arrows),
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2025-05-29 23:56:42 +08:00
|
|
|
|
});
|
2025-06-05 21:32:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
uni.$on("socket-inbox", onReceiveMessage);
|
|
|
|
|
|
});
|
2025-05-29 23:56:42 +08:00
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
2025-06-05 21:32:15 +08:00
|
|
|
|
uni.$off("socket-inbox", onReceiveMessage);
|
2025-05-29 23:56:42 +08:00
|
|
|
|
});
|
2025-05-08 22:05:53 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-05-10 16:57:36 +08:00
|
|
|
|
<view class="container">
|
2025-05-31 14:57:25 +08:00
|
|
|
|
<AppBackground :type="1" />
|
2025-05-08 22:05:53 +08:00
|
|
|
|
<Header title="个人耐力挑战" />
|
2025-05-31 14:57:25 +08:00
|
|
|
|
<ShootProgress :tips="`请连续射箭${total}支`" :total="120" />
|
2025-05-10 16:57:36 +08:00
|
|
|
|
<BowTarget
|
2025-05-29 23:56:42 +08:00
|
|
|
|
:totalRound="total"
|
|
|
|
|
|
:currentRound="scores.length + 1"
|
2025-05-10 16:57:36 +08:00
|
|
|
|
avatar="../static/avatar.png"
|
2025-05-31 14:57:25 +08:00
|
|
|
|
:power="power"
|
2025-05-29 23:56:42 +08:00
|
|
|
|
:scores="scores"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<ScorePanel
|
|
|
|
|
|
v-if="start"
|
|
|
|
|
|
:scores="scores.map((s) => s.ring)"
|
|
|
|
|
|
:total="total"
|
|
|
|
|
|
:rowCount="total / 4"
|
2025-05-10 16:57:36 +08:00
|
|
|
|
/>
|
|
|
|
|
|
<ScoreResult
|
2025-05-29 23:56:42 +08:00
|
|
|
|
:total="total"
|
2025-05-10 16:57:36 +08:00
|
|
|
|
:rowCount="9"
|
|
|
|
|
|
:show="showScore"
|
|
|
|
|
|
:onClose="() => (showScore = false)"
|
2025-05-31 14:57:25 +08:00
|
|
|
|
:result="practiseResult"
|
2025-05-10 16:57:36 +08:00
|
|
|
|
/>
|
2025-05-29 23:56:42 +08:00
|
|
|
|
<SButton v-if="!start" :onClick="onReady">准备好了,直接开始</SButton>
|
2025-05-08 22:05:53 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
2025-05-10 16:57:36 +08:00
|
|
|
|
<style scoped>
|
|
|
|
|
|
.container {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|