diff --git a/src/apis.js b/src/apis.js index 16c36f3..3d3c697 100644 --- a/src/apis.js +++ b/src/apis.js @@ -270,78 +270,6 @@ export const readyGameAPI = (battleId) => { }); }; -export const getGameAPI = async (battleId) => { - const result = await request("POST", "/user/battle/detail", { - id: battleId, - }); - if (!result.battleStats) return {}; - const { - battleStats = {}, - playerStats = {}, - goldenRoundRecords = [], - } = result; - const data = { - id: battleId, - mode: battleStats.mode, // 1.几V几 2.大乱斗 - gameMode: battleStats.gameMode, // 1.约战 2.排位 - teamSize: battleStats.teamSize, - }; - if (battleStats && battleStats.mode === 1) { - data.winner = battleStats.winner; - data.roundsData = {}; - data.redPlayers = {}; - data.bluePlayers = {}; - data.mvps = []; - data.goldenRounds = - goldenRoundRecords && goldenRoundRecords.length ? goldenRoundRecords : []; - playerStats.forEach((item) => { - const { playerBattleStats = {}, roundRecords = [] } = item; - if (playerBattleStats.team === 0) { - data.redPlayers[playerBattleStats.playerId] = playerBattleStats; - } - if (playerBattleStats.team === 1) { - data.bluePlayers[playerBattleStats.playerId] = playerBattleStats; - } - if (playerBattleStats.mvp) { - data.mvps.push(playerBattleStats); - } - roundRecords.forEach((round) => { - data.roundsData[round.roundNumber] = { - ...data.roundsData[round.roundNumber], - [round.playerId]: round.arrowHistory, - }; - }); - }); - const totalRounds = Object.keys(data.roundsData).length; - (goldenRoundRecords || []).forEach((item, index) => { - item.arrowHistory.forEach((arrow) => { - if (!data.roundsData[totalRounds + index + 1]) { - data.roundsData[totalRounds + index + 1] = {}; - } - if (!data.roundsData[totalRounds + index + 1][arrow.playerId]) { - data.roundsData[totalRounds + index + 1][arrow.playerId] = []; - } - data.roundsData[totalRounds + index + 1][arrow.playerId].push(arrow); - }); - }); - - data.mvps.sort((a, b) => b.totalRings - a.totalRings); - } - if (battleStats && battleStats.mode === 2) { - data.players = []; - playerStats.forEach((item) => { - data.players.push({ - ...item.playerBattleStats, - arrowHistory: item.roundRecords[0].arrowHistory, - }); - }); - data.players = data.players.sort((a, b) => b.totalScore - a.totalScore); - } - // console.log("game result:", result); - // console.log("format data:", data); - return data; -}; - export const simulShootAPI = (device_id, x, y) => { const data = { device_id, diff --git a/src/pages/my-growth.vue b/src/pages/my-growth.vue index 685b5e6..34dec56 100644 --- a/src/pages/my-growth.vue +++ b/src/pages/my-growth.vue @@ -93,8 +93,8 @@ const getName = (battle) => { { { const date = new Date(timestamp * 1000); const year = date.getFullYear(); @@ -89,27 +87,6 @@ export const wxShare = async (canvasId = "shareCanvas") => { } }; -// export const isGameEnded = async (battleId) => { -// const state = await getUserGameState(); -// if (!state.gaming) { -// const result = await getGameAPI(battleId); -// if (result.mode) { -// uni.redirectTo({ -// url: `/pages/battle-result?battleId=${battleId}`, -// }); -// } else { -// uni.showToast({ -// title: "比赛已结束", -// icon: "none", -// }); -// setTimeout(() => { -// uni.navigateBack(); -// }, 1000); -// } -// } -// return !state.gaming; -// }; - // 获取元素尺寸和位置信息 export const getElementRect = (classname) => { return new Promise((resolve) => {