1v1排位数据交互完善
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { ref, watch } from "vue";
|
||||
import BowTarget from "@/components/BowTarget.vue";
|
||||
import Avatar from "@/components/Avatar.vue";
|
||||
import { roundsName } from "@/constants";
|
||||
const props = defineProps({
|
||||
show: {
|
||||
type: Boolean,
|
||||
@@ -11,9 +12,50 @@ const props = defineProps({
|
||||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
});
|
||||
const selected = ref(0);
|
||||
const tabs = ["所有轮次", "决金箭", "第三轮", "第二轮", "第一轮"];
|
||||
const scores = ref([]);
|
||||
const tabs = ref(["所有轮次"]);
|
||||
const players = ref([]);
|
||||
const onClickTab = (index) => {
|
||||
selected.value = index;
|
||||
scores.value = [];
|
||||
if (index === 0) {
|
||||
Object.values(props.data.roundsData).forEach((round) => {
|
||||
Object.values(round).forEach((arrows) => {
|
||||
scores.value = [...scores.value, ...Object.values(arrows)];
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Object.values(props.data.roundsData[index]).forEach((arrows) => {
|
||||
scores.value = [...scores.value, ...Object.values(arrows)];
|
||||
});
|
||||
}
|
||||
};
|
||||
watch(
|
||||
() => props.data,
|
||||
(value) => {
|
||||
if (value.winner === 0) {
|
||||
players.value = [
|
||||
...Object.values(value.redPlayers),
|
||||
...Object.values(value.bluePlayers),
|
||||
];
|
||||
} else if (value.winner === 1) {
|
||||
players.value = [
|
||||
...Object.values(value.bluePlayers),
|
||||
...Object.values(value.redPlayers),
|
||||
];
|
||||
}
|
||||
Object.keys(value.roundsData).forEach((key) => {
|
||||
tabs.value.push(`第${roundsName[key]}轮`);
|
||||
});
|
||||
onClickTab(0);
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -28,35 +70,28 @@ const tabs = ["所有轮次", "决金箭", "第三轮", "第二轮", "第一轮"
|
||||
<view
|
||||
v-for="(tab, index) in tabs"
|
||||
:key="index"
|
||||
@click="() => (selected = index)"
|
||||
@click="() => onClickTab(index)"
|
||||
:class="selected === index ? 'selected-tab' : ''"
|
||||
>
|
||||
{{ tab }}
|
||||
</view>
|
||||
</view>
|
||||
<view :style="{ width: '95%' }">
|
||||
<BowTarget />
|
||||
<BowTarget :scores="scores" :showE="false" />
|
||||
</view>
|
||||
<view class="score-row">
|
||||
<Avatar src="../static/avatar.png" :borderColor="1" />
|
||||
<view class="score-row" v-for="(player, index) in players" :key="index">
|
||||
<Avatar
|
||||
:src="player.avatar"
|
||||
:borderColor="data.bluePlayers[player.playerId] ? 1 : 2"
|
||||
/>
|
||||
<view
|
||||
v-for="(score, index) in [7, 9, 7, 3, 8]"
|
||||
v-if="selected > 0"
|
||||
v-for="(score, index) in data.roundsData[selected][player.playerId]"
|
||||
:key="index"
|
||||
class="score-item"
|
||||
:style="{ width: '13vw', height: '13vw' }"
|
||||
>
|
||||
{{ score }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="score-row">
|
||||
<Avatar src="../static/avatar.png" :borderColor="2" />
|
||||
<view
|
||||
v-for="(score, index) in [7, 9, 7, 3, 8]"
|
||||
:key="index"
|
||||
class="score-item"
|
||||
:style="{ width: '13vw', height: '13vw' }"
|
||||
>
|
||||
{{ score }}
|
||||
{{ score.ringScore }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -88,7 +123,7 @@ const tabs = ["所有轮次", "决金箭", "第三轮", "第二轮", "第一轮"
|
||||
.container > view:first-child > view:last-child {
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top:32px;
|
||||
top: 32px;
|
||||
}
|
||||
.container > view:first-child > view:last-child > image {
|
||||
width: 40px;
|
||||
@@ -97,9 +132,15 @@ const tabs = ["所有轮次", "决金箭", "第三轮", "第二轮", "第一轮"
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
width: calc(100% - 20px);
|
||||
color: #fff9;
|
||||
padding-left: 15px;
|
||||
padding: 0 10px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.container > view:nth-child(2)::-webkit-scrollbar {
|
||||
width: 0;
|
||||
height: 0;
|
||||
color: transparent;
|
||||
}
|
||||
.container > view:nth-child(2) > view {
|
||||
border: 1px solid #fff9;
|
||||
@@ -107,6 +148,7 @@ const tabs = ["所有轮次", "决金箭", "第三轮", "第二轮", "第一轮"
|
||||
padding: 7px 10px;
|
||||
margin: 0 5px;
|
||||
font-size: 14px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.selected-tab {
|
||||
background-color: #fed847;
|
||||
|
||||
Reference in New Issue
Block a user