排位房间内容完善

This commit is contained in:
kron
2025-06-06 00:34:54 +08:00
parent 79ef6d978d
commit d1dc839e70
6 changed files with 48 additions and 47 deletions

View File

@@ -119,3 +119,9 @@ export const readyGameAPI = (battleId) => {
battleId, battleId,
}); });
}; };
export const getGameAPI = (battleId) => {
return request("POST", "/user/battle/detail", {
id: battleId,
});
};

View File

@@ -1,21 +1,10 @@
<script setup> <script setup>
import { ref } from "vue";
import CoachComment from "@/components/CoachComment.vue";
defineProps({ defineProps({
blueTeam: { roundResults: {
type: Array,
default: () => [],
},
redTeam: {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
}); });
const showComment = ref(false);
setTimeout(() => {
showComment.value = true;
}, 2000);
</script> </script>
<template> <template>
@@ -23,27 +12,30 @@ setTimeout(() => {
<image src="../static/battle-header.png" mode="widthFix" /> <image src="../static/battle-header.png" mode="widthFix" />
<view class="players"> <view class="players">
<view> <view>
<view v-for="(score, index) in blueTeam" :key="index"> <view v-for="(result, index) in roundResults" :key="index">
<text>Round {{ index + 1 }}</text> <text>Round {{ index + 1 }}</text>
<view> <view>
<text>{{ score }}</text> <text>{{
result.blueArrows
.map((item) => item.ring)
.reduce((last, next) => last + next, 0)
}}</text>
<text></text> <text></text>
</view> </view>
</view> </view>
</view> </view>
<view> <view>
<view v-for="(score, index) in redTeam" :key="index"> <view v-for="(result, index) in roundResults" :key="index">
<text>Round {{ index + 1 }}</text> <text>Round {{ index + 1 }}</text>
<view> <view>
<text>{{ score }}</text> <text>{{ result.redArrows
.map((item) => item.ring)
.reduce((last, next) => last + next, 0) }}</text>
<text></text> <text></text>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<CoachComment :show="showComment" :onClose="() => (showComment = false)">
第三轮射击结束
</CoachComment>
</view> </view>
</template> </template>
@@ -92,6 +84,7 @@ setTimeout(() => {
font-size: 14px; font-size: 14px;
} }
.players > view > view > view:last-child { .players > view > view > view:last-child {
font-size: 14px;
padding-right: 20px; padding-right: 20px;
} }
.players > view > view > view:last-child > text:first-child { .players > view > view > view:last-child > text:first-child {

View File

@@ -25,9 +25,10 @@ defineProps({
<style scoped> <style scoped>
.content { .content {
width: 100%; width: 100vw;
height: calc(100vh - 116px); height: calc(100vh - 116px);
overflow: auto; overflow-x: hidden;
overflow-y: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;

View File

@@ -114,6 +114,7 @@ defineProps({
margin: 0 10px; margin: 0 10px;
overflow: hidden; overflow: hidden;
width: 100px; width: 100px;
transition: all 0.3s linear;
} }
.avatar { .avatar {
width: 40px; width: 40px;

View File

@@ -1,6 +1,7 @@
<script setup> <script setup>
import { ref } from "vue"; import { ref, onMounted } from "vue";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import { getGameAPI } from "@/apis";
const battleId = ref(""); const battleId = ref("");
@@ -10,6 +11,10 @@ onLoad((options) => {
function exit() { function exit() {
uni.navigateBack(); uni.navigateBack();
} }
onMounted(async () => {
const result = await getGameAPI("BATTLE-1749121128909437828-799");
conosle.log(1111, result);
});
</script> </script>
<template> <template>
@@ -50,7 +55,7 @@ function exit() {
.tag { .tag {
position: absolute; position: absolute;
width: 32vw; width: 32vw;
top: 4%; top: 0;
right: 0; right: 0;
} }
.container > view { .container > view {

View File

@@ -6,14 +6,10 @@ import BowTarget from "@/components/BowTarget.vue";
import ShootProgress from "@/components/ShootProgress.vue"; import ShootProgress from "@/components/ShootProgress.vue";
import PlayersRow from "@/components/PlayersRow.vue"; import PlayersRow from "@/components/PlayersRow.vue";
import Timer from "@/components/Timer.vue"; import Timer from "@/components/Timer.vue";
import PlayerScore from "@/components/PlayerScore.vue"; import BattleFooter from "@/components/BattleFooter.vue";
import SButton from "@/components/SButton.vue"; import SButton from "@/components/SButton.vue";
import { matchGameAPI, readyGameAPI } from "@/apis"; import { matchGameAPI, readyGameAPI } from "@/apis";
import { MESSAGETYPES, roundsName } from "@/constants"; import { MESSAGETYPES, roundsName } from "@/constants";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { user } = storeToRefs(store);
const gameType = ref(0); const gameType = ref(0);
const teamSize = ref(0); const teamSize = ref(0);
const matching = ref(false); const matching = ref(false);
@@ -29,6 +25,12 @@ const currentShooterId = ref(0);
const tips = ref("即将开始..."); const tips = ref("即将开始...");
const seq = ref(0); const seq = ref(0);
const timerSeq = ref(0); const timerSeq = ref(0);
const roundResults = ref([
// {
// blueArrows: [{ ring: 2 }, { ring: 2 }],
// redArrows: [{ ring: 2 }, { ring: 3 }],
// },
]);
onLoad((options) => { onLoad((options) => {
gameType.value = options.gameType; gameType.value = options.gameType;
@@ -91,14 +93,13 @@ async function onReceiveMessage(content) {
scores.value = [msg.target]; scores.value = [msg.target];
} }
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) { if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
const result = msg.preRoundResult;
scores.value = []; scores.value = [];
currentShooterId.value = 0; currentShooterId.value = 0;
if ( if (result.currentRound > 0 && result.currentRound < totalRounds.value) {
msg.preRoundResult.currentRound > 0 &&
msg.preRoundResult.currentRound < totalRounds.value
) {
// 开始下一轮; // 开始下一轮;
currentRound.value = msg.preRoundResult.currentRound + 1; roundResults.value = result.roundResults;
currentRound.value = result.currentRound + 1;
} }
} }
if (msg.constructor === MESSAGETYPES.MatchOver) { if (msg.constructor === MESSAGETYPES.MatchOver) {
@@ -136,19 +137,16 @@ onUnmounted(() => {
:totalRound="totalRounds" :totalRound="totalRounds"
:scores="scores" :scores="scores"
/> />
<!-- <PlayerScore <BattleFooter
name="某某选手" v-if="roundResults.length > 0"
avatar="../static/avatar.png" :roundResults="roundResults"
:scores="[1, 4, 7, 4, 2, 2, 4, 4, 5, 8]" />
/> -->
<Timer :seq="timerSeq" :callBack="readyToGo" /> <Timer :seq="timerSeq" :callBack="readyToGo" />
</view> </view>
<view class="footer"> <SButton v-if="!battleId" :onClick="matching ? stopMatch : startMatch">{{
<SButton v-if="!battleId" :onClick="matching ? stopMatch : startMatch">{{ matching ? "取消匹配" : "开始匹配"
matching ? "取消匹配" : "开始匹配" }}</SButton>
}}</SButton> <SButton v-if="battleId && !start" :onClick="readyToGo">准备完毕</SButton>
<SButton v-if="battleId && !start" :onClick="readyToGo">准备完毕</SButton>
</view>
</Container> </Container>
</template> </template>
@@ -156,7 +154,4 @@ onUnmounted(() => {
.container { .container {
width: 100%; width: 100%;
} }
.footer {
margin: 25px 0;
}
</style> </style>