调试重新进入比赛

This commit is contained in:
kron
2025-07-03 21:13:55 +08:00
parent 18ce93b12f
commit 79c869a3f3
7 changed files with 68 additions and 20 deletions

View File

@@ -1,3 +1,4 @@
import { MESSAGETYPES } from "@/constants";
let socket = null;
let heartbeatInterval = null;
let reconnectCount = 0;
@@ -32,6 +33,29 @@ function createWebSocket(token, onMessage) {
uni.onSocketMessage((res) => {
const data = JSON.parse(res.data);
if (onMessage) onMessage(data.data.updates);
const msg = data.data.updates[0];
if (msg && msg.constructor === MESSAGETYPES.BackToGame) {
const { battleInfo } = msg;
uni.setStorageSync(`battle-${battleInfo.id}`, battleInfo);
// 约战
if (battleInfo.config.battleMode === 1) {
uni.navigateTo({
url: `/pages/team-match?battleId=${battleInfo.id}`,
});
}
// 排位
if (battleInfo.config.battleMode === 2) {
if (battleInfo.config.mode === 1) {
uni.navigateTo({
url: `/pages/team-match?battleId=${battleInfo.id}`,
});
} else if (battleInfo.config.mode === 2) {
uni.navigateTo({
url: `/pages/melee-match?battleId=${battleInfo.id}`,
});
}
}
}
});
// 错误处理