Files
shoot-miniprograms/src/components/PlayersRow.vue

133 lines
2.7 KiB
Vue
Raw Normal View History

2025-05-16 15:56:54 +08:00
<script setup>
defineProps({
avatar: {
type: String,
default: "",
},
blueTeam: {
type: Array,
default: () => [],
},
redTeam: {
type: Array,
default: () => [],
},
2025-06-05 21:32:51 +08:00
currentShooterId: {
type: Number,
default: 0,
},
2025-05-16 15:56:54 +08:00
});
</script>
<template>
<view class="container">
<image v-if="avatar" class="avatar" :src="avatar" mode="widthFix" />
2025-06-05 21:32:51 +08:00
<view
v-if="blueTeam.length && redTeam.length"
:style="{ height: 20 + blueTeam.length * 20 + 'px' }"
>
2025-05-16 15:56:54 +08:00
<view
2025-06-05 21:32:51 +08:00
v-for="(player, index) in blueTeam"
2025-05-16 15:56:54 +08:00
:key="index"
:style="{
top: index * 20 + 'px',
zIndex: blueTeam.length - index,
left: 0,
}"
>
<image
class="avatar"
2025-06-05 21:32:51 +08:00
:src="player.avatar"
2025-05-16 15:56:54 +08:00
mode="widthFix"
:style="{
2025-06-05 21:32:51 +08:00
borderColor: currentShooterId === player.id ? '#5fadff' : '#fff',
2025-05-16 15:56:54 +08:00
}"
/>
<text
:style="{
2025-06-05 21:32:51 +08:00
color: currentShooterId === player.id ? '#5fadff' : '#fff',
fontSize: currentShooterId === player.id ? 16 : 12 + 'px',
2025-05-16 15:56:54 +08:00
}"
>
2025-06-05 21:32:51 +08:00
{{ player.name }}
2025-05-16 15:56:54 +08:00
</text>
</view>
</view>
<view
v-if="!avatar"
:style="{
2025-06-05 21:32:51 +08:00
height: 20 + redTeam.length * 20 + 'px',
2025-05-16 15:56:54 +08:00
}"
>
<view
2025-06-05 21:32:51 +08:00
v-for="(player, index) in redTeam"
2025-05-16 15:56:54 +08:00
:key="index"
:style="{
top: index * 20 + 'px',
2025-06-05 21:32:51 +08:00
zIndex: redTeam.length - index,
2025-05-16 15:56:54 +08:00
right: 0,
}"
>
<text
:style="{
2025-06-05 21:32:51 +08:00
color: currentShooterId === player.id ? '#ff6060' : '#fff',
fontSize: currentShooterId === player.id ? 16 : 12 + 'px',
textAlign: 'right',
2025-05-16 15:56:54 +08:00
}"
>
2025-06-05 21:32:51 +08:00
{{ player.name }}
2025-05-16 15:56:54 +08:00
</text>
<image
class="avatar"
2025-06-05 21:32:51 +08:00
:src="player.avatar"
2025-05-16 15:56:54 +08:00
mode="widthFix"
:style="{
2025-06-05 21:32:51 +08:00
borderColor: currentShooterId === player.id ? '#ff6060' : '#fff',
2025-05-16 15:56:54 +08:00
}"
/>
</view>
</view>
</view>
</template>
<style scoped>
.container {
width: calc(100% - 30px);
margin: 15px;
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.container > view {
width: 50%;
position: relative;
}
.container > view > view {
position: absolute;
top: -20px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s linear;
}
.container > view > view > text {
margin: 0 10px;
2025-06-05 21:32:51 +08:00
overflow: hidden;
width: 100px;
2025-05-16 15:56:54 +08:00
}
.avatar {
width: 40px;
height: 40px;
min-width: 40px;
min-height: 40px;
border: 1px solid #fff;
border-radius: 50%;
}
.red-avatar {
border: 1px solid #ff6060;
}
.blue-avatar {
border: 1px solid #5fadff;
}
</style>