BUG修复

This commit is contained in:
kron
2025-08-21 14:50:17 +08:00
parent fca4a138d7
commit e20cb3b272
2 changed files with 52 additions and 37 deletions

View File

@@ -70,6 +70,13 @@ function request(method, url, data = {}) {
resolve({}); resolve({});
return; return;
} }
if (message === "ROOM_EMPTY") {
uni.showToast({
title: "房间已过期",
icon: "none",
});
return;
}
uni.showToast({ uni.showToast({
title: message, title: message,
icon: "none", icon: "none",

View File

@@ -42,31 +42,23 @@ async function refreshRoomData() {
id: m.userInfo.id, id: m.userInfo.id,
name: m.userInfo.name, name: m.userInfo.name,
avatar: m.userInfo.avatar, avatar: m.userInfo.avatar,
rankLvl: m.userInfo.rankLvl,
}; };
return true; return true;
} }
return false; return false;
}); });
if (result.battleType === 1 && result.count === 1) { if (result.battleType === 1 && result.count === 2) {
if (user.value.id !== owner.value.id) { result.members.forEach((m) => {
opponent.value = {
id: user.value.id,
name: user.value.nickName,
avatar: user.value.avatar,
};
} else if (result.members.length > 1) {
result.members.some((m) => {
if (m.userInfo.id !== owner.value.id) { if (m.userInfo.id !== owner.value.id) {
opponent.value = { opponent.value = {
id: m.userInfo.id, id: m.userInfo.id,
name: m.userInfo.name, name: m.userInfo.name,
avatar: m.userInfo.avatar, avatar: m.userInfo.avatar,
rankLvl: m.userInfo.rankLvl,
}; };
return true;
} }
return false;
}); });
}
} else if (result.battleType === 2) { } else if (result.battleType === 2) {
players.value = []; players.value = [];
const ownerIndex = result.members.findIndex( const ownerIndex = result.members.findIndex(
@@ -117,12 +109,14 @@ async function onReceiveMessage(messages = []) {
id: msg.userId, id: msg.userId,
name: msg.name, name: msg.name,
avatar: msg.avatar, avatar: msg.avatar,
rankLvl: msg.rankLvl,
}; };
} else { } else {
opponent.value = { opponent.value = {
id: msg.userId, id: msg.userId,
name: msg.name, name: msg.name,
avatar: msg.avatar, avatar: msg.avatar,
rankLvl: msg.rankLvl,
}; };
} }
} }
@@ -132,12 +126,14 @@ async function onReceiveMessage(messages = []) {
id: msg.userId, id: msg.userId,
name: msg.name, name: msg.name,
avatar: msg.avatar, avatar: msg.avatar,
rankLvl: msg.rankLvl,
}; };
} else { } else {
players.value.push({ players.value.push({
id: msg.userId, id: msg.userId,
name: msg.name, name: msg.name,
avatar: msg.avatar, avatar: msg.avatar,
rankLvl: msg.rankLvl,
}); });
} }
} }
@@ -285,26 +281,38 @@ onHide(() => {});
mode="widthFix" mode="widthFix"
/> />
<view> <view>
<view class="player" :style="{ transform: 'translateY(-60px)' }"> <view
<Avatar :rankLvl="user.rankLvl" :src="user.avatar" :size="60" /> v-if="owner.id"
class="player"
:style="{ transform: 'translateY(-60px)' }"
>
<Avatar :rankLvl="owner.rankLvl" :src="owner.avatar" :size="60" />
<text>{{ owner.name }}</text> <text>{{ owner.name }}</text>
<text>创建者</text> <text>创建者</text>
</view> </view>
<view
v-else
class="no-player"
:style="{ transform: 'translateY(-60px)' }"
>
<image src="../static/question-mark.png" mode="widthFix" />
</view>
<image src="../static/versus.png" mode="widthFix" /> <image src="../static/versus.png" mode="widthFix" />
<block v-if="opponent.id"> <view
<view class="player" :style="{ transform: 'translateY(60px)' }"> v-if="opponent.id"
<image class="player"
:src="opponent.avatar || '../static/user-icon.png'" :style="{ transform: 'translateY(60px)' }"
mode="widthFix" >
<Avatar
:rankLvl="opponent.rankLvl"
:src="opponent.avatar"
:size="60"
/> />
<text v-if="opponent.name">{{ opponent.name }}</text> <text v-if="opponent.name">{{ opponent.name }}</text>
</view> </view>
</block> <view class="no-player" v-else>
<block v-else>
<view class="no-player">
<image src="../static/question-mark.png" mode="widthFix" /> <image src="../static/question-mark.png" mode="widthFix" />
</view> </view>
</block>
</view> </view>
</view> </view>
<PlayerSeats <PlayerSeats
@@ -478,7 +486,7 @@ onHide(() => {});
text-overflow: ellipsis; text-overflow: ellipsis;
text-align: center; text-align: center;
} }
.player > text:last-child { .player > text:nth-child(3) {
color: #000; color: #000;
background-color: #fed847; background-color: #fed847;
font-size: 8px; font-size: 8px;