fix:全部对战页面对接新结算页面

This commit is contained in:
2026-05-09 15:51:51 +08:00
parent eaa1950a18
commit 834841a3d5
5 changed files with 25 additions and 41 deletions

View File

@@ -223,16 +223,24 @@ function closeOverlay() {
}
/**
* 返回对应的战斗房间
* 若有 roomId 则跳转到房间页,否则返回上一页
* 底部按钮文案:好友约战显示“返回房间”,排位赛等其他模式显示“返回”
*/
const exitBtnText = computed(() => data.value.way === 1 ? '返回房间' : '返回');
/**
* 点击底部按钮跳转
* - 好友约战way=1返回对战房间
* - 其他模式(排位赛等):跳转到排位赛首页
*/
function exit() {
if (data.value.roomId) {
if (data.value.way === 1) {
uni.redirectTo({
url: `/pages/battle-room?roomNumber=${data.value.roomId}`,
});
} else {
uni.navigateBack();
uni.redirectTo({
url: '/pages/ranking',
});
}
}
@@ -428,7 +436,7 @@ function goBack() {
<view
:class="['btn-return', data.mode > 3 ? 'btn-return-melee' : 'btn-return-battle']"
@click="exit"
>返回房间</view>
>{{ exitBtnText }}</view>
</view>
<!-- ===== 进场覆盖动效层初始显示点击或2.5s后消失===== -->

View File

@@ -30,10 +30,6 @@ const playersScores = ref([]);
const halfTimeTip = ref(false);
const halfRest = ref(false);
const navigateToResult = () => {
uni.redirectTo({ url: `/pages/battle-result?battleId=${battleId.value}` });
};
function recoverData(battleInfo, { force = false } = {}) {
if (!battleInfo) return;
try {
@@ -126,16 +122,10 @@ async function onReceiveMessage(msg) {
tips.value = "准备下半场";
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
setTimeout(() => {
// 好友约战way=1跳转新结算页,其余跳旧结算页
if (way.value === 1) {
uni.redirectTo({
url: "/pages/friend-battle-result?battleId=" + msg.matchId,
});
} else {
uni.redirectTo({
url: "/pages/battle-result?battleId=" + msg.matchId,
});
}
// 全部跳转新结算页
uni.redirectTo({
url: "/pages/friend-battle-result?battleId=" + msg.matchId,
});
}, 1000);
}
}

View File

@@ -129,17 +129,10 @@ function onAudioEnded(s) {
function onBattleEnd() {
if (matchStatus.value === 2) {
// 好友约战way===1跳转专属结算页其他模式保持跳转旧结算页
// 后期如需新增更多模式的专属页面,在此扩展 if/else 分支即可
if (battleWay.value === 1) {
uni.redirectTo({
url: `/pages/friend-battle-result?battleId=${battleId.value}`,
});
} else {
uni.redirectTo({
url: `/pages/battle-result?battleId=${battleId.value}`,
});
}
// 全部跳转到新结算页
uni.redirectTo({
url: `/pages/friend-battle-result?battleId=${battleId.value}`,
});
}
}
@@ -215,17 +208,10 @@ onShow(async () => {
const result = await getBattleAPI(battleId.value);
if (!result) return;
if (result.status === 2) {
// 比赛已结束(如切后台再回来):跳结算页,按 way 分流
// 与 onBattleEnd 保持一致,避免返回首页
if (result.way === 1) {
uni.redirectTo({
url: `/pages/friend-battle-result?battleId=${result.matchId}`,
});
} else {
uni.redirectTo({
url: `/pages/battle-result?battleId=${result.matchId}`,
});
}
// 比赛已结束(如切后台再回来):跳结算页
uni.redirectTo({
url: `/pages/friend-battle-result?battleId=${result.matchId}`,
});
} else {
recoverData(result, {force: true});
}

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB