This commit is contained in:
2025-12-14 17:39:19 +08:00
parent 0f3cfee622
commit 78291bb76b
12 changed files with 181 additions and 44 deletions

View File

@@ -94,15 +94,6 @@
<text class="toast-text">{{ toastMessage }}</text>
</view>
<!-- 提示文字 -->
<view class="info-text">
<text class="info-hint">默认关闭可切换开关</text>
</view>
<view class="warning-text">
<text>联系人用于接收比赛信息成绩和证书</text>
</view>
<!-- 按钮 -->
<view class="btn-wrapper">
<view class="btn save-btn disabled" v-if="!isFormValid">保存</view>
@@ -219,7 +210,7 @@ export default {
}
.form-label {
width: 180rpx;
width: 280rpx;
font-size: 30rpx;
color: #333333;
}

View File

@@ -126,6 +126,8 @@ export default {
organization: '',
phone: ''
},
competitionId: '',
projectIds: [],
errors: [],
showHint: false,
showToast: false,
@@ -133,6 +135,19 @@ export default {
showIdTypePicker: false
};
},
onLoad(options) {
// 接收赛事ID和项目ID
if (options.competitionId) {
this.competitionId = options.competitionId
}
if (options.projectIds) {
this.projectIds = options.projectIds.split(',').map(id => parseInt(id))
}
console.log('新增选手页面接收参数:', {
competitionId: this.competitionId,
projectIds: this.projectIds
})
},
computed: {
isFormValid() {
return (
@@ -252,7 +267,7 @@ export default {
const info = this.extractInfoFromIdCard(this.formData.idCard)
// 调用API保存选手信息使用后端实体类的字段名
await athleteAPI.submitAthlete({
const submitData = {
playerName: this.formData.name,
idCard: this.formData.idCard,
teamName: this.formData.team,
@@ -262,7 +277,19 @@ export default {
gender: info.gender,
age: info.age,
birthDate: info.birthDate
})
}
// 如果有赛事ID和项目ID一起提交
if (this.competitionId) {
submitData.competitionId = parseInt(this.competitionId)
}
if (this.projectIds && this.projectIds.length > 0) {
// 如果有多个项目取第一个项目ID
submitData.projectId = this.projectIds[0]
}
console.log('提交选手数据:', submitData)
await athleteAPI.submitAthlete(submitData)
// 保存成功
uni.showToast({
@@ -415,9 +442,9 @@ export default {
.btn {
width: 100%;
text-align: center;
padding: 30rpx;
padding: 24rpx;
border-radius: 12rpx;
font-size: 32rpx;
font-size: 30rpx;
font-weight: bold;
}

View File

@@ -60,6 +60,7 @@
import CustomTabs from '../../components/custom-tabs/custom-tabs.vue';
import ConfirmModal from '../../components/confirm-modal/confirm-modal.vue';
import athleteAPI from '@/api/athlete.js';
import { getUserInfo } from '@/utils/auth.js';
export default {
components: {
@@ -89,9 +90,21 @@ export default {
*/
async loadPlayerList() {
try {
// 获取当前用户信息
const userInfo = getUserInfo()
if (!userInfo || !userInfo.userId) {
console.error('未获取到用户信息')
uni.showToast({
title: '请先登录',
icon: 'none'
})
return
}
const res = await athleteAPI.getAthleteList({
current: 1,
size: 100
size: 100,
createUser: userInfo.userId // 只查询当前用户创建的选手
})
let list = []
@@ -104,11 +117,11 @@ export default {
// 数据映射
this.playerList = list.map(item => ({
id: item.id,
name: item.name,
name: item.name || item.playerName,
idCard: item.idCard || item.idCardNumber,
gender: item.gender,
team: item.team,
phone: item.phone
team: item.team || item.teamName,
phone: item.phone || item.contactPhone
}))
} catch (err) {
console.error('加载选手列表失败:', err)

View File

@@ -171,6 +171,7 @@
import competitionAPI from '@/api/competition.js'
import athleteAPI from '@/api/athlete.js'
import registrationAPI from '@/api/registration.js'
import { getUserInfo } from '@/utils/auth.js'
export default {
data() {
@@ -286,9 +287,21 @@ export default {
*/
async loadPlayerList() {
try {
// 获取当前用户信息
const userInfo = getUserInfo()
if (!userInfo || !userInfo.userId) {
uni.showToast({
title: '请先登录',
icon: 'none'
})
return
}
// 只查询当前用户创建的选手
const res = await athleteAPI.getAthleteList({
current: 1,
size: 100
size: 100,
createUser: userInfo.userId
})
let list = []
@@ -363,8 +376,10 @@ export default {
}
},
goToAddPlayer() {
// 传递赛事ID和项目ID到新增选手页面
const projectIds = this.selectedProjects.map(p => p.id).join(',')
uni.navigateTo({
url: '/pages/add-player/add-player'
url: `/pages/add-player/add-player?competitionId=${this.eventId}&projectIds=${projectIds}`
});
},
handleEdit(item) {

View File

@@ -65,6 +65,7 @@
import CustomTabs from '../../components/custom-tabs/custom-tabs.vue';
import registrationAPI from '@/api/registration.js'
import competitionAPI from '@/api/competition.js'
import { getUserInfo } from '@/utils/auth.js'
export default {
components: {
@@ -119,9 +120,29 @@ export default {
*/
async loadRegistrationList(refresh = false, loadMore = false) {
try {
// 获取当前用户信息
const userInfo = getUserInfo()
console.log('=== 用户信息调试 ===')
console.log('获取到的用户信息:', userInfo)
console.log('用户信息类型:', typeof userInfo)
if (!userInfo || (!userInfo.userId && !userInfo.user_id)) {
console.error('未获取到用户信息或缺少用户ID字段')
console.log('原始存储数据:', uni.getStorageSync('userInfo'))
uni.showToast({
title: '请先登录',
icon: 'none'
})
return
}
// 兼容 userId 和 user_id 两种字段名
const userId = userInfo.userId || userInfo.user_id
const params = {
current: this.pageParams.current,
size: this.pageParams.size
size: this.pageParams.size,
createUser: userId // 只查询当前用户创建的报名记录
}
// 添加状态筛选

View File

@@ -66,8 +66,9 @@ export default {
.type-btn {
background-color: #C93639;
color: #fff;
padding: 20rpx 60rpx;
padding: 20rpx 50rpx;
border-radius: 50rpx;
font-size: 28rpx;
font-weight: bold;
}
</style>