1v1比赛结果页UI更新

This commit is contained in:
kron
2025-08-01 15:25:51 +08:00
parent d7306db2dd
commit 18ac484844
11 changed files with 154 additions and 45 deletions

View File

@@ -234,6 +234,7 @@ export const getGameAPI = async (battleId) => {
goldenRoundRecords = [], goldenRoundRecords = [],
} = result; } = result;
const data = { const data = {
battleId,
mode: battleStats.mode, // 1.几V几 2.大乱斗 mode: battleStats.mode, // 1.几V几 2.大乱斗
gameMode: battleStats.gameMode, // 1.约战 2.排位 gameMode: battleStats.gameMode, // 1.约战 2.排位
}; };

View File

@@ -101,16 +101,22 @@ export const getBattleResultTips = (
if (mode === 1) { if (mode === 1) {
if (win) { if (win) {
const tests = [ const tests = [
"你是朋友中的佼佼者哟!", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq1fglywucyoh9zn.png",
"你成功击败好友,成为大赢家!", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgls1trzqneeh.png",
"你将好友“一举拿下”,超神无疑!", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgm4fmv0tqico.png",
// "你是朋友中的佼佼者哟!",
// "你成功击败好友,成为大赢家!",
// "你将好友“一举拿下”,超神无疑!",
]; ];
return tests[getRandomIndex(3)]; return tests[getRandomIndex(3)];
} else { } else {
const tests = [ const tests = [
"失误啦失误啦,再多来几局吧~", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmb12vjkonvzm.png",
"惜败好友,下次再战定能反超!", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmo5gpiecqqgu.png",
"友谊第一,下场胜利属于你!", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmtk8hjwqoecz.png",
// "失误啦失误啦,再多来几局吧~",
// "惜败好友,下次再战定能反超!",
// "友谊第一,下场胜利属于你!",
]; ];
return tests[getRandomIndex(3)]; return tests[getRandomIndex(3)];
} }
@@ -129,16 +135,22 @@ export const getBattleResultTips = (
if (mode === 1) { if (mode === 1) {
if (win) { if (win) {
const tests = [ const tests = [
"你已经奔跑在通向王者的路上了!", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgtb29jbdus4g.png",
"射灵星球最闪耀的前进者!", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgtbu8fzpbh3z.png",
"赞!你真是越战越勇", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgtbu8fzpbh3z.png",
// "你已经奔跑在通向王者的路上了!",
// "射灵星球最闪耀的前进者!",
// "赞!你真是越战越勇",
]; ];
return tests[getRandomIndex(3)]; return tests[getRandomIndex(3)];
} else { } else {
const tests = [ const tests = [
"失败是成功之母,儿子在等你!", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmovnd33hz5yj.png",
"人生得意须尽欢,不过此关心不甘!", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmtu558juplj9.png",
"这回一定是打开方式不对。再来!", "https://api.shelingxingqiu.com/attachment/2025-08-01/dbqq0gmuhb5aofghg4.png",
// "失败是成功之母,儿子在等你!",
// "人生得意须尽欢,不过此关心不甘!",
// "这回一定是打开方式不对。再来!",
]; ];
return tests[getRandomIndex(3)]; return tests[getRandomIndex(3)];
} }

View File

@@ -3,6 +3,9 @@
{ {
"path": "pages/index" "path": "pages/index"
}, },
{
"path": "pages/battle-result"
},
{ {
"path": "pages/match-page" "path": "pages/match-page"
}, },
@@ -75,9 +78,6 @@
{ {
"path": "pages/match-detail" "path": "pages/match-detail"
}, },
{
"path": "pages/battle-result"
},
{ {
"path": "pages/team-bow-data" "path": "pages/team-bow-data"
}, },

View File

@@ -21,23 +21,25 @@ function exit() {
} }
onLoad(async (options) => { onLoad(async (options) => {
const myId = user.value.id;
if (options.battleId) { if (options.battleId) {
const result = await getGameAPI( const result = await getGameAPI(
options.battleId || "BATTLE-1753787456813171958-86" options.battleId || "BATTLE-1753426540845671675-932"
// options.battleId || "BATTLE-1753239612271030113-788"
); );
const battleInfo = uni.getStorageSync("last-battle");
data.value = { data.value = {
...result, ...result,
id: options.battleId, redPlayers: Object.values(result.redPlayers),
bluePlayers: Object.values(result.bluePlayers),
battleMode: result.gameMode, battleMode: result.gameMode,
}; };
if (result.mode === 1 && result.redPlayers[user.value.id]) { if (result.mode === 1 && result.redPlayers[myId]) {
totalPoints.value = result.redPlayers[user.value.id].totalScore; totalPoints.value = result.redPlayers[myId].totalScore;
data.value.myTeam = result.redPlayers[myId].team;
ifWin.value = result.winner === 0; ifWin.value = result.winner === 0;
} }
if (result.mode === 1 && result.bluePlayers[user.value.id]) { if (result.mode === 1 && result.bluePlayers[myId]) {
totalPoints.value = result.bluePlayers[user.value.id].totalScore; totalPoints.value = result.bluePlayers[myId].totalScore;
data.value.myTeam = result.bluePlayers[myId].team;
ifWin.value = result.winner === 1; ifWin.value = result.winner === 1;
} }
if (result.mode === 2) { if (result.mode === 2) {
@@ -45,19 +47,27 @@ onLoad(async (options) => {
...p, ...p,
id: p.playerId, id: p.playerId,
})); }));
const mine = result.players.find((p) => p.playerId === user.value.id); const mine = result.players.find((p) => p.playerId === myId);
if (mine) totalPoints.value = mine.totalScore; if (mine) totalPoints.value = mine.totalScore;
rank.value = rank.value = result.players.findIndex((p) => p.playerId === myId) + 1;
result.players.findIndex((p) => p.playerId === user.value.id) + 1;
} }
} else { } else {
const battleInfo = uni.getStorageSync("last-battle"); const battleInfo = uni.getStorageSync("last-battle");
if (!battleInfo) return; if (!battleInfo) return;
data.value = battleInfo; data.value = battleInfo;
const mine = battleInfo.playerStats.find((p) => p.id === user.value.id); if (battleInfo.mode === 1) {
rank.value = battleInfo.playerStats.forEach((p) => {
battleInfo.playerStats.findIndex((p) => p.id === user.value.id) + 1; if (p.team === 1) data.value.bluePlayers = [p];
if (p.team === 0) data.value.redPlayers = [p];
});
}
rank.value = 0;
const mine = battleInfo.playerStats.find((p, index) => {
rank.value = index + 1;
return p.id === myId;
});
if (mine) { if (mine) {
data.value.myTeam = mine.team;
totalPoints.value = mine.totalScore; totalPoints.value = mine.totalScore;
ifWin.value = battleInfo.mode === 1 && mine.team === battleInfo.winner; ifWin.value = battleInfo.mode === 1 && mine.team === battleInfo.winner;
} }
@@ -73,21 +83,55 @@ const checkBowData = () => {
<template> <template>
<view class="container"> <view class="container">
<image <!-- <image
:style="{ opacity: ifWin ? '1' : '0' }" :style="{ opacity: ifWin ? '1' : '0' }"
class="tag" class="tag"
src="../static/winner-yellow.png" src="../static/winner-yellow.png"
mode="widthFix" mode="widthFix"
/> /> -->
<block v-if="data.mode === 1"> <block v-if="data.mode === 1">
<view class="header-team" :style="{ marginTop: '25%' }"> <view class="header-team" :style="{ marginTop: '25%' }">
<image src="../static/battle-result.png" mode="widthFix" /> <image src="../static/battle-result.png" mode="widthFix" />
<view>
<text
:style="{
background:
data.winner === 1
? 'linear-gradient(270deg, #3597ff 0%, rgba(0,0,0,0) 100%);'
: 'linear-gradient(270deg, #fd4444 0%, rgba(0, 0, 0, 0) 100%)',
}"
>{{ data.winner === 1 ? "蓝队" : "红队" }}获胜</text
>
<Avatar
:size="32"
:src="
data.winner === 1
? data.bluePlayers[0].avatar
: data.redPlayers[0].avatar
"
:borderColor="data.winner === 1 ? '#5FADFF' : '#FF5656'"
mode="widthFix"
/>
</view>
</view> </view>
<view class="battle-winner"> <view class="battle-winner">
<image src="../static/shining-bg.png" mode="widthFix" /> <image src="../static/shining-bg.png" mode="widthFix" />
<image src="../static/throphy.png" mode="widthFix" /> <image
<text>{{ data.winner === 1 ? "蓝队" : "红队" }}获胜</text> :src="ifWin ? '../static/you-win.png' : '../static/you-lost.png'"
<text>强势登顶荣耀加冕</text> mode="widthFix"
class="scale-in"
/>
<image
:src="
getBattleResultTips(data.battleMode, data.mode, {
win: ifWin,
})
"
class="scale-in"
mode="widthFix"
/>
<!-- <text>{{ data.winner === 1 ? "蓝队" : "红队" }}获胜</text> -->
<!-- <text>强势登顶荣耀加冕</text> -->
</view> </view>
</block> </block>
<block v-if="data.mode === 2"> <block v-if="data.mode === 2">
@@ -162,17 +206,28 @@ const checkBowData = () => {
</view> </view>
</view> </view>
</block> </block>
<view class="battle-e"> <view
class="battle-e"
:style="{ marginTop: data.battleMode === 2 ? '20px' : '20vw' }"
>
<image src="../static/row-yellow-bg.png" mode="widthFix" /> <image src="../static/row-yellow-bg.png" mode="widthFix" />
<Avatar :src="user.avatar" :size="40" /> <view :style="{ borderColor: data.myTeam === 1 ? '#5fadff' : '#ff6060' }">
<Avatar :src="user.avatar" :size="40" />
<text :style="{ backgroundColor: '#5fadff' }" v-if="data.myTeam === 1"
>蓝队</text
>
<text :style="{ backgroundColor: '#ff6060' }" v-if="data.myTeam === 0"
>红队</text
>
</view>
<text v-if="data.battleMode === 1"> <text v-if="data.battleMode === 1">
经验 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }} 你的经验 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}
</text> </text>
<text v-if="data.battleMode === 2"> <text v-if="data.battleMode === 2">
积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }} 你的积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}
</text> </text>
</view> </view>
<text class="description"> <text v-if="data.battleMode === 2" class="description">
{{ {{
getBattleResultTips(data.battleMode, data.mode, { getBattleResultTips(data.battleMode, data.mode, {
win: ifWin, win: ifWin,
@@ -210,12 +265,26 @@ const checkBowData = () => {
position: relative; position: relative;
} }
.header-team { .header-team {
width: 80%; width: 82%;
margin: 10px; margin: 10px;
display: flex;
align-items: center;
justify-content: space-between;
color: #fff;
} }
.header-team > image { .header-team > image {
width: 20vw; width: 20vw;
} }
.header-team > view {
font-size: 14px;
display: flex;
align-items: flex-end;
}
.header-team > view > text {
padding: 5px 20px;
padding-left: 24px;
transform: translateX(15px);
}
.battle-winner { .battle-winner {
width: 100%; width: 100%;
height: 38%; height: 38%;
@@ -232,7 +301,16 @@ const checkBowData = () => {
top: 0; top: 0;
left: 0; left: 0;
} }
.battle-winner > image:first-child {
animation: rotate 10s linear infinite;
}
.battle-winner > image:nth-child(2) { .battle-winner > image:nth-child(2) {
top: 10%;
}
.battle-winner > image:nth-child(3) {
top: 75%;
}
/* .battle-winner > image:nth-child(2) {
top: 6vw; top: 6vw;
} }
.battle-winner > text:nth-child(3) { .battle-winner > text:nth-child(3) {
@@ -243,19 +321,35 @@ const checkBowData = () => {
} }
.battle-winner > text:nth-child(4) { .battle-winner > text:nth-child(4) {
margin-bottom: 10px; margin-bottom: 10px;
} } */
.battle-e { .battle-e {
width: 100%; width: 100%;
height: 60px; height: 60px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-top: 20px;
} }
.battle-e > image { .battle-e > image {
position: absolute; position: absolute;
width: 100vw; width: 100vw;
} }
.battle-e > view:nth-child(2) {
position: relative;
border: 1px solid;
overflow: hidden;
width: 40px;
height: 40px;
box-sizing: border-box;
border-radius: 50%;
}
.battle-e > view:nth-child(2) > text {
font-size: 7px;
text-align: center;
width: 100%;
position: absolute;
bottom: 0;
color: #fff;
}
.battle-e > text { .battle-e > text {
position: relative; position: relative;
font-size: 30px; font-size: 30px;
@@ -263,16 +357,18 @@ const checkBowData = () => {
margin-left: 10px; margin-left: 10px;
} }
.description { .description {
margin: 50px 0; margin-top: 50px;
font-size: 14px; font-size: 14px;
color: #fed847; color: #fed847;
width: 100%; width: 100%;
text-align: center; text-align: center;
margin-bottom: 10px;
} }
.op-btn { .op-btn {
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: center; justify-content: center;
margin-top: 30px;
} }
.op-btn > view { .op-btn > view {
width: 36%; width: 36%;

View File

@@ -144,7 +144,7 @@ async function onReceiveMessage(messages = []) {
uni.redirectTo({ uni.redirectTo({
url: "/pages/battle-result", url: "/pages/battle-result",
}); });
}, 3000); }, 1000);
} }
if (msg.constructor === MESSAGETYPES.BackToGame) { if (msg.constructor === MESSAGETYPES.BackToGame) {
uni.$emit("update-header-loading", false); uni.$emit("update-header-loading", false);

View File

@@ -235,7 +235,7 @@ async function onReceiveMessage(messages = []) {
uni.redirectTo({ uni.redirectTo({
url: "/pages/battle-result", url: "/pages/battle-result",
}); });
}, 1500); }, 1000);
} }
} }
if (msg.constructor === MESSAGETYPES.BackToGame) { if (msg.constructor === MESSAGETYPES.BackToGame) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

BIN
src/static/you-lost.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
src/static/you-win.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB