添加返回比赛结束跳转结果页
This commit is contained in:
@@ -22,23 +22,31 @@ function exit() {
|
|||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (options.battleId) {
|
if (options.battleId) {
|
||||||
battleId.value = options.battleId;
|
|
||||||
const result = await getGameAPI(
|
const result = await getGameAPI(
|
||||||
options.battleId || "BATTLE-1752563964391008873-624"
|
options.battleId || "BATTLE-1753274533670200664-192"
|
||||||
|
// options.battleId || "BATTLE-1753239612271030113-788"
|
||||||
);
|
);
|
||||||
data.value = result;
|
const battleInfo = uni.getStorageSync("last-battle");
|
||||||
// if (result.mode === 1 && result.redPlayers[user.value.id]) {
|
data.value = {
|
||||||
// totalPoints.value = result.redPlayers[user.value.id].totalScore;
|
...result,
|
||||||
// ifWin.value = result.winner === 0;
|
id: options.battleId,
|
||||||
// }
|
battleMode: result.gameMode,
|
||||||
// if (result.mode === 1 && result.bluePlayers[user.value.id]) {
|
playerStats: result.players.map((p) => ({ ...p, id: p.playerId })),
|
||||||
// totalPoints.value = result.bluePlayers[user.value.id].totalScore;
|
};
|
||||||
// ifWin.value = result.winner === 1;
|
if (result.mode === 1 && result.redPlayers[user.value.id]) {
|
||||||
// }
|
totalPoints.value = result.redPlayers[user.value.id].totalScore;
|
||||||
// if (result.mode === 2) {
|
ifWin.value = result.winner === 0;
|
||||||
// const mine = result.players.find((p) => p.playerId === user.value.id);
|
}
|
||||||
// if (mine) totalPoints.value = mine.totalScore;
|
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 {
|
} else {
|
||||||
const battleInfo = uni.getStorageSync("last-battle");
|
const battleInfo = uni.getStorageSync("last-battle");
|
||||||
if (!battleInfo) return;
|
if (!battleInfo) return;
|
||||||
@@ -58,7 +66,6 @@ const checkBowData = () => {
|
|||||||
url: `/pages/match-detail?id=${data.value.id}`,
|
url: `/pages/match-detail?id=${data.value.id}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<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();
|
const isGaming = await isGamingAPI();
|
||||||
if (!isGaming) {
|
if (!isGaming) {
|
||||||
uni.showToast({
|
// uni.showToast({
|
||||||
title: "比赛已结束",
|
// title: "比赛已结束",
|
||||||
icon: "none",
|
// icon: "none",
|
||||||
|
// });
|
||||||
|
// setTimeout(() => {
|
||||||
|
// uni.navigateBack();
|
||||||
|
// }, 1000);
|
||||||
|
uni.redirectTo({
|
||||||
|
url: `/pages/battle-result?battleId=${battleId}`,
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack();
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
return !isGaming;
|
return !isGaming;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user