调试多v多房间功能
This commit is contained in:
@@ -114,8 +114,8 @@ const refreshMembers = (members = []) => {
|
||||
players.value[index] = { ...m.userInfo, groupType: m.groupType };
|
||||
if (m.groupType === 1) {
|
||||
blueTeam.value.push({ ...m.userInfo, groupType: 1 });
|
||||
} else if (m.groupType === 0) {
|
||||
redTeam.value.push({ ...m.userInfo, groupType: 0 });
|
||||
} else if (m.groupType === 2) {
|
||||
redTeam.value.push({ ...m.userInfo, groupType: 2 });
|
||||
}
|
||||
});
|
||||
for (let i = 0; i < room.value.count / 2; i++) {
|
||||
@@ -165,12 +165,6 @@ async function onReceiveMessage(message) {
|
||||
}
|
||||
|
||||
const chooseTeam = async (team) => {
|
||||
if (team !== 2) {
|
||||
const notInTeam = room.value.members.some(
|
||||
(m) => m.userInfo.id === user.value.id && m.groupType === 2
|
||||
);
|
||||
if (!notInTeam) return;
|
||||
}
|
||||
const result = await chooseTeamAPI(roomNumber.value, team);
|
||||
refreshMembers(result.members);
|
||||
};
|
||||
@@ -302,45 +296,45 @@ onBeforeUnmount(() => {
|
||||
<view class="choose-side">
|
||||
<view>
|
||||
<view
|
||||
v-for="(item, index) in blueTeam"
|
||||
v-for="(item, index) in redTeam"
|
||||
:key="index"
|
||||
class="choose-side-left-item"
|
||||
>
|
||||
<button
|
||||
hover-class="none"
|
||||
v-if="item.id === user.id"
|
||||
@click="chooseTeam(2)"
|
||||
@click="chooseTeam(0)"
|
||||
>
|
||||
<image src="../static/close-grey.png" mode="widthFix" />
|
||||
</button>
|
||||
<text class="truncate">{{ item.name || "我要加入" }}</text>
|
||||
<view v-if="item.id">
|
||||
<Avatar :src="item.avatar" :size="36" />
|
||||
<text v-if="!!item.state">已准备</text>
|
||||
<text :style="{ opacity: !!item.state ? 1 : 0 }">已准备</text>
|
||||
</view>
|
||||
<button v-else hover-class="none" @click="chooseTeam(1)">
|
||||
<button v-else hover-class="none" @click="chooseTeam(2)">
|
||||
<image src="../static/add-grey.png" mode="widthFix" />
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view
|
||||
v-for="(item, index) in redTeam"
|
||||
v-for="(item, index) in blueTeam"
|
||||
:key="index"
|
||||
class="choose-side-right-item"
|
||||
>
|
||||
<view v-if="item.id">
|
||||
<Avatar :src="item.avatar" :size="36" />
|
||||
<text v-if="!!item.state">已准备</text>
|
||||
<text :style="{ opacity: !!item.state ? 1 : 0 }">已准备</text>
|
||||
</view>
|
||||
<button v-else hover-class="none" @click="chooseTeam(0)">
|
||||
<button v-else hover-class="none" @click="chooseTeam(1)">
|
||||
<image src="../static/add-grey.png" mode="widthFix" />
|
||||
</button>
|
||||
<text class="truncate">{{ item.name || "我要加入" }}</text>
|
||||
<button
|
||||
hover-class="none"
|
||||
v-if="item.id === user.id"
|
||||
@click="chooseTeam(2)"
|
||||
@click="chooseTeam(0)"
|
||||
>
|
||||
<image src="../static/close-grey.png" mode="widthFix" />
|
||||
</button>
|
||||
@@ -479,7 +473,7 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
.player .ready {
|
||||
background-color: #2c261fb3 !important;
|
||||
border-color: #a3793f66 !important;
|
||||
border: 1rpx solid #a3793f66 !important;
|
||||
color: #fed847 !important;
|
||||
}
|
||||
.team-mode > view > image:nth-child(2) {
|
||||
@@ -657,6 +651,7 @@ onBeforeUnmount(() => {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 14rpx;
|
||||
}
|
||||
.choose-side-left-item > button:last-child > image,
|
||||
.choose-side-right-item > button:first-child > image {
|
||||
@@ -677,7 +672,7 @@ onBeforeUnmount(() => {
|
||||
margin-top: -16rpx;
|
||||
position: relative;
|
||||
background-color: #2c261fb3;
|
||||
border-color: #a3793f66;
|
||||
border: 1rpx solid #a3793f66;
|
||||
color: #fed847;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -109,7 +109,11 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container :bgType="1" title="个人单组练习" :showBottom="!start && !scores.length">
|
||||
<Container
|
||||
:bgType="1"
|
||||
title="个人单组练习"
|
||||
:showBottom="!start && !scores.length"
|
||||
>
|
||||
<view>
|
||||
<TestDistance v-if="!practiseId" />
|
||||
<block v-if="practiseId">
|
||||
|
||||
@@ -162,23 +162,8 @@ onShow(async () => {
|
||||
} else {
|
||||
recoverData(result, { force: true });
|
||||
}
|
||||
// if (await isGameEnded(battleId.value)) return;
|
||||
// getCurrentGameAPI();
|
||||
// const refreshData = () => {
|
||||
// const lastAwakeTime = uni.getStorageSync("last-awake-time");
|
||||
// if (lastAwakeTime) {
|
||||
// getCurrentGameAPI();
|
||||
// } else {
|
||||
// clearInterval(refreshTimer.value);
|
||||
// }
|
||||
// };
|
||||
// refreshTimer.value = setInterval(refreshData, 2000);
|
||||
}
|
||||
});
|
||||
// onHide(() => {
|
||||
// if (refreshTimer.value) clearInterval(refreshTimer.value);
|
||||
// uni.setStorageSync("last-awake-time", Date.now());
|
||||
// });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user