2025-08-13 16:44:25 +08:00
|
|
|
|
<script setup>
|
2025-11-10 13:43:25 +08:00
|
|
|
|
import { ref, watch, onMounted, computed } from "vue";
|
2025-08-13 16:44:25 +08:00
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
isRed: {
|
|
|
|
|
|
type: Boolean,
|
|
|
|
|
|
default: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
team: {
|
|
|
|
|
|
type: Array,
|
|
|
|
|
|
default: () => [],
|
|
|
|
|
|
},
|
2025-08-14 15:24:12 +08:00
|
|
|
|
currentShooterId: {
|
|
|
|
|
|
type: Number,
|
|
|
|
|
|
default: "",
|
|
|
|
|
|
},
|
2025-08-13 16:44:25 +08:00
|
|
|
|
});
|
2025-08-15 11:23:23 +08:00
|
|
|
|
const players = ref({});
|
2025-11-10 13:43:25 +08:00
|
|
|
|
const currentTeam = ref(false);
|
2025-08-15 11:23:23 +08:00
|
|
|
|
const firstName = ref("");
|
|
|
|
|
|
|
2025-11-10 13:43:25 +08:00
|
|
|
|
// 抽出判断:当前队伍且该玩家排序为 0(队伍首位)
|
|
|
|
|
|
const isFirst = (id) =>
|
|
|
|
|
|
currentTeam.value && ((players.value[id] || {}).sort || 0) === 0;
|
|
|
|
|
|
|
|
|
|
|
|
const getPos = (id) => {
|
|
|
|
|
|
const sort = (players.value[id] || {}).sort || 0;
|
|
|
|
|
|
if (currentTeam.value) {
|
|
|
|
|
|
return 30 * (sort + Math.ceil(sort / 2));
|
|
|
|
|
|
}
|
|
|
|
|
|
return sort * 40;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-15 11:23:23 +08:00
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
props.team.forEach((p, index) => {
|
|
|
|
|
|
players.value[p.id] = { sort: index, ...p };
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-08-13 16:44:25 +08:00
|
|
|
|
watch(
|
2025-08-14 15:24:12 +08:00
|
|
|
|
() => props.currentShooterId,
|
2025-08-13 16:44:25 +08:00
|
|
|
|
(newVal) => {
|
2025-08-15 11:23:23 +08:00
|
|
|
|
if (!newVal) return;
|
|
|
|
|
|
const index = props.team.findIndex((p) => p.id === newVal);
|
2025-11-10 13:43:25 +08:00
|
|
|
|
currentTeam.value = index >= 0;
|
2025-08-15 11:23:23 +08:00
|
|
|
|
if (index >= 0) {
|
|
|
|
|
|
const newPlayers = [...props.team];
|
|
|
|
|
|
const target = newPlayers.splice(index, 1)[0];
|
|
|
|
|
|
if (target) {
|
|
|
|
|
|
newPlayers.unshift(target);
|
|
|
|
|
|
firstName.value = target.name;
|
|
|
|
|
|
newPlayers.forEach((p, index) => {
|
|
|
|
|
|
players.value[p.id] = { sort: index, ...p };
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-14 15:24:12 +08:00
|
|
|
|
},
|
|
|
|
|
|
{ immediate: true }
|
2025-08-13 16:44:25 +08:00
|
|
|
|
);
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<view class="container">
|
2025-09-03 16:34:54 +08:00
|
|
|
|
<image
|
|
|
|
|
|
:src="isRed ? '../static/flag-red.png' : '../static/flag-blue.png'"
|
|
|
|
|
|
class="flag"
|
2025-11-08 10:57:37 +08:00
|
|
|
|
:style="{
|
|
|
|
|
|
[isRed ? 'left' : 'right']: '10rpx',
|
2025-11-10 13:43:25 +08:00
|
|
|
|
top: currentTeam ? '-44rpx' : '-30rpx',
|
2025-11-08 10:57:37 +08:00
|
|
|
|
}"
|
2025-09-03 16:34:54 +08:00
|
|
|
|
/>
|
2025-08-13 16:44:25 +08:00
|
|
|
|
<view
|
|
|
|
|
|
v-for="(item, index) in team"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
class="player"
|
|
|
|
|
|
:style="{
|
2025-11-10 13:43:25 +08:00
|
|
|
|
width: (isFirst(item.id) ? 80 : 60) + 'rpx',
|
|
|
|
|
|
height: (isFirst(item.id) ? 80 : 60) + 'rpx',
|
2025-08-15 11:23:23 +08:00
|
|
|
|
zIndex: team.length - ((players[item.id] || {}).sort || 0),
|
2025-11-10 13:43:25 +08:00
|
|
|
|
border: isFirst(item.id) ? '3rpx solid' : '2rpx solid',
|
|
|
|
|
|
borderColor: isRed ? '#ff6060' : '#5fadff',
|
|
|
|
|
|
top: isFirst(item.id) ? '0rpx' : '12rpx',
|
|
|
|
|
|
[isRed ? 'left' : 'right']: getPos(item.id) + 'rpx',
|
2025-08-13 16:44:25 +08:00
|
|
|
|
}"
|
|
|
|
|
|
>
|
|
|
|
|
|
<image :src="item.avatar || '../static/user-icon.png'" mode="widthFix" />
|
|
|
|
|
|
<text
|
2025-11-10 13:43:25 +08:00
|
|
|
|
v-if="isFirst(item.id)"
|
2025-08-13 16:44:25 +08:00
|
|
|
|
:style="{ backgroundColor: isRed ? '#ff6060' : '#5fadff' }"
|
|
|
|
|
|
>{{ isRed ? "红队" : "蓝队" }}</text
|
|
|
|
|
|
>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<text
|
2025-11-10 13:43:25 +08:00
|
|
|
|
v-if="currentTeam"
|
2025-08-13 16:44:25 +08:00
|
|
|
|
class="truncate"
|
|
|
|
|
|
:style="{
|
|
|
|
|
|
color: isRed ? '#ff6060' : '#5fadff',
|
2025-11-10 13:43:25 +08:00
|
|
|
|
[isRed ? 'left' : 'right']: '-4rpx',
|
2025-08-13 16:44:25 +08:00
|
|
|
|
}"
|
2025-08-15 11:23:23 +08:00
|
|
|
|
>{{ firstName }}</text
|
2025-08-13 16:44:25 +08:00
|
|
|
|
>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.container {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
width: 20vw;
|
2025-11-08 10:57:37 +08:00
|
|
|
|
height: 10rpx;
|
2025-09-03 16:34:54 +08:00
|
|
|
|
margin: 0 20rpx;
|
2025-08-13 16:44:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
.container > text {
|
|
|
|
|
|
position: absolute;
|
2025-11-10 13:43:25 +08:00
|
|
|
|
font-size: 20rpx;
|
2025-08-13 16:44:25 +08:00
|
|
|
|
text-align: center;
|
2025-11-10 13:43:25 +08:00
|
|
|
|
width: 80rpx;
|
2025-11-08 10:57:37 +08:00
|
|
|
|
bottom: -100rpx;
|
2025-08-13 16:44:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
.player {
|
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
overflow: hidden;
|
2025-11-10 13:43:25 +08:00
|
|
|
|
box-sizing: border-box;
|
2025-08-13 16:44:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
.player > image {
|
|
|
|
|
|
width: 100%;
|
2025-08-22 16:04:39 +08:00
|
|
|
|
min-height: 100%;
|
2025-08-13 16:44:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
.player > text {
|
|
|
|
|
|
position: absolute;
|
2025-11-08 10:57:37 +08:00
|
|
|
|
font-size: 16rpx;
|
2025-08-13 16:44:25 +08:00
|
|
|
|
text-align: center;
|
2025-11-10 13:43:25 +08:00
|
|
|
|
width: 80rpx;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
bottom: 0;
|
2025-08-13 16:44:25 +08:00
|
|
|
|
color: #fff;
|
|
|
|
|
|
}
|
2025-09-03 16:34:54 +08:00
|
|
|
|
.flag {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
width: 45rpx;
|
|
|
|
|
|
height: 45rpx;
|
2025-11-08 10:57:37 +08:00
|
|
|
|
transition: all 0.3s ease;
|
2025-09-03 16:34:54 +08:00
|
|
|
|
}
|
2025-08-13 16:44:25 +08:00
|
|
|
|
</style>
|