初步完成返回游戏功能,待测试完善
This commit is contained in:
@@ -46,10 +46,41 @@ const onComplete = ref(null);
|
||||
const showModal = ref(false);
|
||||
|
||||
onLoad(async (options) => {
|
||||
gameType.value = options.gameType;
|
||||
teamSize.value = options.teamSize;
|
||||
if (gameType.value && teamSize.value) {
|
||||
await matchGameAPI(true, gameType.value, teamSize.value);
|
||||
if (options.battleId) {
|
||||
const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
|
||||
console.log("----battleInfo", battleInfo);
|
||||
if (battleInfo) {
|
||||
battleId.value = battleInfo.id;
|
||||
start.value = true;
|
||||
redTeam.value = battleInfo.redTeam;
|
||||
blueTeam.value = battleInfo.blueTeam;
|
||||
currentRound.value = battleInfo.currentRound;
|
||||
bluePoints.value = battleInfo.blueScore;
|
||||
redPoints.value = battleInfo.redScore;
|
||||
totalRounds.value = battleInfo.maxRound;
|
||||
roundResults.value = battleInfo.roundResults;
|
||||
if (battleInfo.firePlayerIndex) {
|
||||
currentShooterId.value = battleInfo.firePlayerIndex;
|
||||
if (redTeam.value[0].id === currentShooterId.value) {
|
||||
tips.value = `请红队射箭-第${roundsName[currentRound.value]}轮`;
|
||||
} else {
|
||||
tips.value = `请蓝队射箭-第${roundsName[currentRound.value]}轮`;
|
||||
}
|
||||
}
|
||||
const remain = Date.now() / 1000 - battleInfo.fireTime;
|
||||
if (remain > 0 && remain <= 15) {
|
||||
// 等渲染好再通知
|
||||
setTimeout(() => {
|
||||
uni.$emit("update-ramain", remain);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
gameType.value = options.gameType;
|
||||
teamSize.value = options.teamSize;
|
||||
if (gameType.value && teamSize.value) {
|
||||
await matchGameAPI(true, gameType.value, teamSize.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
async function stopMatch() {
|
||||
@@ -227,11 +258,4 @@ onUnmounted(() => {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.modal {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user