ykt-wxapp/pages/home/team-head.vue

123 lines
3.8 KiB
Vue
Raw Permalink Normal View History

2026-01-19 18:52:18 +08:00
<template>
<view>
<view :style="{ height: statusBarHeight }" class="bg-primary"></view>
<view class="relative z-3 flex items-center px-15 py-12 bg-primary">
<view class="flex-shrink-0 mr-5">
<group-avatar :size="120" :avatarList="currentTeam ? currentTeam.avatarList : []" />
</view>
<view class="w-0 flex-grow ">
<view class="flex mb-10">
<view class="w-0 flex-grow truncate text-lg font-semibold text-white">{{ team.name }}</view>
<view v-if="teams.length > 1" class="flex-shinrk-0 flex items-center px-10 bg-white rounded-sm"
@click="showDropDown = true">
<view class="text-base">切换</view>
<uni-icons type="down" size="12"></uni-icons>
</view>
</view>
<view v-if="currentTeam" class="text-base text-white truncate">{{ currentTeam.corpName }}</view>
</view>
<view v-if="menuButtonInfo && menuButtonInfo.width > 0" class="flex-shrink-0"
:style="{ width: menuButtonInfo.width + 'px', height: menuButtonInfo.height + 'px' }">
</view>
</view>
<view class="relative">
<view v-if="showDropDown" class="team-dropdown py-12 bg-white shadow-lg">
<scroll-view scroll-y="true" style="max-height: 50vh;">
<view class="px-15">
<view v-for="item in teams" :key="item.teamId" class="mb-10 p-10 flex items-center bg-gray rounded-sm">
<view class="flex-shrink-0 mr-5">
<group-avatar :size="96" :avatarList="item.avatarList" />
</view>
<view class="w-0 flex-grow mr-5">
<view class="mb-5 text-lg font-semibold text-dark">{{ item.name }}</view>
<view class="text-base text-gray leading-normal">{{ item.corpName }}</view>
</view>
<view class="flex">
<image class="check-icon"
:src="team && team.teamId === item.teamId ? '/static/form/checked.svg' : '/static/form/unchecked.svg'">
</image>
</view>
</view>
</view>
</scroll-view>
</view>
</view>
<view v-if="team.teamTroduce" class="px-15 py-12 flex bg-white border-b shadow-lg">
<image class="laba-icon flex-shrink-0 mr-5" src="/static/laba.svg"></image>
<view class="w-0 flex-grow text-sm text-gray leading-normal line-clamp-2">{{ team.teamTroduce }} </view>
</view>
</view>
<view v-if="showDropDown" class="mask" @click="showDropDown = false"></view>
</template>
<script setup>
import { computed, ref, onMounted, watch } from 'vue';
import groupAvatar from '@/components/group-avatar.vue';
const statusBarHeight = ref('50px');
const menuButtonInfo = ref(null);
const showDropDown = ref(false)
const emits = defineEmits(['changeTeam']);
const props = defineProps({
team: {
type: Object,
default: () => ({})
},
teams: {
type: Array,
default: () => []
}
})
const currentTeam = computed(() => props.teams.find(i => props.team && i.teamId === props.team.teamId))
watch(() => props.teams, (teams) => {
if (teams.length && !(currentTeam.value && teams.some(i => i.teamId === currentTeam.value.teamId))) {
emits('changeTeam', teams[0])
}
})
onMounted(() => {
const win = uni.getWindowInfo();
if (win && win.statusBarHeight > 0) {
statusBarHeight.value = win.statusBarHeight + 'px';
}
menuButtonInfo.value = uni.getMenuButtonBoundingClientRect();
})
</script>
<style scoped>
.laba-icon {
width: 36rpx;
height: 36rpx;
}
.check-icon {
width: 40rpx;
height: 40rpx;
}
.mask {
position: fixed;
z-index: 2;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.3);
}
.z-3 {
z-index: 3;
}
.team-dropdown {
position: absolute;
left: 0;
right: 0;
top: 0;
z-index: 3;
border-bottom-left-radius: 16rpx;
border-bottom-right-radius: 16rpx;
}
</style>