This commit is contained in:
2025-05-06 15:01:24 +08:00
parent 693c9ccef7
commit 2366161259
9 changed files with 312 additions and 67 deletions
+197 -54
View File
@@ -5,38 +5,40 @@
<t-dropdown-item :options="actOptions" :value="selectActId"/>
</t-dropdown-menu>
<view class="content-container">
<view class="page-header">
<text class="page-title">团队报名</text>
<text class="page-subtitle">点击项目报名</text>
</view>
<!-- <view class="page-header">-->
<!-- <text class="page-title">团队报名</text>-->
<!-- <text class="page-subtitle">点击项目报名</text>-->
<!-- </view>-->
<!-- 项目列表 -->
<view class="project-cards">
<view
v-for="project in itemOptions"
:key="project.id"
class="project-card"
:class="{'project-card--registered': registrationStatus.get(project.id)?.length}"
@click="selectProject(project)"
>
<view class="project-card__content">
<view class="project-card__title">{{ project.name }}</view>
<view class="project-card__desc">{{ project.description }}</view>
</view>
<view class="project-card__status">
<t-tag v-if="registrationStatus.get(project.id)?.length" theme="success" variant="light-outline">
已报名 {{ registrationStatus.get(project.id)?.length }}人
</t-tag>
<view v-else class="project-card__action">
<t-icon name="chevron-right" color="#999"/>
<!-- 项目列表 -->
<view class="project-cards">
<view
v-for="project in itemOptions"
:key="project.id"
class="project-card"
:class="{'project-card--registered': registrationStatus.get(project.id)?.length}"
>
<view class="project-card__content">
<t-image :src=config.fileDomain+project.img shape="round"
class="project-card__image" fit="fill"/>
<view class="project-card__title">{{ project.name }}</view>
<div style="display: flex;justify-content: flex-end;margin-top: 10px;">
<t-button size="small" class="project-card__button" @click="openDesc(project)">项目介绍</t-button>
<t-button size="small" @click="selectProject(project)" class="project-card__button"> 活动报名 {{
registrationStatus.get(project.id)?.length ? registrationStatus.get(project.id)?.length : 0
}}人
</t-button>
</div>
<!-- <t-tag v-if="registrationStatus.get(project.id)?.length" theme="success" variant="light-outline">
已报名 {{ registrationStatus.get(project.id)?.length }}人
</t-tag>-->
</view>
</view>
<!-- <view v-if="registrationStatus.get(project.id)?.length" class="project-card__checkmark">
<t-icon name="check" color="#52c41a"/>
</view>-->
</view>
</view>
</view>
</template>
<view v-else style="flex: 1;display: flex;justify-content: center;align-items: center">
<t-empty v-if="actOptions && actOptions.length === 0"
@@ -46,6 +48,45 @@
</t-empty>
</view>
<t-popup v-model:visible="showDescPicker" placement="bottom" destroy-on-close>
<view class="member-picker">
<view class="picker-header">
<text class="picker-title">项目介绍</text>
<t-icon name="close" @click="showDescPicker = false"/>
</view>
<view>
<view class="event-item-header">
<text class="event-item-name">{{ team.name }}</text>
</view>
<view class="event-item-content">
<t-image :src=config.fileDomain+team.img shape="round"
class="event-item-image" fit="fill"/>
<!-- 项目信息区域 -->
<view class="event-item-info">
<view class="event-item-section">
<view class="event-item-section-title">
<t-icon name="flag" size="16px" color="var(--td-brand-color-5)"/>
<text>活动形式</text>
</view>
<view class="event-item-section-content">{{ team.form }}</view>
</view>
<view class="event-item-section">
<view class="event-item-section-title">
<t-icon name="chart-bar" size="16px" color="var(--td-brand-color-5)"/>
<text>评分规则</text>
</view>
<view class="event-item-section-content">{{ team.rule }}</view>
</view>
</view>
</view>
</view>
</view>
</t-popup>
<t-popup v-model:visible="showMemberPicker" placement="bottom" destroy-on-close>
<view class="member-picker">
<view class="picker-header">
@@ -60,7 +101,7 @@
此项目是团队协作需要全体成员参与
</view>
<view v-else>
此项目需【{{itemOptions.find(p => p.id === selectedItemId)?.num}}】名成员参与
此项目需【{{ itemOptions.find(p => p.id === selectedItemId)?.num }}】名成员参与
</view>
</view>
@@ -81,10 +122,22 @@
</view>
</t-checkbox-group>
</view>
<view class="picker-footer"v-if="isSelfLeader">
<t-button block theme="primary" @click="submitRegistration">
确认报名 ({{ selectedMemberIds.length }}人)
</t-button>
<view class="picker-footer" v-if="isSelfLeader">
<t-row gutter="20">
<t-col span="12">
<t-button block theme="primary" @click="cancelRegistration"
:disabled="!selectedMemberList.filter(v => v.itemId === team.id).map(v => v.userId).length">
取消报名
</t-button>
</t-col>
<t-col span="12">
<t-button block theme="primary" style="margin-left: 5px;" @click="submitRegistration">
确认报名 ({{ selectedMemberIds.length }}人)
</t-button>
</t-col>
</t-row>
</view>
</view>
</t-popup>
@@ -97,6 +150,7 @@ import {useRequest} from '@/utils/request';
import {Dialog, Toast} from 'tdesign-mobile-vue';
import {onLoad} from '@dcloudio/uni-app';
import {useUserStore} from "@/store";
import {config} from "@/utils/config";
const request = useRequest();
const userStore = useUserStore();
@@ -106,23 +160,7 @@ const actOptions = ref([])
// 选中的活动ID
const selectActId = ref(null);
// 项目列表数据
const itemOptions = ref([
{
id: 1,
name: '篮球比赛',
description: '3v3篮球友谊赛'
},
{
id: 2,
name: '足球比赛',
description: '5人制足球赛'
},
{
id: 3,
name: '羽毛球比赛',
description: '双打友谊赛'
}
]);
const itemOptions = ref([]);
// 选中的项目ID
const selectedItemId = ref(null);
// 团队成员列表
@@ -147,6 +185,14 @@ const selectedMemberIds = ref([]);
// 成员选择弹窗显示状态
const showMemberPicker = ref(false);
// 描述选择弹窗显示状态
const showDescPicker = ref(false);
const openDesc = (project) => {
team.value = project
showDescPicker.value = true
}
// 获取活动列表
async function listActs() {
@@ -192,7 +238,7 @@ async function listTeamUser() {
const {code, data, msg} = await request.get('/client/item/list-team-user/' + selectActId.value)
if (code === 0) {
teamMembers.value = data;
isSelfLeader.value = data.find(t => t.userId===userStore?.userInfo.id)?.isLeader
isSelfLeader.value = data.find(t => t.userId === userStore?.userInfo.id)?.isLeader
} else {
Toast.error(msg)
}
@@ -222,10 +268,10 @@ const team = ref({})
// 选择项目
const selectProject = (project) => {
selectedItemId.value = project.id;
team.value=project
if (project.isTeamApply){
team.value = project
if (project.isTeamApply) {
selectedMemberIds.value = teamMembers.value.map(v => v.userId)
}else{
} else {
selectedMemberIds.value = selectedMemberList.value.filter(v => v.itemId === project.id).map(v => v.userId)
}
showMemberPicker.value = true;
@@ -245,7 +291,23 @@ const getApplyUsers = async () => {
Toast.error(e.message)
}
}
// 取消报名
const cancelRegistration = async () => {
try {
let data = {}
data.activityId = selectActId.value
data.itemId = selectedItemId.value
const {code, msg} = await useRequest().post('/client/item/cancel-team-sign-up/' ,{...data})
if (code === 0) {
Toast.success('取消报名成功')
showMemberPicker.value = false;
await getApplyUsers();
fetchRegistrationStatus();
}
} catch (e) {
console.log(e)
}
};
// 提交报名 - 使用静态数据模拟
const submitRegistration = async () => {
@@ -312,6 +374,71 @@ const submitRegistration = async () => {
margin-bottom: 24px;
}
.event-item-header {
display: flex;
align-items: center;
padding: 20rpx 24rpx;
background-color: #f9f9f9;
border-left: 8rpx solid var(--td-brand-color-5);
position: relative;
}
.event-item-name {
color: #333333;
font-size: 30rpx;
font-weight: 500;
flex: 1;
margin-right: 8rpx;
position: relative;
z-index: 1;
}
.event-item-content {
padding: 0;
}
.event-item-image {
height: 300rpx;
display: block;
}
.event-item-info {
padding: 24rpx;
}
.event-item-section {
margin-bottom: 24rpx;
&:last-child {
margin-bottom: 0;
}
}
.event-item-section-title {
display: flex;
align-items: center;
margin-bottom: 12rpx;
.t-icon {
margin-right: 8rpx;
}
text {
font-size: 28rpx;
font-weight: 500;
color: #333333;
}
}
.event-item-section-content {
font-size: 28rpx;
color: #666666;
line-height: 1.5;
word-break: break-all;
padding-left: 32rpx;
}
.project-card {
background-color: #fff;
border-radius: 12px;
@@ -323,6 +450,22 @@ const submitRegistration = async () => {
position: relative;
overflow: hidden;
.project-card__image {
height: 150px !important;
}
.project-card__title {
font-size: 15px !important;
margin: 10px;
}
.project-card__button {
margin-left: 10px;
background-color: #0052D9;
color: #ffffff;
}
&:active {
transform: scale(0.98);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);