diff --git a/src/pages/battle-result.vue b/src/pages/battle-result.vue index b31925d..51c0650 100644 --- a/src/pages/battle-result.vue +++ b/src/pages/battle-result.vue @@ -22,23 +22,31 @@ function exit() { onLoad(async (options) => { if (options.battleId) { - battleId.value = options.battleId; const result = await getGameAPI( - options.battleId || "BATTLE-1752563964391008873-624" + options.battleId || "BATTLE-1753274533670200664-192" + // options.battleId || "BATTLE-1753239612271030113-788" ); - 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; - // } + const battleInfo = uni.getStorageSync("last-battle"); + data.value = { + ...result, + id: options.battleId, + battleMode: result.gameMode, + playerStats: result.players.map((p) => ({ ...p, id: p.playerId })), + }; + 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; + rank.value = + result.players.findIndex((p) => p.playerId === user.value.id) + 1; + } } else { const battleInfo = uni.getStorageSync("last-battle"); if (!battleInfo) return; @@ -58,7 +66,6 @@ const checkBowData = () => { url: `/pages/match-detail?id=${data.value.id}`, }); }; -