feat(registration): 支持集体项目报名
- 修改event-register页面支持集体项目 - 根据项目类型(个人/集体)显示不同选择界面 - 添加集体API到athlete.js - 集体项目报名时选择集体而非选手
This commit is contained in:
@@ -7,8 +7,6 @@ import request from '@/utils/request.js'
|
|||||||
export default {
|
export default {
|
||||||
/**
|
/**
|
||||||
* 获取选手列表
|
* 获取选手列表
|
||||||
* @param {Object} params 查询参数 { current, size, competitionId, name }
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
*/
|
||||||
getAthleteList(params = {}) {
|
getAthleteList(params = {}) {
|
||||||
return request.get('/martial/athlete/list', {
|
return request.get('/martial/athlete/list', {
|
||||||
@@ -20,8 +18,6 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取选手详情
|
* 获取选手详情
|
||||||
* @param {String|Number} id 选手ID
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
*/
|
||||||
getAthleteDetail(id) {
|
getAthleteDetail(id) {
|
||||||
return request.get('/martial/athlete/detail', { id })
|
return request.get('/martial/athlete/detail', { id })
|
||||||
@@ -29,8 +25,6 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增或修改选手
|
* 新增或修改选手
|
||||||
* @param {Object} data 选手数据
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
*/
|
||||||
submitAthlete(data) {
|
submitAthlete(data) {
|
||||||
return request.post('/martial/athlete/submit', data)
|
return request.post('/martial/athlete/submit', data)
|
||||||
@@ -38,12 +32,44 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除选手
|
* 删除选手
|
||||||
* @param {String|Array} ids 选手ID或ID数组
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
*/
|
||||||
removeAthlete(ids) {
|
removeAthlete(ids) {
|
||||||
return request.post('/martial/athlete/remove', {
|
return request.post('/martial/athlete/remove', {
|
||||||
ids: Array.isArray(ids) ? ids.join(',') : ids
|
ids: Array.isArray(ids) ? ids.join(',') : ids
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// ========== 集体/团队相关 API ==========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取集体列表
|
||||||
|
*/
|
||||||
|
getTeamList(params = {}) {
|
||||||
|
return request.get('/martial/team/list', {
|
||||||
|
current: params.current || 1,
|
||||||
|
size: params.size || 100,
|
||||||
|
...params
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取集体详情
|
||||||
|
*/
|
||||||
|
getTeamDetail(id) {
|
||||||
|
return request.get('/martial/team/detail', { id })
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存集体
|
||||||
|
*/
|
||||||
|
saveTeam(data) {
|
||||||
|
return request.post('/martial/team/submit', data)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除集体
|
||||||
|
*/
|
||||||
|
removeTeam(id) {
|
||||||
|
return request.post('/martial/team/remove', null, { params: { id } })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<view class="steps-indicator">
|
<view class="steps-indicator">
|
||||||
<view class="step-item" :class="{ active: currentStep >= 1 }">
|
<view class="step-item" :class="{ active: currentStep >= 1 }">
|
||||||
<image class="step-icon-img" :src="currentStep >= 1 ? '/static/images/选择选手信息@3x.png' : '/static/images/选择选手信息@3x.png'" mode="aspectFit"></image>
|
<image class="step-icon-img" :src="currentStep >= 1 ? '/static/images/选择选手信息@3x.png' : '/static/images/选择选手信息@3x.png'" mode="aspectFit"></image>
|
||||||
<text class="step-text">选择选手信息</text>
|
<text class="step-text">{{ isTeamProject ? '选择集体' : '选择选手信息' }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="step-line" :class="{ active: currentStep >= 2 }"></view>
|
<view class="step-line" :class="{ active: currentStep >= 2 }"></view>
|
||||||
<view class="step-item" :class="{ active: currentStep >= 2 }">
|
<view class="step-item" :class="{ active: currentStep >= 2 }">
|
||||||
@@ -18,37 +18,73 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 步骤1:选择选手信息 -->
|
<!-- 步骤1:选择选手/集体 -->
|
||||||
<view class="step-content" v-if="currentStep === 1">
|
<view class="step-content" v-if="currentStep === 1">
|
||||||
<view class="selected-count">已选:<text class="count">{{ selectedCount }}</text> 人</view>
|
<!-- 个人项目:选择选手 -->
|
||||||
|
<template v-if="!isTeamProject">
|
||||||
|
<view class="selected-count">已选:<text class="count">{{ selectedCount }}</text> 人</view>
|
||||||
|
|
||||||
<view class="add-player-btn" @click="goToAddPlayer">
|
<view class="add-player-btn" @click="goToAddPlayer">
|
||||||
<text class="add-icon">⊕</text>
|
<text class="add-icon">⊕</text>
|
||||||
<text>新增选手</text>
|
<text>新增选手</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="player-list">
|
<view class="player-list">
|
||||||
<view class="player-item" v-for="(item, index) in playerList" :key="index">
|
<view class="player-item" v-for="(item, index) in playerList" :key="index">
|
||||||
<view class="player-checkbox" @click="togglePlayer(item)">
|
<view class="player-checkbox" @click="togglePlayer(item)">
|
||||||
<image v-if="item.selected" class="checkbox-img" src="/static/images/选中@3x.png" mode="aspectFit"></image>
|
<image v-if="item.selected" class="checkbox-img" src="/static/images/选中@3x.png" mode="aspectFit"></image>
|
||||||
<image v-else class="checkbox-img" src="/static/images/未选中@3x.png" mode="aspectFit"></image>
|
<image v-else class="checkbox-img" src="/static/images/未选中@3x.png" mode="aspectFit"></image>
|
||||||
</view>
|
|
||||||
<view class="player-info">
|
|
||||||
<view class="player-name">{{ item.name }}</view>
|
|
||||||
<view class="player-id">身份证:{{ item.idCard }}</view>
|
|
||||||
</view>
|
|
||||||
<view class="player-actions">
|
|
||||||
<view class="action-btn edit-btn" @click.stop="handleEdit(item)">
|
|
||||||
<image class="action-icon" src="/static/images/编辑@3x.png" mode="aspectFit"></image>
|
|
||||||
<text>编辑</text>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="action-btn delete-btn" @click.stop="handleDelete(item)">
|
<view class="player-info">
|
||||||
<image class="action-icon" src="/static/images/删除@3x.png" mode="aspectFit"></image>
|
<view class="player-name">{{ item.name }}</view>
|
||||||
<text>删除</text>
|
<view class="player-id">身份证:{{ item.idCard }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="player-actions">
|
||||||
|
<view class="action-btn edit-btn" @click.stop="handleEdit(item)">
|
||||||
|
<image class="action-icon" src="/static/images/编辑@3x.png" mode="aspectFit"></image>
|
||||||
|
<text>编辑</text>
|
||||||
|
</view>
|
||||||
|
<view class="action-btn delete-btn" @click.stop="handleDelete(item)">
|
||||||
|
<image class="action-icon" src="/static/images/删除@3x.png" mode="aspectFit"></image>
|
||||||
|
<text>删除</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</template>
|
||||||
|
|
||||||
|
<!-- 集体项目:选择集体 -->
|
||||||
|
<template v-else>
|
||||||
|
<view class="selected-count">已选:<text class="count">{{ selectedTeamCount }}</text> 个集体</view>
|
||||||
|
|
||||||
|
<view class="add-player-btn" @click="goToAddTeam">
|
||||||
|
<text class="add-icon">⊕</text>
|
||||||
|
<text>新增集体</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="player-list">
|
||||||
|
<view class="player-item" v-for="(item, index) in teamList" :key="index">
|
||||||
|
<view class="player-checkbox" @click="toggleTeam(item)">
|
||||||
|
<image v-if="item.selected" class="checkbox-img" src="/static/images/选中@3x.png" mode="aspectFit"></image>
|
||||||
|
<image v-else class="checkbox-img" src="/static/images/未选中@3x.png" mode="aspectFit"></image>
|
||||||
|
</view>
|
||||||
|
<view class="player-info">
|
||||||
|
<view class="player-name">{{ item.name }}</view>
|
||||||
|
<view class="player-id">成员数:{{ item.memberCount || 0 }}人</view>
|
||||||
|
</view>
|
||||||
|
<view class="player-actions">
|
||||||
|
<view class="action-btn delete-btn" @click.stop="handleDeleteTeam(item)">
|
||||||
|
<image class="action-icon" src="/static/images/删除@3x.png" mode="aspectFit"></image>
|
||||||
|
<text>删除</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="empty-state" v-if="teamList.length === 0">
|
||||||
|
<text class="empty-text">暂无集体,请先新增</text>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
<view class="next-btn-wrapper">
|
<view class="next-btn-wrapper">
|
||||||
<view class="next-btn" @click="goToStep2">下一步</view>
|
<view class="next-btn" @click="goToStep2">下一步</view>
|
||||||
@@ -81,11 +117,11 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="info-hint">(注意是否用此号码接收信息)</view>
|
<view class="info-hint">(注意是否用此号码接收信息)</view>
|
||||||
<view class="info-item participants-item">
|
<view class="info-item participants-item">
|
||||||
<text class="label">参赛选手:</text>
|
<text class="label">{{ isTeamProject ? '参赛集体:' : '参赛选手:' }}</text>
|
||||||
<text class="value participants" style="color: #C93639; font-weight: bold;">
|
<text class="value participants" style="color: #C93639; font-weight: bold;">
|
||||||
{{ eventInfo.participants || '未选择选手' }}
|
{{ eventInfo.participants || (isTeamProject ? '未选择集体' : '未选择选手') }}
|
||||||
</text>
|
</text>
|
||||||
<view class="view-cert-btn" @click="showPlayers">
|
<view class="view-cert-btn" @click="showPlayers" v-if="!isTeamProject">
|
||||||
<text>查看证件</text>
|
<text>查看证件</text>
|
||||||
<text class="arrow">›</text>
|
<text class="arrow">›</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -94,8 +130,8 @@
|
|||||||
|
|
||||||
<view class="payment-info">
|
<view class="payment-info">
|
||||||
<view class="payment-row">
|
<view class="payment-row">
|
||||||
<text class="label">人数:</text>
|
<text class="label">{{ isTeamProject ? '集体数:' : '人数:' }}</text>
|
||||||
<text class="value">{{ selectedCount }}</text>
|
<text class="value">{{ isTeamProject ? selectedTeamCount : selectedCount }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="payment-row total">
|
<view class="payment-row total">
|
||||||
<text class="label">合计:</text>
|
<text class="label">合计:</text>
|
||||||
@@ -132,14 +168,25 @@
|
|||||||
<text class="value">{{ eventInfo.contact }}</text>
|
<text class="value">{{ eventInfo.contact }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="participants-title">参赛选手:{{ selectedPlayers.length }}人</view>
|
<template v-if="!isTeamProject">
|
||||||
<view class="participants-detail">
|
<view class="participants-title">参赛选手:{{ selectedPlayers.length }}人</view>
|
||||||
<view class="participant-item" v-for="(item, index) in selectedPlayers" :key="index">
|
<view class="participants-detail">
|
||||||
<view class="participant-name">{{ item.name }}</view>
|
<view class="participant-item" v-for="(item, index) in selectedPlayers" :key="index">
|
||||||
<view class="participant-id">身份证:{{ item.idCard }}</view>
|
<view class="participant-name">{{ item.name }}</view>
|
||||||
<view class="participant-number">编号:{{ item.number }}</view>
|
<view class="participant-id">身份证:{{ item.idCard }}</view>
|
||||||
|
<view class="participant-number">编号:{{ item.number }}</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<view class="participants-title">参赛集体:{{ selectedTeams.length }}个</view>
|
||||||
|
<view class="participants-detail">
|
||||||
|
<view class="participant-item" v-for="(item, index) in selectedTeams" :key="index">
|
||||||
|
<view class="participant-name">{{ item.name }}</view>
|
||||||
|
<view class="participant-id">成员数:{{ item.memberCount }}人</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="close-btn-wrapper">
|
<view class="close-btn-wrapper">
|
||||||
@@ -179,6 +226,7 @@ export default {
|
|||||||
currentStep: 1,
|
currentStep: 1,
|
||||||
eventId: '',
|
eventId: '',
|
||||||
selectedProjects: [],
|
selectedProjects: [],
|
||||||
|
isTeamProject: false,
|
||||||
eventInfo: {
|
eventInfo: {
|
||||||
title: '',
|
title: '',
|
||||||
location: '',
|
location: '',
|
||||||
@@ -188,7 +236,9 @@ export default {
|
|||||||
participants: ''
|
participants: ''
|
||||||
},
|
},
|
||||||
playerList: [],
|
playerList: [],
|
||||||
|
teamList: [],
|
||||||
selectedPlayers: [],
|
selectedPlayers: [],
|
||||||
|
selectedTeams: [],
|
||||||
showPlayerModal: false,
|
showPlayerModal: false,
|
||||||
totalPrice: 0,
|
totalPrice: 0,
|
||||||
registrationId: ''
|
registrationId: ''
|
||||||
@@ -198,11 +248,8 @@ export default {
|
|||||||
selectedCount() {
|
selectedCount() {
|
||||||
return this.playerList.filter(item => item.selected).length
|
return this.playerList.filter(item => item.selected).length
|
||||||
},
|
},
|
||||||
participantsText() {
|
selectedTeamCount() {
|
||||||
return this.playerList
|
return this.teamList.filter(item => item.selected).length
|
||||||
.filter(item => item.selected)
|
|
||||||
.map(item => item.name)
|
|
||||||
.join('、')
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
@@ -213,47 +260,44 @@ export default {
|
|||||||
|
|
||||||
if (options.projects) {
|
if (options.projects) {
|
||||||
try {
|
try {
|
||||||
// 尝试解码(可能被双重编码)
|
|
||||||
let projectsStr = decodeURIComponent(options.projects)
|
let projectsStr = decodeURIComponent(options.projects)
|
||||||
|
|
||||||
// 如果还包含 %,说明被双重编码了,再解码一次
|
|
||||||
if (projectsStr.includes('%')) {
|
if (projectsStr.includes('%')) {
|
||||||
projectsStr = decodeURIComponent(projectsStr)
|
projectsStr = decodeURIComponent(projectsStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selectedProjects = JSON.parse(projectsStr)
|
this.selectedProjects = JSON.parse(projectsStr)
|
||||||
|
|
||||||
|
// Check if any project is team type (type === 2)
|
||||||
|
this.isTeamProject = this.selectedProjects.some(p => p.type === 2 || p.type === '2')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('解析项目数据失败:', err)
|
console.error('解析项目数据失败:', err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载选手列表
|
// Load list based on project type
|
||||||
this.loadPlayerList()
|
if (this.isTeamProject) {
|
||||||
},
|
this.loadTeamList()
|
||||||
onShow() {
|
} else {
|
||||||
// 从新增/编辑页面返回时重新加载列表
|
|
||||||
if (this.currentStep === 1) {
|
|
||||||
this.loadPlayerList()
|
this.loadPlayerList()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onShow() {
|
||||||
|
if (this.currentStep === 1) {
|
||||||
|
if (this.isTeamProject) {
|
||||||
|
this.loadTeamList()
|
||||||
|
} else {
|
||||||
|
this.loadPlayerList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
|
||||||
* 加载赛事详情
|
|
||||||
*/
|
|
||||||
async loadEventDetail(id) {
|
async loadEventDetail(id) {
|
||||||
try {
|
try {
|
||||||
const res = await competitionAPI.getCompetitionDetail(id)
|
const res = await competitionAPI.getCompetitionDetail(id)
|
||||||
|
|
||||||
// 尝试多个可能的时间字段名
|
|
||||||
const startTime = res.startTime || res.competitionStartTime || res.beginTime || res.startDate
|
const startTime = res.startTime || res.competitionStartTime || res.beginTime || res.startDate
|
||||||
const endTime = res.endTime || res.competitionEndTime || res.finishTime || res.endDate
|
const endTime = res.endTime || res.competitionEndTime || res.finishTime || res.endDate
|
||||||
|
|
||||||
// 如果没有时间字段,尝试使用其他字段
|
|
||||||
let matchTime = this.formatTimeRange(startTime, endTime)
|
let matchTime = this.formatTimeRange(startTime, endTime)
|
||||||
if (!matchTime && res.matchTime) {
|
if (!matchTime && res.matchTime) {
|
||||||
matchTime = res.matchTime
|
matchTime = res.matchTime
|
||||||
} else if (!matchTime && res.competitionTime) {
|
|
||||||
matchTime = res.competitionTime
|
|
||||||
} else if (!matchTime) {
|
} else if (!matchTime) {
|
||||||
matchTime = '待定'
|
matchTime = '待定'
|
||||||
}
|
}
|
||||||
@@ -270,7 +314,6 @@ export default {
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('加载赛事详情失败:', err)
|
console.error('加载赛事详情失败:', err)
|
||||||
// 设置默认值,防止页面显示空白
|
|
||||||
this.eventInfo = {
|
this.eventInfo = {
|
||||||
title: '未命名赛事',
|
title: '未命名赛事',
|
||||||
location: '待定',
|
location: '待定',
|
||||||
@@ -282,111 +325,105 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* 加载选手列表
|
|
||||||
*/
|
|
||||||
async loadPlayerList() {
|
async loadPlayerList() {
|
||||||
try {
|
try {
|
||||||
// 获取当前用户信息
|
|
||||||
const userInfo = getUserInfo()
|
const userInfo = getUserInfo()
|
||||||
if (!userInfo || !userInfo.userId) {
|
if (!userInfo || !userInfo.userId) {
|
||||||
uni.showToast({
|
uni.showToast({ title: '请先登录', icon: 'none' })
|
||||||
title: '请先登录',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 只查询当前用户创建的选手
|
|
||||||
const res = await athleteAPI.getAthleteList({
|
const res = await athleteAPI.getAthleteList({
|
||||||
current: 1,
|
current: 1,
|
||||||
size: 100,
|
size: 100,
|
||||||
createUser: userInfo.userId
|
createUser: userInfo.userId
|
||||||
})
|
})
|
||||||
|
|
||||||
let list = []
|
let list = res.records || (Array.isArray(res) ? res : [])
|
||||||
if (res.records) {
|
|
||||||
list = res.records
|
|
||||||
} else if (Array.isArray(res)) {
|
|
||||||
list = res
|
|
||||||
}
|
|
||||||
|
|
||||||
// 数据映射 - 尝试多个可能的字段名
|
|
||||||
this.playerList = list.map(item => ({
|
this.playerList = list.map(item => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
// 尝试多个可能的姓名字段
|
name: item.name || item.athleteName || item.playerName || '未命名',
|
||||||
name: item.name || item.athleteName || item.playerName || item.realName || item.userName || '未命名',
|
idCard: item.idCard || item.idCardNumber || '',
|
||||||
// 尝试多个可能的身份证字段
|
|
||||||
idCard: item.idCard || item.idCardNumber || item.idCardNo || item.identityCard || '',
|
|
||||||
selected: false
|
selected: false
|
||||||
}))
|
}))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('加载选手列表失败:', err)
|
console.error('加载选手列表失败:', err)
|
||||||
uni.showToast({
|
|
||||||
title: '加载选手列表失败',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
async loadTeamList() {
|
||||||
* 格式化时间范围
|
try {
|
||||||
*/
|
const userInfo = getUserInfo()
|
||||||
|
if (!userInfo || !userInfo.userId) return
|
||||||
|
|
||||||
|
const res = await athleteAPI.getTeamList({
|
||||||
|
current: 1,
|
||||||
|
size: 100
|
||||||
|
})
|
||||||
|
|
||||||
|
let list = res.records || (Array.isArray(res) ? res : [])
|
||||||
|
this.teamList = list.map(item => ({
|
||||||
|
id: item.id,
|
||||||
|
name: item.teamName || item.name,
|
||||||
|
memberCount: item.memberCount || 0,
|
||||||
|
selected: false
|
||||||
|
}))
|
||||||
|
} catch (err) {
|
||||||
|
console.error('加载集体列表失败:', err)
|
||||||
|
this.teamList = []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
formatTimeRange(startTime, endTime) {
|
formatTimeRange(startTime, endTime) {
|
||||||
if (!startTime || !endTime) return ''
|
if (!startTime || !endTime) return ''
|
||||||
|
|
||||||
const formatDate = (dateStr) => {
|
const formatDate = (dateStr) => {
|
||||||
if (!dateStr) return ''
|
if (!dateStr) return ''
|
||||||
const date = new Date(dateStr)
|
const date = new Date(dateStr)
|
||||||
const year = date.getFullYear()
|
return `${date.getFullYear()}.${String(date.getMonth() + 1).padStart(2, '0')}.${String(date.getDate()).padStart(2, '0')}`
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
||||||
const day = String(date.getDate()).padStart(2, '0')
|
|
||||||
return `${year}.${month}.${day}`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${formatDate(startTime)}-${formatDate(endTime)}`
|
return `${formatDate(startTime)}-${formatDate(endTime)}`
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* 计算总价
|
|
||||||
*/
|
|
||||||
calculateTotalPrice() {
|
calculateTotalPrice() {
|
||||||
const count = this.selectedCount
|
const count = this.isTeamProject ? this.selectedTeamCount : this.selectedCount
|
||||||
|
if (!this.selectedProjects || this.selectedProjects.length === 0) return 0
|
||||||
if (!this.selectedProjects || this.selectedProjects.length === 0) {
|
const pricePerProject = this.selectedProjects.reduce((sum, p) => sum + parseFloat(p.price || 0), 0)
|
||||||
return 0
|
return (count * pricePerProject).toFixed(2)
|
||||||
}
|
|
||||||
|
|
||||||
// 计算所有项目的总价(将字符串转换为数字)
|
|
||||||
const pricePerProject = this.selectedProjects.reduce((sum, p) => {
|
|
||||||
const price = parseFloat(p.price || 0)
|
|
||||||
return sum + price
|
|
||||||
}, 0)
|
|
||||||
|
|
||||||
const total = count * pricePerProject
|
|
||||||
|
|
||||||
return total.toFixed(2)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
togglePlayer(item) {
|
togglePlayer(item) {
|
||||||
const index = this.playerList.findIndex(p => p.id === item.id)
|
const index = this.playerList.findIndex(p => p.id === item.id)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
const newValue = !this.playerList[index].selected
|
this.$set(this.playerList[index], 'selected', !this.playerList[index].selected)
|
||||||
this.$set(this.playerList[index], 'selected', newValue)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleTeam(item) {
|
||||||
|
const index = this.teamList.findIndex(t => t.id === item.id)
|
||||||
|
if (index !== -1) {
|
||||||
|
this.$set(this.teamList[index], 'selected', !this.teamList[index].selected)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
goToAddPlayer() {
|
goToAddPlayer() {
|
||||||
// 传递赛事ID和项目ID到新增选手页面
|
|
||||||
const projectIds = this.selectedProjects.map(p => p.id).join(',')
|
const projectIds = this.selectedProjects.map(p => p.id).join(',')
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/add-player/add-player?competitionId=${this.eventId}&projectIds=${projectIds}`
|
url: `/pages/add-player/add-player?competitionId=${this.eventId}&projectIds=${projectIds}`
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
goToAddTeam() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/add-team/add-team'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
handleEdit(item) {
|
handleEdit(item) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/edit-player/edit-player?id=' + item.id
|
url: '/pages/edit-player/edit-player?id=' + item.id
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
async handleDelete(item) {
|
async handleDelete(item) {
|
||||||
try {
|
try {
|
||||||
const confirmRes = await new Promise((resolve) => {
|
const confirmRes = await new Promise((resolve) => {
|
||||||
@@ -399,167 +436,146 @@ export default {
|
|||||||
|
|
||||||
if (confirmRes.confirm) {
|
if (confirmRes.confirm) {
|
||||||
await athleteAPI.removeAthlete(item.id)
|
await athleteAPI.removeAthlete(item.id)
|
||||||
|
const index = this.playerList.findIndex(p => p.id === item.id)
|
||||||
const index = this.playerList.findIndex(p => p.id === item.id);
|
if (index > -1) this.playerList.splice(index, 1)
|
||||||
if (index > -1) {
|
uni.showToast({ title: '删除成功', icon: 'success' })
|
||||||
this.playerList.splice(index, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
uni.showToast({
|
|
||||||
title: '删除成功',
|
|
||||||
icon: 'success'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('删除选手失败:', err)
|
console.error('删除选手失败:', err)
|
||||||
uni.showToast({
|
uni.showToast({ title: '删除失败', icon: 'none' })
|
||||||
title: '删除失败',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async handleDeleteTeam(item) {
|
||||||
|
try {
|
||||||
|
const confirmRes = await new Promise((resolve) => {
|
||||||
|
uni.showModal({
|
||||||
|
title: '删除集体',
|
||||||
|
content: '确定要删除该集体吗?',
|
||||||
|
success: (res) => resolve(res)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
if (confirmRes.confirm) {
|
||||||
|
await athleteAPI.removeTeam(item.id)
|
||||||
|
const index = this.teamList.findIndex(t => t.id === item.id)
|
||||||
|
if (index > -1) this.teamList.splice(index, 1)
|
||||||
|
uni.showToast({ title: '删除成功', icon: 'success' })
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('删除集体失败:', err)
|
||||||
|
uni.showToast({ title: '删除失败', icon: 'none' })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
goToStep2() {
|
goToStep2() {
|
||||||
const selected = this.playerList.filter(item => item.selected)
|
if (this.isTeamProject) {
|
||||||
|
const selected = this.teamList.filter(item => item.selected)
|
||||||
if (selected.length === 0) {
|
if (selected.length === 0) {
|
||||||
uni.showToast({
|
uni.showToast({ title: '请至少选择一个集体', icon: 'none' })
|
||||||
title: '请至少选择一名选手',
|
return
|
||||||
icon: 'none'
|
}
|
||||||
})
|
this.$set(this.eventInfo, 'participants', selected.map(t => t.name).join('、'))
|
||||||
return
|
this.selectedTeams = selected
|
||||||
|
} else {
|
||||||
|
const selected = this.playerList.filter(item => item.selected)
|
||||||
|
if (selected.length === 0) {
|
||||||
|
uni.showToast({ title: '请至少选择一名选手', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.$set(this.eventInfo, 'participants', selected.map(p => p.name).join('、'))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新参赛选手信息
|
|
||||||
const participantsText = selected.map(p => p.name).join('、')
|
|
||||||
|
|
||||||
// 使用 $set 确保响应式更新
|
|
||||||
this.$set(this.eventInfo, 'participants', participantsText)
|
|
||||||
this.totalPrice = this.calculateTotalPrice()
|
this.totalPrice = this.calculateTotalPrice()
|
||||||
|
this.$nextTick(() => { this.currentStep = 2 })
|
||||||
// 延迟切换步骤,确保数据更新完成
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.currentStep = 2
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async goToStep3() {
|
async goToStep3() {
|
||||||
try {
|
try {
|
||||||
// 获取选中的选手
|
|
||||||
const selected = this.playerList.filter(item => item.selected)
|
|
||||||
|
|
||||||
// 检查必填字段
|
|
||||||
if (!this.eventId) {
|
if (!this.eventId) {
|
||||||
uni.showToast({
|
uni.showToast({ title: '赛事ID缺失', icon: 'none' })
|
||||||
title: '赛事ID缺失',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.selectedProjects || this.selectedProjects.length === 0) {
|
if (!this.selectedProjects || this.selectedProjects.length === 0) {
|
||||||
uni.showToast({
|
uni.showToast({ title: '请选择报名项目', icon: 'none' })
|
||||||
title: '请选择报名项目',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected.length === 0) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '请选择参赛选手',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 生成订单号:格式 BMyyyyMMddHHmmss + 随机4位数
|
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const year = now.getFullYear()
|
const orderNo = `BM${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}${String(Math.floor(Math.random() * 10000)).padStart(4, '0')}`
|
||||||
const month = String(now.getMonth() + 1).padStart(2, '0')
|
|
||||||
const day = String(now.getDate()).padStart(2, '0')
|
|
||||||
const hours = String(now.getHours()).padStart(2, '0')
|
|
||||||
const minutes = String(now.getMinutes()).padStart(2, '0')
|
|
||||||
const seconds = String(now.getSeconds()).padStart(2, '0')
|
|
||||||
const random = String(Math.floor(Math.random() * 10000)).padStart(4, '0')
|
|
||||||
const orderNo = `BM${year}${month}${day}${hours}${minutes}${seconds}${random}`
|
|
||||||
|
|
||||||
// 构建提交数据 - 确保ID都是数字类型
|
let submitData
|
||||||
const submitData = {
|
if (this.isTeamProject) {
|
||||||
orderNo: orderNo,
|
const selected = this.teamList.filter(item => item.selected)
|
||||||
competitionId: String(this.eventId),
|
if (selected.length === 0) {
|
||||||
projectIds: this.selectedProjects.map(p => String(p.id)),
|
uni.showToast({ title: '请选择参赛集体', icon: 'none' })
|
||||||
athleteIds: selected.map(p => String(p.id)),
|
return
|
||||||
contactPhone: this.eventInfo.contact || '',
|
}
|
||||||
totalAmount: parseFloat(this.totalPrice) || 0
|
submitData = {
|
||||||
|
orderNo: orderNo,
|
||||||
|
competitionId: String(this.eventId),
|
||||||
|
projectIds: this.selectedProjects.map(p => String(p.id)),
|
||||||
|
teamIds: selected.map(t => String(t.id)),
|
||||||
|
athleteIds: [],
|
||||||
|
contactPhone: this.eventInfo.contact || '',
|
||||||
|
totalAmount: parseFloat(this.totalPrice) || 0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const selected = this.playerList.filter(item => item.selected)
|
||||||
|
if (selected.length === 0) {
|
||||||
|
uni.showToast({ title: '请选择参赛选手', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
submitData = {
|
||||||
|
orderNo: orderNo,
|
||||||
|
competitionId: String(this.eventId),
|
||||||
|
projectIds: this.selectedProjects.map(p => String(p.id)),
|
||||||
|
athleteIds: selected.map(p => String(p.id)),
|
||||||
|
contactPhone: this.eventInfo.contact || '',
|
||||||
|
totalAmount: parseFloat(this.totalPrice) || 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('=== 提交报名数据 ===')
|
console.log('提交报名数据:', submitData)
|
||||||
console.log('订单号:', submitData.orderNo)
|
|
||||||
console.log('完整提交数据:', submitData)
|
|
||||||
console.log('赛事ID:', submitData.competitionId, typeof submitData.competitionId)
|
|
||||||
console.log('项目IDs:', submitData.projectIds)
|
|
||||||
console.log('选手IDs:', submitData.athleteIds)
|
|
||||||
console.log('联系电话:', submitData.contactPhone)
|
|
||||||
console.log('总金额:', submitData.totalAmount, typeof submitData.totalAmount)
|
|
||||||
|
|
||||||
// 提交报名订单
|
|
||||||
const res = await registrationAPI.submitRegistration(submitData)
|
const res = await registrationAPI.submitRegistration(submitData)
|
||||||
|
this.registrationId = res.id || res.registrationId || orderNo
|
||||||
|
|
||||||
console.log('=== 报名响应数据 ===')
|
if (this.isTeamProject) {
|
||||||
console.log('完整响应:', res)
|
this.selectedTeams = this.teamList.filter(item => item.selected).map(item => ({
|
||||||
console.log('响应数据:', res.data)
|
name: item.name,
|
||||||
|
memberCount: item.memberCount
|
||||||
// 保存报名ID - 尝试多个可能的字段
|
}))
|
||||||
this.registrationId = res.id || res.registrationId || res.data?.id || res.data?.registrationId || orderNo
|
} else {
|
||||||
|
const selected = this.playerList.filter(item => item.selected)
|
||||||
console.log('报名ID:', this.registrationId)
|
this.selectedPlayers = selected.map((item, index) => ({
|
||||||
|
|
||||||
// 更新选中的选手列表(包含编号)
|
|
||||||
this.selectedPlayers = selected.map((item, index) => {
|
|
||||||
// 生成编号:使用报名ID或订单号 + 选手索引
|
|
||||||
const playerNumber = item.playerNo || item.number || `${this.registrationId}-${String(index + 1).padStart(6, '0')}`
|
|
||||||
|
|
||||||
return {
|
|
||||||
name: item.name,
|
name: item.name,
|
||||||
idCard: item.idCard,
|
idCard: item.idCard,
|
||||||
number: playerNumber
|
number: `${this.registrationId}-${String(index + 1).padStart(6, '0')}`
|
||||||
}
|
}))
|
||||||
})
|
}
|
||||||
|
|
||||||
this.currentStep = 3;
|
this.currentStep = 3
|
||||||
|
uni.showToast({ title: '报名成功', icon: 'success' })
|
||||||
uni.showToast({
|
|
||||||
title: '报名成功',
|
|
||||||
icon: 'success'
|
|
||||||
})
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('提交报名失败:', err)
|
console.error('提交报名失败:', err)
|
||||||
uni.showToast({
|
uni.showToast({ title: '报名失败,请重试', icon: 'none' })
|
||||||
title: '报名失败,请重试',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
showPlayers() {
|
showPlayers() {
|
||||||
// 更新选中的选手列表
|
|
||||||
this.selectedPlayers = this.playerList
|
this.selectedPlayers = this.playerList
|
||||||
.filter(item => item.selected)
|
.filter(item => item.selected)
|
||||||
.map(item => ({
|
.map(item => ({ name: item.name, idCard: item.idCard, number: '' }))
|
||||||
name: item.name,
|
this.showPlayerModal = true
|
||||||
idCard: item.idCard,
|
|
||||||
number: ''
|
|
||||||
}))
|
|
||||||
|
|
||||||
this.showPlayerModal = true;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleClose() {
|
handleClose() {
|
||||||
uni.navigateBack({
|
uni.navigateBack({ delta: 3 })
|
||||||
delta: 3
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.event-register-page {
|
.event-register-page {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
@@ -999,3 +1015,13 @@ export default {
|
|||||||
margin-top: 10rpx;
|
margin-top: 10rpx;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
.empty-state {
|
||||||
|
padding: 100rpx 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user