update:个人训练优化

This commit is contained in:
2026-08-14 17:13:23 +08:00
parent d662db9465
commit e7f073ed7c
25 changed files with 481 additions and 344 deletions
+82 -16
View File
@@ -1,25 +1,70 @@
<script setup>
import { ref } from "vue";
import { computed, ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import Container from "@/components/Container.vue";
import Avatar from "@/components/Avatar.vue";
import BowTarget from "@/components/BowTarget.vue";
import ScorePanel from "@/components/ScorePanel.vue";
import { getPractiseAPI } from "@/apis";
import ScorePanel2 from "@/components/TrainingScorePanel.vue";
import { getPractiseDetailAPI } from "@/apis";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { user } = storeToRefs(store);
const arrows = ref([]);
const isSvip = ref(false);
const total = ref(0);
const practiseDetail = ref({});
const trainingTypeNameMap = Object.freeze({
base: "基础训练",
endurance: "耐力训练",
precision: "精准训练",
rhythm: "节奏训练",
});
const trainingType = computed(() =>
String(practiseDetail.value.trainingType || "").trim().toLowerCase()
);
const trainingTypeName = computed(
() => trainingTypeNameMap[trainingType.value] || "自由训练"
);
const targetTypeText = computed(() => {
const targetType = Number(practiseDetail.value.targetType);
return targetType > 0 ? `${targetType}CM靶` : "";
});
const difficultyText = computed(() => {
const difficultyLevel = Number(practiseDetail.value.difficultyLevel);
return Number.isInteger(difficultyLevel) && difficultyLevel > 0
? `LV${difficultyLevel}`
: "";
});
const totalRings = computed(() => {
const interpretationTotal = Number(
practiseDetail.value.interpretation?.totalRings
);
if (Number.isFinite(interpretationTotal)) return interpretationTotal;
return arrows.value.reduce(
(total, arrow) => total + (Number(arrow.ring) || 0),
0
);
});
const normalizeArrow = (arrow = {}) => ({
...arrow,
ring: Number(arrow.ring) || 0,
ringX:
arrow.ringX === true ||
Number(arrow.ringX) === 1 ||
Number(arrow.ifX) === 1,
ok: arrow.ok === true || Number(arrow.ok) === 1,
});
onLoad(async (options) => {
if (!options.id) return;
const result = await getPractiseAPI(options.id || 176);
arrows.value = result.details;
isSvip.value = result.sVip === true;
total.value = result.details.length;
const result = (await getPractiseDetailAPI(options.id)) || {};
practiseDetail.value = result;
arrows.value = Array.isArray(result.details)
? result.details.map(normalizeArrow)
: [];
isSvip.value = result.sVip === true || user.value?.sVip === true;
});
</script>
@@ -35,22 +80,29 @@ onLoad(async (options) => {
</view>
</view>
</view> -->
<view v-if="practiseDetail.id" class="practice-meta">
<text v-if="targetTypeText">{{ targetTypeText }}</text>
<text>{{ trainingTypeName }}</text>
<text v-if="difficultyText">{{ difficultyText }}</text>
</view>
<view :style="{ marginBottom: '20px' }">
<BowTarget :scores="arrows" :isSvip="isSvip" />
<BowTarget
:scores="arrows"
:isSvip="isSvip"
:enableShotEffect="false"
/>
</view>
<view class="desc">
<text>{{ arrows.length }}</text>
<text>支箭</text>
<text>{{ arrows.reduce((a, b) => a + b.ring, 0) }}</text>
<text>{{ totalRings }}</text>
<text></text>
</view>
<ScorePanel
:completeEffect="false"
:rowCount="total === 12 ? 6 : 9"
:total="total"
<ScorePanel2
:arrows="arrows"
:margin="arrows.length === 12 ? 4 : 1"
:fontSize="arrows.length === 12 ? 25 : 22"
:total="arrows.length"
:trainingType="trainingType"
recordMode
/>
</view>
</Container>
@@ -63,6 +115,20 @@ onLoad(async (options) => {
justify-content: center;
align-items: center;
}
.practice-meta {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: 26rpx;
font-weight: 600;
line-height: 40rpx;
padding: 16rpx 0;
}
.practice-meta > text + text {
margin-left: 24rpx;
}
.header {
display: flex;
justify-content: space-between;