射箭记录完善

This commit is contained in:
kron
2025-06-14 22:45:07 +08:00
parent aacfc17a01
commit 9a051aca20
6 changed files with 135 additions and 76 deletions

View File

@@ -30,6 +30,10 @@ const props = defineProps({
type: Array,
default: () => [],
},
blueScores: {
type: Array,
default: () => [],
},
showE: {
type: Boolean,
default: true,
@@ -88,13 +92,27 @@ function calcRealY(num) {
<image
v-for="(bow, index) in scores"
:key="index"
src="../static/hit-icon.png"
:src="
index === scores.length - 1 && !blueScores.length
? '../static/hit-icon-green.png'
: '../static/hit-icon.png'
"
:class="`hit ${index + 1 === scores.length ? 'pump-in' : ''}`"
:style="{
left: calcRealX(bow.x),
top: calcRealY(bow.y),
}"
/>
<image
v-for="(bow, index) in blueScores"
:key="index"
src="../static/hit-icon-blue.png"
:class="`hit ${index + 1 === blueScores.length ? 'pump-in' : ''}`"
:style="{
left: calcRealX(bow.x),
top: calcRealY(bow.y),
}"
/>
<image src="../static/bow-target.png" mode="widthFix" />
</view>
<view v-if="avatar" class="footer">

View File

@@ -25,7 +25,7 @@ watch(
() => props.data,
(value) => {
const mine = value.players.find((p) => p.playerId === user.value.id);
if (mine.arrowHistory) {
if (mine && mine.arrowHistory) {
scores.value = mine.arrowHistory;
}
},
@@ -47,7 +47,7 @@ watch(
<image v-if="index === 1" src="../static/champ2.png" mode="widthFix" />
<image v-if="index === 2" src="../static/champ3.png" mode="widthFix" />
<view v-if="index > 2" class="rank-view">{{ index + 1 }}</view>
<Avatar src="../static/avatar.png" :size="24" />
<Avatar :src="player.avatar" :size="24" />
<text
>积分
{{

View File

@@ -96,9 +96,7 @@ setTimeout(() => {
src="../static/review.png"
:onClick="() => (showComment = true)"
/>
<SButton width="70vw" :rounded="30" :onClick="closePanel"
>完成</SButton
>
<SButton width="70vw" :rounded="30" :onClick="closePanel">完成</SButton>
</view>
</view>
<ImageShare :show="showShare" :onClose="() => (showShare = false)" />
@@ -116,6 +114,7 @@ setTimeout(() => {
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.6);
z-index: 5;
}
.container-header {
margin-top: 20vh;

View File

@@ -18,21 +18,40 @@ const props = defineProps({
},
});
const selected = ref(0);
const scores = ref([]);
const redScores = ref([]);
const blueScores = ref([]);
const tabs = ref(["所有轮次"]);
const players = ref([]);
const onClickTab = (index) => {
selected.value = index;
scores.value = [];
redScores.value = [];
blueScores.value = [];
const { bluePlayers, redPlayers, roundsData } = props.data;
if (index === 0) {
Object.values(props.data.roundsData).forEach((round) => {
Object.values(round).forEach((arrows) => {
scores.value = [...scores.value, ...Object.values(arrows)];
Object.keys(bluePlayers).forEach((p) => {
Object.values(roundsData).forEach((round) => {
round[p].forEach((arrow) => {
blueScores.value.push(arrow);
});
});
});
Object.keys(redPlayers).forEach((p) => {
Object.values(roundsData).forEach((round) => {
round[p].forEach((arrow) => {
redScores.value.push(arrow);
});
});
});
} else {
Object.values(props.data.roundsData[index]).forEach((arrows) => {
scores.value = [...scores.value, ...Object.values(arrows)];
Object.keys(bluePlayers).forEach((p) => {
roundsData[index][p].forEach((arrow) => {
blueScores.value.push(arrow);
});
});
Object.keys(redPlayers).forEach((p) => {
roundsData[index][p].forEach((arrow) => {
redScores.value.push(arrow);
});
});
}
};
@@ -54,7 +73,8 @@ watch(
tabs.value.push(`${roundsName[key]}`);
});
onClickTab(0);
}
},
{ deep: true, immediate: true }
);
</script>
@@ -77,7 +97,7 @@ watch(
</view>
</view>
<view :style="{ width: '95%' }">
<BowTarget :scores="scores" :showE="false" />
<BowTarget :scores="redScores" :blueScores="blueScores" :showE="false" />
</view>
<view class="score-row" v-for="(player, index) in players" :key="index">
<Avatar