Files
shoot-miniprograms/src/pages/match-detail.vue

335 lines
9.4 KiB
Vue
Raw Normal View History

2025-06-08 12:52:49 +08:00
<script setup>
import { ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import Container from "@/components/Container.vue";
import BattleHeader from "@/components/BattleHeader.vue";
import Avatar from "@/components/Avatar.vue";
2025-06-24 13:18:03 +08:00
// import TeamResult from "@/components/TeamResult.vue";
// import MeleeResult from "@/components/MeleeResult.vue";
2025-06-25 01:46:04 +08:00
import PlayerScore2 from "@/components/PlayerScore2.vue";
2025-06-14 22:45:07 +08:00
import { getGameAPI } from "@/apis";
2025-06-08 12:52:49 +08:00
2025-06-14 22:45:07 +08:00
const blueTeam = ref([]);
const redTeam = ref([]);
const roundsData = ref([]);
2025-08-18 16:09:11 +08:00
const goldenRoundsData = ref([]);
2025-06-24 13:18:03 +08:00
const battleId = ref("");
2025-06-20 01:47:57 +08:00
const data = ref({
players: [],
});
2025-06-24 13:18:03 +08:00
// const show = ref(false);
2025-06-08 12:52:49 +08:00
2025-06-11 23:57:03 +08:00
onLoad(async (options) => {
if (options.id) {
2025-08-18 16:09:11 +08:00
battleId.value = options.id || "BATTLE-1755484626207409508-955";
2025-06-28 12:38:38 +08:00
const result = await getGameAPI(battleId.value);
2025-06-14 22:45:07 +08:00
data.value = result;
if (result.mode === 1) {
blueTeam.value = Object.values(result.bluePlayers || {});
redTeam.value = Object.values(result.redPlayers || {});
Object.values(result.roundsData).forEach((item) => {
2025-07-17 13:55:04 +08:00
let bluePoint = 1;
let redPoint = 1;
2025-08-15 15:25:41 +08:00
let blueTotalRings = 0;
let redTotalRings = 0;
let blueArrows = [];
let redArrows = [];
blueTeam.value.forEach((p) => {
2025-08-18 16:09:11 +08:00
if (!item[p.playerId]) return;
2025-08-15 15:25:41 +08:00
blueTotalRings += item[p.playerId].reduce((a, b) => a + b.ring, 0);
blueArrows = [...blueArrows, ...item[p.playerId]];
});
redTeam.value.forEach((p) => {
2025-08-18 16:09:11 +08:00
if (!item[p.playerId]) return;
2025-08-15 15:25:41 +08:00
redTotalRings += item[p.playerId].reduce((a, b) => a + b.ring, 0);
redArrows = [...redArrows, ...item[p.playerId]];
});
2025-07-17 13:55:04 +08:00
if (blueTotalRings > redTotalRings) {
bluePoint = 2;
redPoint = 0;
} else if (blueTotalRings < redTotalRings) {
bluePoint = 0;
redPoint = 2;
}
2025-06-14 22:45:07 +08:00
roundsData.value.push({
blue: {
2025-08-15 15:25:41 +08:00
avatars: blueTeam.value.map((p) => p.avatar),
arrows: blueArrows,
2025-07-17 13:55:04 +08:00
totalRing: blueTotalRings,
totalScore: bluePoint,
2025-06-14 22:45:07 +08:00
},
red: {
2025-08-15 15:25:41 +08:00
avatars: redTeam.value.map((p) => p.avatar),
arrows: redArrows,
2025-07-17 13:55:04 +08:00
totalRing: redTotalRings,
totalScore: redPoint,
2025-06-14 22:45:07 +08:00
},
});
});
2025-08-18 16:09:11 +08:00
result.goldenRounds.forEach((round) => {
goldenRoundsData.value.push({
blue: {
avatars: blueTeam.value.map((p) => p.avatar),
arrows: round.arrowHistory.filter((a) => a.team === 1),
},
red: {
avatars: redTeam.value.map((p) => p.avatar),
arrows: round.arrowHistory.filter((a) => a.team === 0),
},
winner: round.winner,
});
});
2025-06-14 22:45:07 +08:00
}
2025-06-11 23:57:03 +08:00
}
2025-06-08 12:52:49 +08:00
});
2025-06-24 13:18:03 +08:00
const checkBowData = () => {
if (data.value.mode === 1) {
uni.navigateTo({
url: `/pages/team-bow-data?battleId=${battleId.value}`,
});
} else if (data.value.mode === 2) {
uni.navigateTo({
url: `/pages/melee-bow-data?battleId=${battleId.value}`,
});
}
};
2025-06-08 12:52:49 +08:00
</script>
<template>
<Container title="详情">
<view class="container">
<BattleHeader
2025-06-18 02:02:09 +08:00
:winner="data.winner"
2025-06-14 22:45:07 +08:00
:blueTeam="blueTeam"
:redTeam="redTeam"
2025-06-20 01:47:57 +08:00
:players="data.players"
2025-06-08 12:52:49 +08:00
/>
2025-07-17 13:55:04 +08:00
<view
v-if="data.players && data.players.length"
class="score-header"
:style="{ border: 'none', padding: '5px 15px' }"
>
<text>大乱斗</text>
<view @click="checkBowData">
<text>查看靶纸</text>
<image src="../static/back.png" mode="widthFix" />
</view>
</view>
<PlayerScore2
v-if="data.players && data.players.length"
v-for="(player, index) in data.players"
:key="index"
:name="player.name"
:avatar="player.avatar"
:scores="player.arrowHistory"
:totalScore="player.totalScore"
:totalRing="player.totalRings"
:rank="index + 1"
/>
2025-08-18 16:09:11 +08:00
<block v-for="(round, index) in goldenRoundsData" :key="index">
2025-07-06 12:36:20 +08:00
<view class="score-header">
<text>决金箭轮环数</text>
<view @click="checkBowData">
<text>查看靶纸</text>
<image src="../static/back.png" mode="widthFix" />
</view>
2025-06-08 12:52:49 +08:00
</view>
<view class="score-row">
<view>
2025-08-15 15:25:41 +08:00
<view>
<image
v-for="(src, index) in round.blue.avatars"
:style="{
borderColor: '#64BAFF',
transform: `translateX(-${index * 15}px)`,
}"
:src="src"
:key="index"
mode="widthFix"
/>
</view>
2025-08-18 16:09:11 +08:00
<text v-for="(arrow, index) in round.blue.arrows" :key="index">
2025-06-17 21:34:41 +08:00
{{ arrow.ring }}
2025-06-14 22:45:07 +08:00
</text>
2025-06-08 12:52:49 +08:00
</view>
2025-08-18 16:09:11 +08:00
<image
v-if="round.winner === 1"
src="../static/winner-badge.png"
mode="widthFix"
/>
2025-06-08 12:52:49 +08:00
</view>
2025-08-18 16:09:11 +08:00
<view class="score-row" :style="{ marginBottom: '5px' }">
2025-06-08 12:52:49 +08:00
<view>
2025-08-15 15:25:41 +08:00
<view>
<image
2025-08-15 16:37:10 +08:00
v-for="(src, index) in round.red.avatars"
2025-08-15 15:25:41 +08:00
:style="{
borderColor: '#FF6767',
transform: `translateX(-${index * 15}px)`,
}"
:src="src"
:key="index"
mode="widthFix"
/>
</view>
2025-08-18 16:09:11 +08:00
<text v-for="(arrow, index) in round.red.arrows" :key="index">
2025-06-17 21:34:41 +08:00
{{ arrow.ring }}
2025-06-14 22:45:07 +08:00
</text>
2025-06-08 12:52:49 +08:00
</view>
2025-08-18 16:09:11 +08:00
<image
v-if="round.winner === 0"
src="../static/winner-badge.png"
mode="widthFix"
/>
2025-06-08 12:52:49 +08:00
</view>
2025-08-18 16:09:11 +08:00
</block>
<view
v-for="(round, index) in roundsData"
:key="index"
:style="{ marginBottom: '5px' }"
>
<block
v-if="
index < Object.keys(roundsData).length - goldenRoundsData.length
"
>
<view class="score-header">
<text>{{ index + 1 }}</text>
<view @click="checkBowData">
<text>查看靶纸</text>
<image src="../static/back.png" mode="widthFix" />
</view>
</view>
<view class="score-row">
<view>
<view>
<image
v-for="(src, index) in round.blue.avatars"
:style="{
borderColor: '#64BAFF',
transform: `translateX(-${index * 15}px)`,
}"
:src="src"
:key="index"
mode="widthFix"
/>
</view>
<text v-for="(arrow, index2) in round.blue.arrows" :key="index2">
{{ arrow.ring }}
</text>
</view>
<view>
<text :style="{ color: '#64BAFF' }">
{{ round.blue.totalRing }}
</text>
<text>得分 {{ round.blue.totalScore }}</text>
</view>
</view>
<view class="score-row">
<view>
<view>
<image
v-for="(src, index) in round.red.avatars"
:style="{
borderColor: '#FF6767',
transform: `translateX(-${index * 15}px)`,
}"
:src="src"
:key="index"
mode="widthFix"
/>
</view>
<text v-for="(arrow, index2) in round.red.arrows" :key="index2">
{{ arrow.ring }}
</text>
</view>
<view>
<text :style="{ color: '#FF6767' }">
{{ round.red.totalRing }}
</text>
<text>得分 {{ round.red.totalScore }}</text>
</view>
</view>
</block>
2025-06-08 12:52:49 +08:00
</view>
<view :style="{ height: '20px' }"></view>
</view>
2025-06-24 13:18:03 +08:00
<!-- <TeamResult
2025-06-14 22:45:07 +08:00
v-if="data.mode === 1"
:show="show"
:onClose="() => (show = false)"
:data="data"
/>
<MeleeResult
v-if="data.mode === 2"
:show="show"
:onClose="() => (show = false)"
:data="data"
2025-06-24 13:18:03 +08:00
/> -->
2025-06-08 12:52:49 +08:00
</Container>
</template>
<style scoped>
.container {
width: 100%;
height: 100%;
}
.score-header,
.score-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
color: #fff9;
font-size: 15px;
border-bottom: 1px solid #fff3;
}
.score-header > text:first-child {
color: #fed847;
}
.score-header > view:last-child {
display: flex;
align-items: center;
}
.score-header > view:last-child > image {
margin-left: 5px;
width: 15px;
height: 15px;
transform: rotate(180deg);
margin-top: -2px;
}
.score-row > view {
display: flex;
align-items: center;
2025-08-15 15:25:41 +08:00
font-size: 12px;
}
.score-row > view:first-child > view:first-child {
display: flex;
align-items: center;
2025-08-15 16:37:10 +08:00
width: 70px;
2025-08-15 15:25:41 +08:00
}
.score-row > view:first-child > view:first-child > image {
width: 25px;
height: 25px;
2025-08-15 16:37:10 +08:00
min-width: 25px;
min-height: 25px;
2025-08-15 15:25:41 +08:00
border: 1px solid;
border-radius: 50%;
2025-06-08 12:52:49 +08:00
}
.score-row > view:first-child > text {
color: #fff;
display: block;
2025-08-15 15:25:41 +08:00
width: 35px;
2025-06-08 12:52:49 +08:00
}
.score-row > image:last-child {
width: 40px;
}
2025-08-18 16:09:11 +08:00
.score-row > view:nth-child(2) {
2025-06-08 12:52:49 +08:00
padding-right: 5px;
}
2025-08-18 16:09:11 +08:00
.score-row > view:nth-child(2) > text:last-child {
2025-06-08 12:52:49 +08:00
margin-left: 20px;
}
</style>