Files
shoot-miniprograms/src/components/ScoreResult.vue

272 lines
6.9 KiB
Vue
Raw Normal View History

2025-05-10 16:57:36 +08:00
<script setup>
2025-11-17 17:14:51 +08:00
import { ref, onMounted, computed } from "vue";
2025-05-10 16:57:36 +08:00
import IconButton from "@/components/IconButton.vue";
import SButton from "@/components/SButton.vue";
2025-06-19 21:03:33 +08:00
import ScreenHint from "@/components/ScreenHint.vue";
2025-06-15 15:53:57 +08:00
import BowData from "@/components/BowData.vue";
2025-07-17 16:14:30 +08:00
import UserUpgrade from "@/components/UserUpgrade.vue";
2025-07-05 19:23:38 +08:00
import { directionAdjusts } from "@/constants";
2025-07-18 22:17:17 +08:00
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { user } = storeToRefs(store);
2025-05-10 16:57:36 +08:00
const props = defineProps({
onClose: {
type: Function,
default: () => {},
},
2025-07-05 13:12:58 +08:00
total: {
type: Number,
default: 0,
},
2025-05-10 16:57:36 +08:00
rowCount: {
type: Number,
default: 0,
},
2025-05-31 14:57:25 +08:00
result: {
type: Object,
default: () => ({}),
2025-05-29 23:45:44 +08:00
},
2025-06-28 20:51:50 +08:00
tipSrc: {
type: String,
default: "",
},
2025-05-10 16:57:36 +08:00
});
const showPanel = ref(true);
const showComment = ref(false);
2025-06-15 15:53:57 +08:00
const showBowData = ref(false);
2025-07-17 16:14:30 +08:00
const showUpgrade = ref(false);
2025-07-05 19:23:38 +08:00
const totalRing = ref(0);
2025-05-10 16:57:36 +08:00
const closePanel = () => {
showPanel.value = false;
setTimeout(() => {
props.onClose();
}, 300);
};
2025-11-11 10:13:14 +08:00
function onClickShare() {
uni.$emit("share-image");
}
2025-07-05 13:12:58 +08:00
onMounted(() => {
2025-07-18 22:17:17 +08:00
if (props.result.lvl > user.value.lvl) {
2025-07-17 16:14:30 +08:00
showUpgrade.value = true;
}
2026-02-07 18:30:16 +08:00
totalRing.value = (props.result.details || []).reduce(
2025-11-17 17:14:51 +08:00
(last, next) => last + next.ring,
0
);
});
const validArrows = computed(() => {
2026-02-07 18:30:16 +08:00
return (props.result.details || []).filter(
2025-11-17 17:14:51 +08:00
(arrow) => arrow.x !== -30 && arrow.y !== -30
).length;
2025-07-05 13:12:58 +08:00
});
2025-11-17 17:14:51 +08:00
const getRing = (arrow) => {
2026-02-09 17:27:44 +08:00
if (arrow.ringX) return "X";
return arrow.ring ? arrow.ring + "环" : "-";
2025-11-17 17:14:51 +08:00
};
2025-05-10 16:57:36 +08:00
</script>
<template>
2025-07-17 16:14:30 +08:00
<view class="container">
2025-05-10 16:57:36 +08:00
<view :class="['container-header', showPanel ? 'scale-in' : 'scale-out']">
2025-06-28 20:51:50 +08:00
<image :src="tipSrc" mode="widthFix" />
2025-05-10 16:57:36 +08:00
<image src="../static/finish-frame.png" mode="widthFix" />
2025-05-29 23:45:44 +08:00
<text
2025-11-17 17:14:51 +08:00
>完成<text class="gold-text">{{ validArrows }}</text
>获得<text class="gold-text">{{ validArrows }}</text
2025-05-30 17:34:59 +08:00
>点经验</text
2025-05-29 23:45:44 +08:00
>
2025-05-10 16:57:36 +08:00
</view>
<view
class="container-content"
:style="{ transform: `translateY(${showPanel ? '0%' : '100%'})` }"
>
<view>
2025-07-05 19:23:38 +08:00
<text>本局成绩{{ totalRing }}</text>
2025-06-15 15:53:57 +08:00
<button @click="() => (showBowData = true)">
2025-05-10 16:57:36 +08:00
<text>查看靶纸</text>
<image
src="../static/enter-arrow-blue.png"
mode="widthFix"
:style="{ width: '20px' }"
/>
</button>
</view>
<view :style="{ gridTemplateColumns: `repeat(${rowCount}, 1fr)` }">
2025-07-10 19:55:30 +08:00
<view v-for="(_, index) in new Array(total).fill(0)" :key="index">
2026-02-07 18:30:16 +08:00
{{ getRing(result.details[index])
}}<text v-if="getRing(result.details[index]) !== '-'"></text>
2025-05-10 16:57:36 +08:00
</view>
</view>
<view>
2025-11-17 17:14:51 +08:00
<block v-if="validArrows === total">
2025-07-05 13:12:58 +08:00
<IconButton
name="分享"
src="../static/share.png"
2025-11-11 10:13:14 +08:00
:onClick="onClickShare"
2025-07-05 13:12:58 +08:00
/>
<IconButton
name="教练点评"
src="../static/review.png"
:onClick="() => (showComment = true)"
/>
</block>
<SButton
2025-11-17 17:14:51 +08:00
:width="validArrows === total ? '70vw' : 'calc(100vw - 20px)'"
2025-07-05 13:12:58 +08:00
:rounded="30"
:onClick="closePanel"
2025-12-26 16:16:05 +08:00
>{{ validArrows === total ? "完成" : "返回" }}</SButton
2025-07-05 13:12:58 +08:00
>
2025-05-10 16:57:36 +08:00
</view>
</view>
2025-07-05 19:23:38 +08:00
<ScreenHint
:show="showComment"
:onClose="() => (showComment = false)"
mode="tall"
>
<view class="coach-comment">
<text>
您本次练习取得了<text :style="{ color: '#fed847' }">{{
totalRing
}}</text
>环的成绩所有箭支上靶后的平均点间距为<text
:style="{ color: '#fed847' }"
2026-02-07 18:30:16 +08:00
>{{ Number((result.average_distance || 0).toFixed(2)) }}</text
2025-07-05 19:23:38 +08:00
>{{
result.spreadEvaluation === "Dispersed"
2025-12-30 14:25:20 +08:00
? "还需要持续改进哦~"
2025-07-05 19:23:38 +08:00
: "成绩优秀。"
}}
</text>
2025-12-30 14:25:20 +08:00
<view>
<image
src="https://static.shelingxingqiu.com/attachment/2025-11-26/deihtj15xjwcz3c1tx.png"
mode="widthFix"
/>
<text :style="{ marginTop: '12px' }"
>针对您本次的练习{{
result.spreadEvaluation === "Dispersed"
? "我们建议您充分练习推弓、靠位以及撒放动作一致性。"
: totalRing >= 100
? "我们建议您继续保持即可。"
: `我们建议您将设备的瞄准器${
directionAdjusts[result.adjustmentHint]
}调整`
}}</text
>
</view>
2025-07-05 19:23:38 +08:00
</view>
2025-06-19 21:03:33 +08:00
</ScreenHint>
2025-06-15 15:53:57 +08:00
<BowData
2026-02-09 17:27:44 +08:00
:total="result.details.length"
2026-02-07 18:30:16 +08:00
:arrows="result.details"
2025-06-15 15:53:57 +08:00
:show="showBowData"
:onClose="() => (showBowData = false)"
/>
2025-07-17 16:14:30 +08:00
<UserUpgrade
:show="showUpgrade"
:onClose="() => (showUpgrade = false)"
:lvl="result.lvl"
/>
2025-05-10 16:57:36 +08:00
</view>
</template>
<style scoped>
.container {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
2025-06-20 11:22:41 +08:00
background-color: rgba(0, 0, 0, 0.8);
2026-01-07 15:12:18 +08:00
z-index: 999;
2025-05-10 16:57:36 +08:00
}
.container-header {
margin-top: 20vh;
display: flex;
flex-direction: column;
align-items: center;
opacity: 0;
}
.container-header > text:last-child {
color: #fff;
text-align: center;
2025-06-19 01:55:40 +08:00
margin-top: -85px;
2025-05-10 16:57:36 +08:00
}
.container-content {
width: calc(100vw - 20px);
background-color: #fff;
position: absolute;
bottom: 0;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 15px 10px;
transition: all 0.3s ease;
transform: translateY(0);
}
.container-content > view:first-child {
display: flex;
justify-content: space-between;
align-items: center;
}
2025-06-18 21:30:54 +08:00
.container-content > view:first-child > text:first-child {
color: #000;
}
2025-05-10 16:57:36 +08:00
.container-content > view:first-child > button {
display: flex;
align-items: center;
color: #287fff;
font-size: 14px;
}
.container-content > view:nth-child(2) {
display: grid;
row-gap: 10px;
column-gap: 5px;
justify-content: flex-start;
2025-07-10 19:55:30 +08:00
margin-top: 10px;
margin-bottom: 15px;
2025-05-10 16:57:36 +08:00
}
.container-content > view:nth-child(2) > view {
background: linear-gradient(#fbfbfb, #f5f5f5);
border: 1px solid #e5e5e5;
border-radius: 5px;
text-align: center;
line-height: 27px;
color: #333333;
2025-11-14 09:46:14 +08:00
font-size: 28rpx;
2025-05-10 16:57:36 +08:00
}
.container-content > view:nth-child(2) > view > text {
2025-11-14 09:46:14 +08:00
font-size: 20rpx;
2025-05-10 16:57:36 +08:00
color: #666666;
2025-11-14 09:46:14 +08:00
margin-left: 5rpx;
2025-05-10 16:57:36 +08:00
}
.container-content > view:nth-child(3) {
width: 100%;
display: flex;
justify-content: space-around;
}
2025-05-30 17:34:59 +08:00
.gold-text {
color: #fed847;
font-size: 20px;
margin: 0 2px;
}
2025-07-05 19:23:38 +08:00
.coach-comment {
display: flex;
flex-direction: column;
font-size: 14px;
2025-12-30 14:25:20 +08:00
}
.coach-comment > view {
display: flex;
}
.coach-comment > view > image {
width: 420rpx;
height: 420rpx;
margin-right: 20rpx;
2025-07-05 19:23:38 +08:00
}
2025-05-10 16:57:36 +08:00
</style>