新版房间1v1对战数据调试完成
This commit is contained in:
@@ -23,6 +23,7 @@ const warnning = ref("");
|
||||
const roomNumber = ref("");
|
||||
const data = ref({});
|
||||
const roomID = ref("");
|
||||
const loading = ref(false);
|
||||
|
||||
const enterRoom = debounce(async (number) => {
|
||||
if (!canEenter(user.value, device.value, online.value)) return;
|
||||
@@ -33,27 +34,32 @@ const enterRoom = debounce(async (number) => {
|
||||
if (!number) {
|
||||
warnning.value = "请输入房间号";
|
||||
showModal.value = true;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const room = await getRoomAPI(number);
|
||||
if (room.number) {
|
||||
const alreadyIn = room.members.find(
|
||||
(item) => item.userInfo.id === user.value.id
|
||||
);
|
||||
if (!alreadyIn) {
|
||||
const result = await joinRoomAPI(number);
|
||||
if (result.full) {
|
||||
warnning.value = "房间已满员";
|
||||
showModal.value = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: "/pages/battle-room?roomNumber=" + number,
|
||||
});
|
||||
} else {
|
||||
if (!room.number) {
|
||||
warnning.value = room.started ? "该房间对战已开始,无法加入" : "查无此房";
|
||||
showModal.value = true;
|
||||
return;
|
||||
}
|
||||
const alreadyIn = room.members.find(
|
||||
(item) => item.userInfo.id === user.value.id
|
||||
);
|
||||
if (!alreadyIn) {
|
||||
const result = await joinRoomAPI(number);
|
||||
if (result.full) {
|
||||
warnning.value = "房间已满员";
|
||||
showModal.value = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
loading.value = true;
|
||||
uni.navigateTo({
|
||||
url: "/pages/battle-room?roomNumber=" + number,
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
});
|
||||
const onCreateRoom = async () => {
|
||||
|
||||
Reference in New Issue
Block a user