diff --git a/src/apis.js b/src/apis.js index 4c4850a..e463b14 100644 --- a/src/apis.js +++ b/src/apis.js @@ -260,6 +260,7 @@ export const matchGameAPI = (match, gameType, teamSize) => { match, gameType, teamSize, + readyTime: 1.5, }); }; diff --git a/src/constants.js b/src/constants.js index 93b459f..f0c5962 100644 --- a/src/constants.js +++ b/src/constants.js @@ -39,6 +39,7 @@ export const MESSAGETYPESV2 = { BattleEnd: 6, HalfRest: 7, TestDistance: 8, + MatchSuccess: 9, }; export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"]; diff --git a/src/pages/battle-result.vue b/src/pages/battle-result.vue index e0e7d59..03e05b7 100644 --- a/src/pages/battle-result.vue +++ b/src/pages/battle-result.vue @@ -31,7 +31,7 @@ function exit() { onLoad(async (options) => { if (!options.battleId) return; const myId = user.value.id; - const result = await getBattleAPI(options.battleId || "59090720979554304"); + const result = await getBattleAPI(options.battleId || "60049406950510592"); data.value = result; if (result.winTeam) { ifWin.value = result.teams[result.winTeam].players.some( @@ -246,7 +246,7 @@ const checkBowData = () => { @@ -257,12 +257,12 @@ const checkBowData = () => { /> 蓝队 红队 @@ -273,7 +273,7 @@ const checkBowData = () => { 你的积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }} - + {{ getBattleResultTips(data.way, data.mode, { win: ifWin, diff --git a/src/pages/match-page.vue b/src/pages/match-page.vue index 49ca6be..89b7cb8 100644 --- a/src/pages/match-page.vue +++ b/src/pages/match-page.vue @@ -6,42 +6,32 @@ import Matching from "@/components/Matching.vue"; import RoundEndTip from "@/components/RoundEndTip.vue"; import TestDistance from "@/components/TestDistance.vue"; import { matchGameAPI } from "@/apis"; -import { MESSAGETYPES } from "@/constants"; +import { MESSAGETYPESV2 } from "@/constants"; const gameType = ref(0); const teamSize = ref(0); const onComplete = ref(null); +const matchSuccess = ref(false); async function stopMatch() { uni.$showHint(3); } -async function onReceiveMessage(messages = []) { - messages.forEach((msg) => { - if (msg.constructor === MESSAGETYPES.WaitForAllReady) { - if (!onComplete.value) { - onComplete.value = () => { - if (msg.groupUserStatus) { - uni.setStorageSync("red-team", msg.groupUserStatus.redTeam); - uni.setStorageSync("blue-team", msg.groupUserStatus.blueTeam); - uni.setStorageSync("melee-players", [ - ...msg.groupUserStatus.redTeam, - ...msg.groupUserStatus.blueTeam, - ]); - } - if (gameType.value == 1) { - uni.redirectTo({ - url: `/pages/team-battle?battleId=${msg.id}&gameMode=2`, - }); - } else if (gameType.value == 2) { - uni.redirectTo({ - url: `/pages/melee-battle?battleId=${msg.id}&gameMode=2`, - }); - } - }; +async function onReceiveMessage(msg) { + if (msg.type === MESSAGETYPESV2.MatchSuccess) { + matchSuccess.value = true; + onComplete.value = () => { + if (gameType.value == 1) { + uni.redirectTo({ + url: `/pages/team-battle?battleId=${msg.id}&gameMode=2`, + }); + } else if (gameType.value == 2) { + uni.redirectTo({ + url: `/pages/melee-battle?battleId=${msg.id}&gameMode=2`, + }); } - } - }); + }; + } } onLoad(async (options) => { @@ -63,7 +53,7 @@ onBeforeUnmount(() => { keepScreenOn: false, }); uni.$off("socket-inbox", onReceiveMessage); - if (gameType.value && teamSize.value) { + if (gameType.value && teamSize.value && !matchSuccess.value) { matchGameAPI(false, gameType.value, teamSize.value); } }); @@ -75,7 +65,7 @@ onShow(async () => { }); onHide(() => { - if (gameType.value && teamSize.value) { + if (gameType.value && teamSize.value && !matchSuccess.value) { matchGameAPI(false, gameType.value, teamSize.value); } }); diff --git a/src/pages/ranking.vue b/src/pages/ranking.vue index 81a8e5f..04d73d6 100644 --- a/src/pages/ranking.vue +++ b/src/pages/ranking.vue @@ -197,22 +197,22 @@ onShow(async () => { diff --git a/src/pages/team-battle.vue b/src/pages/team-battle.vue index 12088a0..c7751b4 100644 --- a/src/pages/team-battle.vue +++ b/src/pages/team-battle.vue @@ -104,6 +104,7 @@ async function onReceiveMessage(msg) { } else if (msg.type === MESSAGETYPESV2.ToSomeoneShoot) { recoverData(msg); } else if (msg.type === MESSAGETYPESV2.ShootResult) { + showRoundTip.value = false; recoverData(msg, { arrowOnly: true }); } else if (msg.type === MESSAGETYPESV2.NewRound) { showRoundTip.value = true;