添加X环显示,比赛过程完善
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
<script setup>
|
||||
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||
import { onShow, onLoad, onShareAppMessage } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import PlayerSeats from "@/components/PlayerSeats.vue";
|
||||
import Guide from "@/components/Guide.vue";
|
||||
import SButton from "@/components/SButton.vue";
|
||||
import SModal from "@/components/SModal.vue";
|
||||
import Avatar from "@/components/Avatar.vue";
|
||||
import {
|
||||
getRoomAPI,
|
||||
@@ -16,7 +15,6 @@ import {
|
||||
getReadyAPI,
|
||||
kickPlayerAPI,
|
||||
} from "@/apis";
|
||||
|
||||
import { MESSAGETYPES, MESSAGETYPESV2 } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
@@ -31,8 +29,6 @@ const players = ref([]);
|
||||
const blueTeam = ref([]);
|
||||
const redTeam = ref([]);
|
||||
|
||||
const showModal = ref(false);
|
||||
const battleType = ref(0);
|
||||
const ready = ref(false);
|
||||
const allReady = ref(false);
|
||||
const timer = ref(null);
|
||||
@@ -43,7 +39,6 @@ async function refreshRoomData() {
|
||||
const result = await getRoomAPI(roomNumber.value);
|
||||
if (result.started) return;
|
||||
room.value = result;
|
||||
battleType.value = result.battleType;
|
||||
owner.value = {};
|
||||
opponent.value = {};
|
||||
const members = result.members || [];
|
||||
@@ -235,15 +230,15 @@ onBeforeUnmount(() => {
|
||||
<view class="battle-guide">
|
||||
<view class="guide-tips">
|
||||
<text>弓箭手们,人都到齐了吗?</text>
|
||||
<text v-if="battleType === 1">{{
|
||||
<text v-if="room.battleType === 1">{{
|
||||
`${room.count / 2}v${room.count / 2}比赛即将开始!`
|
||||
}}</text>
|
||||
<text v-if="battleType === 2">大乱斗即将开始! </text>
|
||||
<text v-if="room.battleType === 2">大乱斗即将开始! </text>
|
||||
</view>
|
||||
<button hover-class="none" open-type="share">邀请</button>
|
||||
</view>
|
||||
</Guide>
|
||||
<view v-if="battleType === 1 && room.count === 2" class="team-mode">
|
||||
<view v-if="room.battleType === 1 && room.count === 2" class="team-mode">
|
||||
<image
|
||||
src="https://static.shelingxingqiu.com/attachment/2025-08-05/dbua9nuf5fyeph7cxi.png"
|
||||
mode="widthFix"
|
||||
@@ -272,9 +267,9 @@ onBeforeUnmount(() => {
|
||||
:style="{ transform: 'translateY(60px)' }"
|
||||
>
|
||||
<Avatar :src="opponent.avatar" :size="60" />
|
||||
<text :class="{ ready: opponent.ready }">{{
|
||||
opponent.ready ? "已准备" : ""
|
||||
}}</text>
|
||||
<text class="ready" :style="{ opacity: opponent.ready ? 1 : 0 }">
|
||||
已准备
|
||||
</text>
|
||||
<text>{{ opponent.name }}</text>
|
||||
<button
|
||||
v-if="owner.id === user.id"
|
||||
@@ -290,7 +285,7 @@ onBeforeUnmount(() => {
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<block v-if="battleType === 1 && room.count >= 4">
|
||||
<block v-if="room.battleType === 1 && room.count >= 4">
|
||||
<view class="all-players">
|
||||
<image
|
||||
src="https://static.shelingxingqiu.com/attachment/2025-08-13/dc0x1p59iab6cvbhqc.png"
|
||||
@@ -372,60 +367,22 @@ onBeforeUnmount(() => {
|
||||
</view>
|
||||
</block>
|
||||
<PlayerSeats
|
||||
v-if="battleType === 2"
|
||||
v-if="room.battleType === 2"
|
||||
:total="room.count || 10"
|
||||
:players="players"
|
||||
:removePlayer="removePlayer"
|
||||
/>
|
||||
<view>
|
||||
<!-- <SButton
|
||||
v-if="user.id === owner.id && battleType === 1 && room.count === 2"
|
||||
:disabled="!opponent.id"
|
||||
:onClick="startGame"
|
||||
>进入对战</SButton
|
||||
>
|
||||
<SButton
|
||||
v-if="user.id === owner.id && battleType === 2"
|
||||
:disabled="players.length < 3"
|
||||
:onClick="startGame"
|
||||
>进入大乱斗</SButton
|
||||
>
|
||||
<SButton
|
||||
v-if="user.id === owner.id && battleType === 1 && room.count >= 4"
|
||||
:disabled="
|
||||
players.some((p) => p.groupType === undefined || p.groupType === 2)
|
||||
"
|
||||
:onClick="startGame"
|
||||
>开启对局</SButton
|
||||
>
|
||||
<SButton v-if="user.id !== owner.id" disabled>等待房主开启对战</SButton> -->
|
||||
<SButton :disabled="ready" :onClick="getReady">{{
|
||||
allReady.value
|
||||
? "即将进入对局..."
|
||||
: owner.id === user.id
|
||||
: owner.id === user.id && (room.members || []).length > 2
|
||||
? "开始对局"
|
||||
: "我准备好了"
|
||||
}}</SButton>
|
||||
<text class="tips">所有人准备后自动开始游戏。</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <SModal
|
||||
:show="showModal"
|
||||
:onClose="() => (showModal = false)"
|
||||
height="520rpx"
|
||||
>
|
||||
<view class="btns">
|
||||
<SButton :onClick="exitRoom" width="200px" :rounded="20">
|
||||
暂时离开
|
||||
</SButton>
|
||||
<block v-if="owner.id === user.id">
|
||||
<view :style="{ height: '20px' }"></view>
|
||||
<SButton :onClick="destroyRoom" width="200px" :rounded="20">
|
||||
解散房间
|
||||
</SButton>
|
||||
</block>
|
||||
</view>
|
||||
</SModal> -->
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user