页面调整
This commit is contained in:
@@ -150,8 +150,8 @@ const simulShoot2 = async () => {
|
|||||||
v-if="blueScores.length && showRoundTips && showLatestArrow"
|
v-if="blueScores.length && showRoundTips && showLatestArrow"
|
||||||
class="round-tip fade-in-out"
|
class="round-tip fade-in-out"
|
||||||
:style="{
|
:style="{
|
||||||
left: calcRealX(scores[scores.length - 1].x, 70),
|
left: calcRealX(blueScores[blueScores.length - 1].x, 70),
|
||||||
top: calcRealY(scores[scores.length - 1].y, 100),
|
top: calcRealY(blueScores[blueScores.length - 1].y, 100),
|
||||||
}"
|
}"
|
||||||
>{{ blueScores[blueScores.length - 1].ring }}<text>环</text></view
|
>{{ blueScores[blueScores.length - 1].ring }}<text>环</text></view
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ defineProps({
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
done: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const rowCount = new Array(6).fill(0);
|
const rowCount = new Array(6).fill(0);
|
||||||
</script>
|
</script>
|
||||||
@@ -23,11 +19,11 @@ const rowCount = new Array(6).fill(0);
|
|||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<image
|
<image
|
||||||
:style="{ opacity: done ? 1 : 0 }"
|
:style="{ opacity: scores.length === 12 ? 1 : 0 }"
|
||||||
src="../static/checked-green.png"
|
src="../static/checked-green.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
<image :src="avatar" mode="widthFix" />
|
<image :src="avatar || '../static/user-icon.png'" mode="widthFix" />
|
||||||
<text>{{ name }}</text>
|
<text>{{ name }}</text>
|
||||||
<view>
|
<view>
|
||||||
<view>
|
<view>
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ const rowCount = new Array(6).fill(0);
|
|||||||
/>
|
/>
|
||||||
<view v-if="rank > 3" class="rank-view">{{ rank }}</view>
|
<view v-if="rank > 3" class="rank-view">{{ rank }}</view>
|
||||||
<image
|
<image
|
||||||
:src="avatar"
|
:src="avatar || '../static/user-icon.png'"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
:style="{ borderColor: topThreeColors[rank - 1] || '#fff' }"
|
:style="{ borderColor: topThreeColors[rank - 1] || '#fff' }"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -57,16 +57,16 @@ onUnmounted(() => {
|
|||||||
<text>第{{ round }}轮射击结束</text>
|
<text>第{{ round }}轮射击结束</text>
|
||||||
<block v-if="!isFinal">
|
<block v-if="!isFinal">
|
||||||
<view class="point-view1">
|
<view class="point-view1">
|
||||||
<text>本轮红队</text>
|
<text>本轮蓝队</text>
|
||||||
<text>{{
|
<text>{{
|
||||||
(roundData.redArrows || []).reduce(
|
(roundData.blueArrows || []).reduce(
|
||||||
(last, next) => last + next.ring,
|
(last, next) => last + next.ring,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
}}</text>
|
}}</text>
|
||||||
<text>环,蓝队</text>
|
<text>环,红队</text>
|
||||||
<text>{{
|
<text>{{
|
||||||
(roundData.blueArrows || []).reduce(
|
(roundData.redArrows || []).reduce(
|
||||||
(last, next) => last + next.ring,
|
(last, next) => last + next.ring,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, onUnmounted } from "vue";
|
import { ref, watch, onMounted, onUnmounted } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import PlayerSeats from "@/components/PlayerSeats.vue";
|
import PlayerSeats from "@/components/PlayerSeats.vue";
|
||||||
@@ -34,6 +34,7 @@ const redTeam = ref([]);
|
|||||||
const blueTeam = ref([]);
|
const blueTeam = ref([]);
|
||||||
const currentShooterId = ref(0);
|
const currentShooterId = ref(0);
|
||||||
const players = ref([]);
|
const players = ref([]);
|
||||||
|
const playersSorted = ref([]);
|
||||||
const currentRound = ref(1);
|
const currentRound = ref(1);
|
||||||
const totalRounds = ref(0);
|
const totalRounds = ref(0);
|
||||||
const start = ref(false);
|
const start = ref(false);
|
||||||
@@ -54,6 +55,21 @@ const halfTimeTip = ref(false);
|
|||||||
const isFinalShoot = ref(false);
|
const isFinalShoot = ref(false);
|
||||||
const total = ref(90);
|
const total = ref(90);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [players.value, playersScores.value],
|
||||||
|
([n_players, n_scores]) => {
|
||||||
|
if (n_players.length) {
|
||||||
|
playersSorted.value = Object.keys(n_scores)
|
||||||
|
.sort((a, b) => n_scores[b].length - n_scores[a].length)
|
||||||
|
.map((pid) => n_players.find((p) => p.id == pid));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deep: true, // 添加深度监听
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (options.battleId) {
|
if (options.battleId) {
|
||||||
const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
|
const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
|
||||||
@@ -243,6 +259,26 @@ async function onReceiveMessage(messages = []) {
|
|||||||
const isRed = redTeam.value.find((item) => item.id === msg.userId);
|
const isRed = redTeam.value.find((item) => item.id === msg.userId);
|
||||||
if (isRed) scores.value = [msg.target];
|
if (isRed) scores.value = [msg.target];
|
||||||
else blueScores.value = [msg.target];
|
else blueScores.value = [msg.target];
|
||||||
|
if (roundResults.value[currentRound.value - 1]) {
|
||||||
|
if (isRed && roundResults.value[currentRound.value - 1].redArrows) {
|
||||||
|
roundResults.value[currentRound.value - 1].redArrows.push(
|
||||||
|
msg.target
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
!isRed &&
|
||||||
|
roundResults.value[currentRound.value - 1].blueArrows
|
||||||
|
) {
|
||||||
|
roundResults.value[currentRound.value - 1].blueArrows.push(
|
||||||
|
msg.target
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
roundResults.value.push({
|
||||||
|
redArrows: isRed ? [msg.target] : [],
|
||||||
|
blueArrows: isRed ? [] : [msg.target],
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (room.value.battleType === 2) {
|
if (room.value.battleType === 2) {
|
||||||
scores.value.push(msg.target);
|
scores.value.push(msg.target);
|
||||||
@@ -261,7 +297,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
currentRedPoint.value = result.redScore;
|
currentRedPoint.value = result.redScore;
|
||||||
bluePoints.value += result.blueScore;
|
bluePoints.value += result.blueScore;
|
||||||
redPoints.value += result.redScore;
|
redPoints.value += result.redScore;
|
||||||
roundResults.value = result.roundResults;
|
// roundResults.value = result.roundResults;
|
||||||
currentRound.value = result.currentRound + 1;
|
currentRound.value = result.currentRound + 1;
|
||||||
if (result.currentRound < 5) showRoundTip.value = true;
|
if (result.currentRound < 5) showRoundTip.value = true;
|
||||||
}
|
}
|
||||||
@@ -419,14 +455,11 @@ onUnmounted(() => {
|
|||||||
/>
|
/>
|
||||||
<PlayerScore
|
<PlayerScore
|
||||||
v-if="room.battleType === 2"
|
v-if="room.battleType === 2"
|
||||||
v-for="(player, index) in players"
|
v-for="(player, index) in playersSorted"
|
||||||
:key="index"
|
:key="index"
|
||||||
:name="player.name"
|
:name="player.name"
|
||||||
:avatar="player.avatar"
|
:avatar="player.avatar"
|
||||||
:scores="playersScores[player.id] || []"
|
:scores="playersScores[player.id] || []"
|
||||||
:done="
|
|
||||||
playersScores[player.id] && playersScores[player.id].length === 12
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<Timer :seq="timerSeq" />
|
<Timer :seq="timerSeq" />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, onUnmounted } from "vue";
|
import { ref, watch, onMounted, onUnmounted } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import BowTarget from "@/components/BowTarget.vue";
|
import BowTarget from "@/components/BowTarget.vue";
|
||||||
@@ -32,10 +32,26 @@ const tips = ref("即将开始...");
|
|||||||
const seq = ref(0);
|
const seq = ref(0);
|
||||||
const timerSeq = ref(0);
|
const timerSeq = ref(0);
|
||||||
const players = ref([]);
|
const players = ref([]);
|
||||||
|
const playersSorted = ref([]);
|
||||||
const playersScores = ref({});
|
const playersScores = ref({});
|
||||||
const halfTimeTip = ref(false);
|
const halfTimeTip = ref(false);
|
||||||
const onComplete = ref(null);
|
const onComplete = ref(null);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [players.value, playersScores.value],
|
||||||
|
([n_players, n_scores]) => {
|
||||||
|
if (n_players.length) {
|
||||||
|
playersSorted.value = Object.keys(n_scores)
|
||||||
|
.sort((a, b) => n_scores[b].length - n_scores[a].length)
|
||||||
|
.map((pid) => n_players.find((p) => p.id == pid));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deep: true, // 添加深度监听
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (options.battleId) {
|
if (options.battleId) {
|
||||||
const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
|
const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
|
||||||
@@ -188,14 +204,11 @@ onUnmounted(() => {
|
|||||||
<view :style="{ paddingBottom: '20px' }">
|
<view :style="{ paddingBottom: '20px' }">
|
||||||
<PlayerScore
|
<PlayerScore
|
||||||
v-if="start"
|
v-if="start"
|
||||||
v-for="(player, index) in players"
|
v-for="(player, index) in playersSorted"
|
||||||
:key="index"
|
:key="index"
|
||||||
:name="player.name"
|
:name="player.name"
|
||||||
:avatar="player.avatar"
|
:avatar="player.avatar"
|
||||||
:scores="playersScores[player.id] || []"
|
:scores="playersScores[player.id] || []"
|
||||||
:done="
|
|
||||||
playersScores[player.id] && playersScores[player.id].length === 12
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<Timer :seq="timerSeq" :callBack="readyToGo" />
|
<Timer :seq="timerSeq" :callBack="readyToGo" />
|
||||||
|
|||||||
@@ -140,6 +140,21 @@ async function onReceiveMessage(messages = []) {
|
|||||||
const isRed = redTeam.value.find((item) => item.id === msg.userId);
|
const isRed = redTeam.value.find((item) => item.id === msg.userId);
|
||||||
if (isRed) scores.value = [msg.target];
|
if (isRed) scores.value = [msg.target];
|
||||||
else blueScores.value = [msg.target];
|
else blueScores.value = [msg.target];
|
||||||
|
if (roundResults.value[currentRound.value - 1]) {
|
||||||
|
if (isRed && roundResults.value[currentRound.value - 1].redArrows) {
|
||||||
|
roundResults.value[currentRound.value - 1].redArrows.push(msg.target);
|
||||||
|
}
|
||||||
|
if (!isRed && roundResults.value[currentRound.value - 1].blueArrows) {
|
||||||
|
roundResults.value[currentRound.value - 1].blueArrows.push(
|
||||||
|
msg.target
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
roundResults.value.push({
|
||||||
|
redArrows: isRed ? [msg.target] : [],
|
||||||
|
blueArrows: isRed ? [] : [msg.target],
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||||
const result = msg.preRoundResult;
|
const result = msg.preRoundResult;
|
||||||
@@ -150,7 +165,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
currentRedPoint.value = result.redScore;
|
currentRedPoint.value = result.redScore;
|
||||||
bluePoints.value += result.blueScore;
|
bluePoints.value += result.blueScore;
|
||||||
redPoints.value += result.redScore;
|
redPoints.value += result.redScore;
|
||||||
roundResults.value = result.roundResults;
|
// roundResults.value = result.roundResults;
|
||||||
currentRound.value = result.currentRound + 1;
|
currentRound.value = result.currentRound + 1;
|
||||||
if (result.currentRound < 5) showRoundTip.value = true;
|
if (result.currentRound < 5) showRoundTip.value = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user