添加返回比赛结束跳转结果页
This commit is contained in:
@@ -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}`,
|
||||
});
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
17
src/util.js
17
src/util.js
@@ -266,16 +266,19 @@ export const wxShare = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
export const isGameEnded = async () => {
|
||||
export const isGameEnded = async (battleId) => {
|
||||
const isGaming = await isGamingAPI();
|
||||
if (!isGaming) {
|
||||
uni.showToast({
|
||||
title: "比赛已结束",
|
||||
icon: "none",
|
||||
// uni.showToast({
|
||||
// title: "比赛已结束",
|
||||
// icon: "none",
|
||||
// });
|
||||
// setTimeout(() => {
|
||||
// uni.navigateBack();
|
||||
// }, 1000);
|
||||
uni.redirectTo({
|
||||
url: `/pages/battle-result?battleId=${battleId}`,
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1000);
|
||||
}
|
||||
return !isGaming;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user