2025-06-05 21:32:15 +08:00
|
|
|
|
<script setup>
|
2025-06-06 00:34:54 +08:00
|
|
|
|
import { ref, onMounted } from "vue";
|
2025-06-05 21:32:15 +08:00
|
|
|
|
import { onLoad } from "@dcloudio/uni-app";
|
2025-06-09 01:17:18 +08:00
|
|
|
|
import Avatar from "@/components/Avatar.vue";
|
2025-07-17 16:14:30 +08:00
|
|
|
|
import UserUpgrade from "@/components/UserUpgrade.vue";
|
2025-07-01 23:07:47 +08:00
|
|
|
|
import { getGameAPI, getHomeData } from "@/apis";
|
2025-07-16 15:32:49 +08:00
|
|
|
|
import { topThreeColors, getBattleResultTips } from "@/constants";
|
2025-06-08 20:59:41 +08:00
|
|
|
|
import useStore from "@/store";
|
|
|
|
|
|
import { storeToRefs } from "pinia";
|
|
|
|
|
|
const store = useStore();
|
|
|
|
|
|
const { user } = storeToRefs(store);
|
2025-07-02 15:57:58 +08:00
|
|
|
|
const { updateUser, getLvlName } = store;
|
2025-06-05 21:32:15 +08:00
|
|
|
|
|
2025-06-08 20:59:41 +08:00
|
|
|
|
const ifWin = ref(false);
|
|
|
|
|
|
const data = ref({});
|
|
|
|
|
|
const totalPoints = ref(0);
|
2025-07-16 15:32:49 +08:00
|
|
|
|
const rank = ref(0);
|
2025-07-17 16:14:30 +08:00
|
|
|
|
const showUpgrade = ref(false);
|
2025-06-05 21:32:15 +08:00
|
|
|
|
|
2025-07-15 18:14:59 +08:00
|
|
|
|
// onLoad(async (options) => {
|
|
|
|
|
|
// battleId.value = options.battleId;
|
|
|
|
|
|
// const result = await getGameAPI(
|
|
|
|
|
|
// // options.battleId || "BATTLE-1750867490990424058-718"
|
|
|
|
|
|
// options.battleId || "BATTLE-1752563964391008873-624"
|
|
|
|
|
|
// );
|
|
|
|
|
|
// data.value = result;
|
|
|
|
|
|
// if (result.mode === 1 && result.redPlayers[user.value.id]) {
|
|
|
|
|
|
// totalPoints.value = result.redPlayers[user.value.id].totalScore;
|
|
|
|
|
|
// ifWin.value = result.winner === 0;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (result.mode === 1 && result.bluePlayers[user.value.id]) {
|
|
|
|
|
|
// totalPoints.value = result.bluePlayers[user.value.id].totalScore;
|
|
|
|
|
|
// ifWin.value = result.winner === 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (result.mode === 2) {
|
|
|
|
|
|
// const mine = result.players.find((p) => p.playerId === user.value.id);
|
|
|
|
|
|
// if (mine) totalPoints.value = mine.totalScore;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
2025-06-05 21:32:15 +08:00
|
|
|
|
function exit() {
|
|
|
|
|
|
uni.navigateBack();
|
|
|
|
|
|
}
|
2025-06-18 00:35:44 +08:00
|
|
|
|
onMounted(async () => {
|
2025-07-15 18:14:59 +08:00
|
|
|
|
const battleInfo = uni.getStorageSync("last-battle");
|
2025-07-16 15:32:49 +08:00
|
|
|
|
// console.log("----battleInfo", battleInfo);
|
2025-07-15 18:14:59 +08:00
|
|
|
|
data.value = battleInfo;
|
2025-07-16 12:09:27 +08:00
|
|
|
|
const mine = battleInfo.playerStats.find((p) => p.id === user.value.id);
|
2025-07-16 15:32:49 +08:00
|
|
|
|
rank.value =
|
|
|
|
|
|
battleInfo.playerStats.findIndex((p) => p.id === user.value.id) + 1;
|
2025-07-16 12:09:27 +08:00
|
|
|
|
if (mine) {
|
2025-07-17 09:35:30 +08:00
|
|
|
|
totalPoints.value = mine.totalScore;
|
|
|
|
|
|
ifWin.value = battleInfo.mode === 1 && mine.team === battleInfo.winner;
|
2025-07-15 18:14:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
// const result = await getHomeData();
|
|
|
|
|
|
// if (result.user) updateUser(result.user);
|
2025-06-18 00:35:44 +08:00
|
|
|
|
});
|
2025-06-24 13:18:03 +08:00
|
|
|
|
|
|
|
|
|
|
const checkBowData = () => {
|
|
|
|
|
|
if (data.value.mode === 1) {
|
|
|
|
|
|
uni.navigateTo({
|
2025-07-15 18:14:59 +08:00
|
|
|
|
url: `/pages/team-bow-data?battleId=${data.value.id}`,
|
2025-06-24 13:18:03 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else if (data.value.mode === 2) {
|
|
|
|
|
|
uni.navigateTo({
|
2025-07-15 18:14:59 +08:00
|
|
|
|
url: `/pages/melee-bow-data?battleId=${data.value.id}`,
|
2025-06-24 13:18:03 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2025-06-05 21:32:15 +08:00
|
|
|
|
</script>
|
2025-06-04 16:26:07 +08:00
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<view class="container">
|
2025-06-08 20:59:41 +08:00
|
|
|
|
<image
|
|
|
|
|
|
:style="{ opacity: ifWin ? '1' : '0' }"
|
|
|
|
|
|
class="tag"
|
|
|
|
|
|
src="../static/winner-yellow.png"
|
|
|
|
|
|
mode="widthFix"
|
|
|
|
|
|
/>
|
2025-06-09 01:17:18 +08:00
|
|
|
|
<block v-if="data.mode === 1">
|
2025-06-24 13:18:03 +08:00
|
|
|
|
<view class="header-team" :style="{ marginTop: '25%' }">
|
2025-06-09 01:17:18 +08:00
|
|
|
|
<image src="../static/battle-result.png" mode="widthFix" />
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="battle-winner">
|
|
|
|
|
|
<image src="../static/shining-bg.png" mode="widthFix" />
|
|
|
|
|
|
<image src="../static/throphy.png" mode="widthFix" />
|
2025-06-26 01:27:23 +08:00
|
|
|
|
<text>{{ data.winner === 1 ? "蓝队" : "红队" }}获胜</text>
|
2025-06-09 01:17:18 +08:00
|
|
|
|
<text>强势登顶,荣耀加冕</text>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</block>
|
|
|
|
|
|
<block v-if="data.mode === 2">
|
|
|
|
|
|
<view class="header-melee">
|
|
|
|
|
|
<view />
|
|
|
|
|
|
<image src="../static/battle-result.png" mode="widthFix" />
|
|
|
|
|
|
<view />
|
|
|
|
|
|
</view>
|
2025-07-05 16:50:54 +08:00
|
|
|
|
<view
|
|
|
|
|
|
class="players"
|
|
|
|
|
|
:style="{
|
2025-07-15 18:14:59 +08:00
|
|
|
|
height: `${Math.max(data.playerStats.length > 5 ? '330' : '300')}px`,
|
2025-07-05 16:50:54 +08:00
|
|
|
|
}"
|
|
|
|
|
|
>
|
2025-06-24 13:18:03 +08:00
|
|
|
|
<view
|
2025-07-15 18:14:59 +08:00
|
|
|
|
v-for="(player, index) in data.playerStats"
|
2025-06-24 13:18:03 +08:00
|
|
|
|
:key="index"
|
|
|
|
|
|
:style="{
|
2025-07-15 18:14:59 +08:00
|
|
|
|
border: player.id === user.id ? '1px solid #B04630' : 'none',
|
2025-06-24 13:18:03 +08:00
|
|
|
|
}"
|
|
|
|
|
|
>
|
2025-06-09 01:17:18 +08:00
|
|
|
|
<image
|
|
|
|
|
|
v-if="index === 0"
|
|
|
|
|
|
class="player-bg"
|
|
|
|
|
|
src="../static/melee-player-bg1.png"
|
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<image
|
|
|
|
|
|
v-if="index === 1"
|
|
|
|
|
|
class="player-bg"
|
|
|
|
|
|
src="../static/melee-player-bg2.png"
|
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<image
|
|
|
|
|
|
v-if="index === 2"
|
|
|
|
|
|
class="player-bg"
|
|
|
|
|
|
src="../static/melee-player-bg3.png"
|
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<image
|
|
|
|
|
|
v-if="index === 0"
|
|
|
|
|
|
class="player-crown"
|
|
|
|
|
|
src="../static/champ1.png"
|
|
|
|
|
|
mode="widthFix"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<image
|
|
|
|
|
|
v-if="index === 1"
|
|
|
|
|
|
class="player-crown"
|
|
|
|
|
|
src="../static/champ2.png"
|
|
|
|
|
|
mode="widthFix"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<image
|
|
|
|
|
|
v-if="index === 2"
|
|
|
|
|
|
class="player-crown"
|
|
|
|
|
|
src="../static/champ3.png"
|
|
|
|
|
|
mode="widthFix"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<view v-if="index > 2" class="view-crown">{{ index + 1 }}</view>
|
2025-06-25 00:09:53 +08:00
|
|
|
|
<Avatar
|
|
|
|
|
|
:src="player.avatar"
|
|
|
|
|
|
:size="36"
|
|
|
|
|
|
:borderColor="topThreeColors[index] || ''"
|
|
|
|
|
|
/>
|
2025-06-09 01:17:18 +08:00
|
|
|
|
<view class="player-title">
|
2025-07-16 12:09:27 +08:00
|
|
|
|
<text class="truncate">{{ player.name }}</text>
|
2025-07-02 15:57:58 +08:00
|
|
|
|
<text>{{ getLvlName(player.totalScore) }}</text>
|
2025-06-09 01:17:18 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<text
|
|
|
|
|
|
><text :style="{ color: '#fff' }">{{ player.totalRings }}</text>
|
|
|
|
|
|
环</text
|
|
|
|
|
|
>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</block>
|
|
|
|
|
|
<view class="battle-e">
|
2025-06-04 16:26:07 +08:00
|
|
|
|
<image src="../static/row-yellow-bg.png" mode="widthFix" />
|
2025-07-01 23:07:47 +08:00
|
|
|
|
<Avatar v-if="data.mode === 1" :src="user.avatar" :size="40" />
|
2025-07-16 12:09:27 +08:00
|
|
|
|
<text v-if="data.battleMode === 1">
|
|
|
|
|
|
经验 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}
|
|
|
|
|
|
</text>
|
|
|
|
|
|
<text v-if="data.battleMode === 2">
|
|
|
|
|
|
积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}
|
|
|
|
|
|
</text>
|
2025-06-04 16:26:07 +08:00
|
|
|
|
</view>
|
2025-07-16 15:32:49 +08:00
|
|
|
|
<text class="description">
|
|
|
|
|
|
{{
|
|
|
|
|
|
getBattleResultTips(data.battleMode, data.mode, {
|
|
|
|
|
|
win: ifWin,
|
|
|
|
|
|
score: totalPoints,
|
|
|
|
|
|
rank,
|
|
|
|
|
|
})
|
|
|
|
|
|
}}
|
|
|
|
|
|
</text>
|
2025-06-09 01:17:18 +08:00
|
|
|
|
<view class="op-btn">
|
2025-06-24 13:18:03 +08:00
|
|
|
|
<view @click="checkBowData">查看靶纸</view>
|
2025-06-05 21:32:15 +08:00
|
|
|
|
<view @click="exit">退出</view>
|
2025-06-04 16:26:07 +08:00
|
|
|
|
</view>
|
2025-07-17 16:14:30 +08:00
|
|
|
|
<UserUpgrade
|
|
|
|
|
|
:show="showUpgrade"
|
|
|
|
|
|
:onClose="() => (showUpgrade = false)"
|
|
|
|
|
|
:lvl="data.lvl"
|
|
|
|
|
|
/>
|
2025-06-04 16:26:07 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.container {
|
|
|
|
|
|
width: 100vw;
|
|
|
|
|
|
height: 100vh;
|
2025-06-24 13:18:03 +08:00
|
|
|
|
background-color: #292929;
|
2025-06-04 16:26:07 +08:00
|
|
|
|
position: relative;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
align-items: center;
|
2025-06-24 13:18:03 +08:00
|
|
|
|
justify-content: flex-start;
|
2025-06-04 16:26:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
.tag {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
width: 32vw;
|
2025-06-06 00:34:54 +08:00
|
|
|
|
top: 0;
|
2025-06-04 16:26:07 +08:00
|
|
|
|
right: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
.container > view {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.header-team {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
width: 80%;
|
|
|
|
|
|
margin: 10px;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.header-team > image {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
width: 20vw;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.battle-winner {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 38%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
color: #fff9;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.battle-winner > image {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
width: 100vw;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.battle-winner > image:nth-child(2) {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
top: 6vw;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.battle-winner > text:nth-child(3) {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
font-size: 30px;
|
2025-06-24 13:18:03 +08:00
|
|
|
|
margin-bottom: 5px;
|
2025-06-04 16:26:07 +08:00
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
color: #fed847;
|
|
|
|
|
|
}
|
2025-06-24 13:18:03 +08:00
|
|
|
|
.battle-winner > text:nth-child(4) {
|
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.battle-e {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 60px;
|
2025-07-01 23:07:47 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
margin-top: 20px;
|
2025-06-04 16:26:07 +08:00
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.battle-e > image {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
width: 100vw;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.battle-e > text {
|
2025-07-01 23:07:47 +08:00
|
|
|
|
position: relative;
|
2025-06-04 16:26:07 +08:00
|
|
|
|
font-size: 30px;
|
|
|
|
|
|
color: #fff;
|
2025-07-01 23:07:47 +08:00
|
|
|
|
margin-left: 10px;
|
2025-06-04 16:26:07 +08:00
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.description {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
margin: 50px 0;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: #fed847;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.op-btn {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.op-btn > view {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
width: 36%;
|
|
|
|
|
|
margin: 0 10px;
|
|
|
|
|
|
background-color: #fed847;
|
|
|
|
|
|
border-radius: 20px;
|
|
|
|
|
|
padding: 10px 0;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.op-btn > view:last-child {
|
2025-06-04 16:26:07 +08:00
|
|
|
|
color: #fff;
|
|
|
|
|
|
background-color: #757575;
|
|
|
|
|
|
}
|
2025-06-09 01:17:18 +08:00
|
|
|
|
.header-melee {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
margin-bottom: 30px;
|
2025-06-24 13:18:03 +08:00
|
|
|
|
margin-top: 25%;
|
2025-06-09 01:17:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
.header-melee > view {
|
|
|
|
|
|
height: 1px;
|
|
|
|
|
|
background-color: #fff3;
|
|
|
|
|
|
width: 18%;
|
|
|
|
|
|
}
|
|
|
|
|
|
.header-melee > image {
|
|
|
|
|
|
width: 27%;
|
|
|
|
|
|
margin: 0 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.players {
|
|
|
|
|
|
display: flex;
|
2025-07-15 17:10:41 +08:00
|
|
|
|
flex-direction: column;
|
2025-07-05 16:50:54 +08:00
|
|
|
|
overflow: auto;
|
2025-06-09 01:17:18 +08:00
|
|
|
|
width: calc(100% - 60px);
|
2025-07-05 16:50:54 +08:00
|
|
|
|
color: #fff6;
|
2025-06-09 01:17:18 +08:00
|
|
|
|
margin: 0 30px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.players > view {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 60px;
|
|
|
|
|
|
flex: 0 0 auto;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
background-color: #ffffff1a;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2025-06-24 13:18:03 +08:00
|
|
|
|
box-sizing: border-box;
|
2025-06-09 01:17:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
.player-bg {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
.player-crown {
|
2025-06-09 12:24:01 +08:00
|
|
|
|
position: relative;
|
2025-06-09 01:17:18 +08:00
|
|
|
|
width: 27px;
|
|
|
|
|
|
margin: 0 15px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.view-crown {
|
|
|
|
|
|
width: 27px;
|
|
|
|
|
|
height: 27px;
|
|
|
|
|
|
line-height: 27px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
margin: 0 15px;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
background-color: #676767;
|
2025-06-09 12:24:01 +08:00
|
|
|
|
position: relative;
|
2025-06-09 01:17:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
.player-title {
|
2025-06-09 12:24:01 +08:00
|
|
|
|
position: relative;
|
2025-06-09 01:17:18 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
margin-left: 15px;
|
|
|
|
|
|
width: calc(100% - 160px);
|
|
|
|
|
|
}
|
|
|
|
|
|
.player-title > text:first-child {
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
margin-bottom: 3px;
|
2025-07-16 12:09:27 +08:00
|
|
|
|
width: 40vw;
|
2025-06-09 01:17:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
.player-title > text:last-child {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
}
|
2025-06-04 16:26:07 +08:00
|
|
|
|
</style>
|