2025-05-01 16:36:24 +08:00
|
|
|
|
<script setup>
|
2025-05-16 15:56:54 +08:00
|
|
|
|
import { ref } from "vue";
|
2025-05-01 16:36:24 +08:00
|
|
|
|
import AppBackground from "@/components/AppBackground.vue";
|
2025-05-01 21:50:12 +08:00
|
|
|
|
import Header from "@/components/Header.vue";
|
2025-05-01 22:50:17 +08:00
|
|
|
|
import Guide from "@/components/Guide.vue";
|
2025-05-10 16:57:36 +08:00
|
|
|
|
import SButton from "@/components/SButton.vue";
|
2025-05-16 15:56:54 +08:00
|
|
|
|
import SModal from "@/components/SModal.vue";
|
|
|
|
|
|
import CreateRoom from "@/components/CreateRoom.vue";
|
2025-05-30 16:14:17 +08:00
|
|
|
|
import { getRoomAPI } from "@/apis";
|
2025-05-16 15:56:54 +08:00
|
|
|
|
|
|
|
|
|
|
const showModal = ref(false);
|
|
|
|
|
|
const warnning = ref("");
|
|
|
|
|
|
const roomNumber = ref("");
|
|
|
|
|
|
|
2025-05-30 16:14:17 +08:00
|
|
|
|
const enterRoom = async () => {
|
2025-05-16 15:56:54 +08:00
|
|
|
|
if (!roomNumber.value) {
|
|
|
|
|
|
warnning.value = "请输入房间号";
|
2025-05-30 16:14:17 +08:00
|
|
|
|
showModal.value = true;
|
2025-05-16 15:56:54 +08:00
|
|
|
|
} else {
|
2025-05-30 16:14:17 +08:00
|
|
|
|
const room = await getRoomAPI(roomNumber.value);
|
|
|
|
|
|
if (room.number) {
|
|
|
|
|
|
roomNumber.value = "";
|
|
|
|
|
|
uni.navigateTo({
|
2025-06-13 14:05:30 +08:00
|
|
|
|
url: `/pages/battle-room?roomNumber=${room.number}`,
|
2025-05-30 16:14:17 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
warnning.value = "查无此房";
|
|
|
|
|
|
showModal.value = true;
|
|
|
|
|
|
}
|
2025-05-16 15:56:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
const createRoom = () => {
|
|
|
|
|
|
warnning.value = "";
|
|
|
|
|
|
showModal.value = true;
|
|
|
|
|
|
};
|
2025-05-01 16:36:24 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<view>
|
|
|
|
|
|
<AppBackground />
|
2025-05-01 21:50:12 +08:00
|
|
|
|
<Header title="好友约战" />
|
2025-05-08 22:05:53 +08:00
|
|
|
|
<Guide>
|
|
|
|
|
|
<view class="guide-tips">
|
|
|
|
|
|
<text>约上朋友开几局,欢乐多,不寂寞</text>
|
|
|
|
|
|
<text>一起练升级更快,早日加入全国排位赛!</text>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</Guide>
|
2025-05-01 22:50:17 +08:00
|
|
|
|
<view class="founded-room">
|
|
|
|
|
|
<image src="../static/founded-room.png" mode="widthFix" />
|
|
|
|
|
|
<view>
|
2025-05-16 15:56:54 +08:00
|
|
|
|
<input placeholder="输入房间号" v-model="roomNumber" />
|
|
|
|
|
|
<view @click="enterRoom">进入房间</view>
|
2025-05-01 22:50:17 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="create-room">
|
|
|
|
|
|
<image src="../static/battle-bg.png" mode="widthFix" />
|
|
|
|
|
|
<view>
|
|
|
|
|
|
<image src="../static/avatar.png" mode="widthFix" />
|
|
|
|
|
|
<image src="../static/versus.png" mode="widthFix" />
|
|
|
|
|
|
<view>
|
|
|
|
|
|
<image src="../static/question-mark.png" mode="widthFix" />
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
2025-05-10 16:57:36 +08:00
|
|
|
|
<view>
|
2025-05-16 15:56:54 +08:00
|
|
|
|
<SButton width="70%" :rounded="30" :onClick="createRoom">
|
|
|
|
|
|
创建约战房
|
|
|
|
|
|
</SButton>
|
2025-05-10 16:57:36 +08:00
|
|
|
|
</view>
|
2025-05-01 22:50:17 +08:00
|
|
|
|
</view>
|
2025-05-16 15:56:54 +08:00
|
|
|
|
<SModal :show="showModal" :onClose="() => (showModal = false)">
|
|
|
|
|
|
<view v-if="warnning" class="warnning">
|
|
|
|
|
|
{{ warnning }}
|
|
|
|
|
|
</view>
|
2025-05-30 16:14:17 +08:00
|
|
|
|
<CreateRoom v-if="!warnning" :onConfirm="() => (showModal = false)" />
|
2025-05-16 15:56:54 +08:00
|
|
|
|
</SModal>
|
2025-05-01 16:36:24 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2025-05-01 22:50:17 +08:00
|
|
|
|
.founded-room {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
|
padding: 20px 0;
|
|
|
|
|
|
background-color: #54431d33;
|
|
|
|
|
|
border: 1px solid #54431d;
|
|
|
|
|
|
margin: 25px 15px;
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
padding: 15px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.founded-room > image {
|
|
|
|
|
|
width: 16vw;
|
|
|
|
|
|
}
|
|
|
|
|
|
.founded-room > view {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
margin: 25px 0;
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
border-radius: 30px;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
.founded-room > view > input {
|
|
|
|
|
|
width: 70%;
|
|
|
|
|
|
text-align: center;
|
2025-05-01 16:36:24 +08:00
|
|
|
|
font-size: 14px;
|
2025-05-07 23:34:15 +08:00
|
|
|
|
height: 40px;
|
2025-05-01 16:36:24 +08:00
|
|
|
|
}
|
2025-05-16 15:56:54 +08:00
|
|
|
|
.founded-room > view > view {
|
2025-05-01 22:50:17 +08:00
|
|
|
|
background-color: #fed847;
|
|
|
|
|
|
width: 30%;
|
2025-05-07 23:34:15 +08:00
|
|
|
|
line-height: 40px;
|
2025-05-01 22:50:17 +08:00
|
|
|
|
border-radius: 30px;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
padding: 3px 0;
|
|
|
|
|
|
font-weight: bold;
|
2025-05-10 16:57:36 +08:00
|
|
|
|
color: #000;
|
2025-05-16 15:56:54 +08:00
|
|
|
|
text-align: center;
|
2025-05-01 22:50:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
.create-room {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
margin: 25px 15px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.create-room > image:first-of-type {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
.create-room > view {
|
|
|
|
|
|
margin: 0 30px;
|
|
|
|
|
|
padding-top: 30px;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
}
|
|
|
|
|
|
.create-room > view > image:first-child {
|
|
|
|
|
|
width: 18vw;
|
|
|
|
|
|
transform: translateX(40%);
|
|
|
|
|
|
}
|
|
|
|
|
|
.create-room > view > image:nth-child(2) {
|
|
|
|
|
|
width: 36vw;
|
|
|
|
|
|
transform: translateX(55%) translateY(-40px);
|
|
|
|
|
|
}
|
|
|
|
|
|
.create-room > view > view:nth-child(3) {
|
|
|
|
|
|
width: 18vw;
|
|
|
|
|
|
height: 18vw;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
background-color: #ccc;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
transform: translate(280%, -75px);
|
|
|
|
|
|
}
|
|
|
|
|
|
.create-room > view > view:nth-child(3) > image {
|
2025-06-13 14:05:30 +08:00
|
|
|
|
width: 20px;
|
|
|
|
|
|
margin-right: 2px;
|
2025-05-01 22:50:17 +08:00
|
|
|
|
}
|
2025-05-10 16:57:36 +08:00
|
|
|
|
.create-room > view:last-child {
|
2025-05-01 22:50:17 +08:00
|
|
|
|
transform: translateY(-110%);
|
2025-05-01 16:36:24 +08:00
|
|
|
|
}
|
2025-05-16 15:56:54 +08:00
|
|
|
|
.warnning {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
color: #fff9;
|
|
|
|
|
|
}
|
2025-05-01 16:36:24 +08:00
|
|
|
|
</style>
|