diff --git a/src/apis.js b/src/apis.js index 144adc2..b017577 100644 --- a/src/apis.js +++ b/src/apis.js @@ -6,7 +6,7 @@ try { switch (envVersion) { case "develop": // 开发版 - // BASE_URL = "http://192.168.1.242:8000/api/shoot"; + // BASE_URL = "http://192.168.1.30:8000/api/shoot"; BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot"; break; case "trial": // 体验版 @@ -418,9 +418,9 @@ export const getUserGameState = () => { }; export const getCurrentGameAPI = async () => { - uni.$emit("update-header-loading", true); - const result = await request("GET", "/user/join/battle"); - return result.currentGame || {}; + // uni.$emit("update-header-loading", true); + // const result = await request("GET", "/user/join/battle"); + // return result.currentGame || {}; }; export const getPointBookConfigAPI = async () => { @@ -552,3 +552,10 @@ export const getReadyAPI = (roomId) => { roomId, }); }; + +export const getBattleAPI = async (battleId) => { + const result = await request("POST", "/user/match/info", { + id: battleId, + }); + return result; +}; diff --git a/src/components/BackToGame.vue b/src/components/BackToGame.vue index 31167fb..703612e 100644 --- a/src/components/BackToGame.vue +++ b/src/components/BackToGame.vue @@ -2,7 +2,7 @@ import { ref, watch, onMounted, onBeforeUnmount } from "vue"; import { onShow } from "@dcloudio/uni-app"; -import { getCurrentGameAPI, getUserGameState } from "@/apis"; +import { getBattleAPI, getUserGameState } from "@/apis"; import { debounce } from "@/util"; import useStore from "@/store"; @@ -44,10 +44,21 @@ const onClick = debounce(async () => { if (loading.value) return; try { loading.value = true; - if (game.value.inBattle) { - await uni.$checkAudio(); - const result = await getCurrentGameAPI(); - } else if (game.value.roomID) { + const result = await getBattleAPI(); + if (result && result.matchId) { + // await uni.$checkAudio(); + if (result.way === 1) { + uni.navigateTo({ + url: `/pages/team-battle?battleId=${result.matchId}`, + }); + } else if (result.way === 2) { + uni.navigateTo({ + url: `/pages/melee-match?battleId=${result.matchId}`, + }); + } + return; + } + if (game.value.roomID) { uni.navigateTo({ url: "/pages/battle-room?roomNumber=" + game.value.roomID, }); diff --git a/src/components/BattleFooter.vue b/src/components/BattleFooter.vue index 3186b2f..cfed39f 100644 --- a/src/components/BattleFooter.vue +++ b/src/components/BattleFooter.vue @@ -22,9 +22,10 @@ const props = defineProps({ }, }); -const normalRounds = computed( - () => props.roundResults.length - props.goldenRound -); +const normalRounds = computed(() => { + const count = props.roundResults.findIndex((item) => !!item.ifGold); + return count > 0 ? count : props.roundResults.length; +});