Files
shoot-miniprograms/src/pages/point-book-detail.vue

234 lines
5.7 KiB
Vue
Raw Normal View History

2025-07-29 10:46:37 +08:00
<script setup>
import { ref, onMounted, onUnmounted } from "vue";
2025-08-04 17:54:59 +08:00
import { onLoad } from "@dcloudio/uni-app";
2025-07-30 09:55:15 +08:00
import Container from "@/components/Container.vue";
2025-08-05 11:51:09 +08:00
import BowTargetEdit from "@/components/BowTargetEdit.vue";
2025-07-30 09:55:15 +08:00
import ScreenHint2 from "@/components/ScreenHint2.vue";
2025-08-04 17:54:59 +08:00
import { getPointBookDetailAPI } from "@/apis";
2025-07-30 09:55:15 +08:00
const selectedIndex = ref(0);
const showTip = ref(false);
const showTip2 = ref(false);
2025-08-05 11:51:09 +08:00
const groups = ref([]);
const data = ref({});
const targetSrc = ref("");
const arrows = ref([]);
2025-07-30 09:55:15 +08:00
const openTip = (index) => {
if (index === 1) showTip.value = true;
else if (index === 2) showTip2.value = true;
};
const closeTip = () => {
showTip.value = false;
showTip2.value = false;
};
2025-08-05 11:51:09 +08:00
const onSelect = (index) => {
selectedIndex.value = index;
data.value = groups.value[index];
arrows.value = groups.value[index].list.filter((item) => item.x && item.y);
};
onLoad(async (options) => {
if (options.id) {
const result = await getPointBookDetailAPI(options.id);
const config = uni.getStorageSync("point-book-config");
config.targetOption.some((item) => {
if (item.id === result.targetType) {
targetSrc.value = item.icon;
}
});
if (result.groups) {
groups.value = result.groups;
data.value = result.groups[0];
arrows.value = result.groups[0].list.filter((item) => item.x && item.y);
}
}
});
2025-07-29 10:46:37 +08:00
</script>
<template>
2025-07-30 09:55:15 +08:00
<Container :bgType="2" bgColor="#F5F5F5" :whiteBackArrow="false" title="分析">
<view class="container">
<view class="tab-bar">
<view
2025-08-05 11:51:09 +08:00
v-for="(_, index) in groups"
2025-07-30 09:55:15 +08:00
:key="index"
2025-08-05 11:51:09 +08:00
@click="onSelect(index)"
2025-07-30 09:55:15 +08:00
>
<text
:style="{
color: selectedIndex === index ? '#FF8709' : '#333',
fontSize: selectedIndex === index ? '15px' : '13px',
letterSpacing: index !== 0 ? '2px' : '0',
}"
>{{ index === 0 ? "全部" : `${index}` }}</text
>
<image
src="../static/s-triangle.png"
mode="widthFix"
2025-08-05 15:17:19 +08:00
:style="{ bottom: selectedIndex !== index ? '0' : '-5px' }"
2025-07-30 09:55:15 +08:00
/>
</view>
</view>
<view class="detail-data">
<view>
<view
:style="{ display: 'flex', alignItems: 'center' }"
@click="() => openTip(1)"
>
<text>落点稳定性</text>
<image
src="../static/s-question-mark.png"
mode="widthFix"
class="question-mark"
/>
</view>
2025-08-05 11:51:09 +08:00
<text>{{ Number((data.stability || 0).toFixed(2)) }}</text>
2025-07-30 09:55:15 +08:00
</view>
<view>
<view>黄心率</view>
2025-08-05 11:51:09 +08:00
<text>{{ Number((data.yellowRate * 100).toFixed(2)) }}%</text>
2025-07-30 09:55:15 +08:00
</view>
<view>
<view>10环数</view>
2025-08-05 11:51:09 +08:00
<text>{{ data.tenRings }}</text>
2025-07-30 09:55:15 +08:00
</view>
<view>
<view>平均环数</view>
2025-08-05 11:51:09 +08:00
<text>{{ Number((data.averageRing || 0).toFixed(2)) }}</text>
2025-07-30 09:55:15 +08:00
</view>
<view>
<view>总环数</view>
2025-08-05 11:51:09 +08:00
<text>{{ data.userTotalRing }}/{{ data.totalRing }}</text>
2025-07-30 09:55:15 +08:00
</view>
</view>
<view class="title-bar">
<view />
<text>落点分布</text>
<button hover-class="none" @click="() => openTip(2)">
<image
src="../static/s-question-mark.png"
mode="widthFix"
class="question-mark"
/>
</button>
</view>
2025-08-05 11:51:09 +08:00
<BowTargetEdit :src="targetSrc" :arrows="arrows" />
2025-07-30 09:55:15 +08:00
<ScreenHint2 :show="showTip || showTip2" :onClose="closeTip">
<view class="tip-content">
<block v-if="showTip">
<text>落点稳定性说明</text>
<text
>通过计算每支箭与其他箭的平均距离衡一量射击的稳定性数字越小则说明射击越稳定该数据只能在用户标记落点的情况下生成</text
>
</block>
<block v-if="showTip2">
<text>落点分布说明</text>
<text>展示用户某次练习中射击的点位</text>
</block>
</view>
</ScreenHint2>
</view>
</Container>
2025-07-29 10:46:37 +08:00
</template>
2025-07-30 09:55:15 +08:00
<style scoped>
.container {
width: 100%;
}
.tab-bar {
display: flex;
width: clac(100% - 20px);
overflow-x: auto;
padding: 0 10px;
}
.tab-bar::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
.tab-bar > view {
border-radius: 10px;
background-color: #fff;
width: 24vw;
height: 13vw;
line-height: 13vw;
text-align: center;
margin: 5px;
margin-top: 0;
font-size: 14px;
flex: 0 0 auto;
position: relative;
}
.tab-bar > view > text {
transition: all 0.2s ease;
}
.tab-bar > view > image {
position: absolute;
width: 14px;
height: 4px;
left: calc(50% - 7px);
transition: all 0.3s ease;
}
.detail-data {
display: grid;
grid-template-columns: repeat(3, 1fr);
column-gap: 3vw;
margin: 10px 15px;
}
.detail-data > view {
border-radius: 10px;
background-color: #fff;
margin-bottom: 10px;
padding: 12px;
}
.detail-data > view > view {
font-size: 13px;
color: #999;
margin-bottom: 8px;
}
.question-mark {
width: 15px;
height: 15px;
margin-left: 3px;
}
.title-bar {
width: 100%;
display: flex;
align-items: center;
font-size: 13px;
color: #999;
}
.title-bar > view:first-child {
width: 5px;
height: 15px;
border-radius: 10px;
background-color: #fed847;
margin-right: 7px;
margin-left: 15px;
}
.title-bar > text {
margin-bottom: 2px;
}
.tip-content {
width: 100%;
padding: 25px;
display: flex;
flex-direction: column;
}
.tip-content > text {
width: 100%;
}
.tip-content > text:first-child {
text-align: center;
}
.tip-content > text:last-child {
font-size: 13px;
margin-top: 20px;
opacity: 0.8;
}
</style>