This commit is contained in:
2025-12-12 01:44:41 +08:00
parent 21abcaff53
commit 2f1d732a36
46 changed files with 7756 additions and 484 deletions

View File

@@ -45,6 +45,31 @@
/>
</view>
</view>
<view class="form-item">
<view class="form-label">所属单位</view>
<view class="form-value">
<input
class="form-input"
v-model="formData.organization"
placeholder="请输入所属单位"
placeholder-class="placeholder"
/>
</view>
</view>
<view class="form-item">
<view class="form-label">联系电话</view>
<view class="form-value">
<input
class="form-input"
v-model="formData.phone"
type="number"
placeholder="请输入联系电话"
placeholder-class="placeholder"
/>
</view>
</view>
</view>
<!-- 错误提示 -->
@@ -88,6 +113,8 @@
</template>
<script>
import athleteAPI from '@/api/athlete.js'
export default {
data() {
return {
@@ -95,7 +122,9 @@ export default {
idType: '身份证',
name: '',
idCard: '',
team: ''
team: '',
organization: '',
phone: ''
},
errors: [],
showHint: false,
@@ -110,7 +139,10 @@ export default {
this.formData.name &&
this.formData.idCard &&
this.formData.team &&
this.validateIdCard(this.formData.idCard)
this.formData.organization &&
this.formData.phone &&
this.validateIdCard(this.formData.idCard) &&
this.validatePhone(this.formData.phone)
);
}
},
@@ -123,20 +155,30 @@ export default {
},
'formData.team'(val) {
this.validateForm();
},
'formData.organization'(val) {
this.validateForm();
},
'formData.phone'(val) {
this.validateForm();
}
},
methods: {
validateIdCard(idCard) {
// 简单的身份证号验证
return /^\d{18}$/.test(idCard);
// 身份证号验证18位最后一位可以是数字或字母X
return /^\d{17}[\dXx]$/.test(idCard);
},
validatePhone(phone) {
// 手机号验证11位数字
return /^1[3-9]\d{9}$/.test(phone);
},
validateForm() {
this.errors = [];
this.showHint = false;
if (!this.formData.name || !this.formData.idCard || !this.formData.team) {
if (!this.formData.name || !this.formData.idCard || !this.formData.team || !this.formData.organization || !this.formData.phone) {
this.showHint = true;
if (!this.formData.name || !this.formData.idCard || !this.formData.team) {
if (!this.formData.name || !this.formData.idCard || !this.formData.team || !this.formData.organization || !this.formData.phone) {
this.errors.push({
label: '有空文本时弹出:',
message: '按钮置灰'
@@ -154,25 +196,93 @@ export default {
message: '按钮置灰'
});
}
if (this.formData.phone && !this.validatePhone(this.formData.phone)) {
this.errors.push({
label: '手机号格式不正确:',
message: '按钮置灰'
});
}
},
handleIdTypeChange(e) {
this.formData.idType = '身份证';
this.showIdTypePicker = false;
},
handleSave() {
/**
* 从身份证号中提取信息
*/
extractInfoFromIdCard(idCard) {
if (!idCard || idCard.length !== 18) {
return {
gender: null,
age: null,
birthDate: null
}
}
// 提取出生日期
const year = idCard.substring(6, 10)
const month = idCard.substring(10, 12)
const day = idCard.substring(12, 14)
const birthDate = `${year}-${month}-${day}`
// 计算年龄
const birthYear = parseInt(year)
const currentYear = new Date().getFullYear()
const age = currentYear - birthYear
// 提取性别(倒数第二位,奇数为男,偶数为女)
const genderCode = parseInt(idCard.substring(16, 17))
const gender = genderCode % 2 === 1 ? 1 : 2
return {
gender,
age,
birthDate
}
},
async handleSave() {
if (!this.isFormValid) {
return;
}
// 显示身份证号码格式错误提示(模拟)
this.toastMessage = '身份证号码格式不正确';
this.showToast = true;
setTimeout(() => {
this.showToast = false;
}, 2000);
try {
// 从身份证号中提取信息
const info = this.extractInfoFromIdCard(this.formData.idCard)
// 实际保存逻辑
// uni.navigateBack();
// 调用API保存选手信息使用后端实体类的字段名
await athleteAPI.submitAthlete({
playerName: this.formData.name,
idCard: this.formData.idCard,
teamName: this.formData.team,
organization: this.formData.organization,
contactPhone: this.formData.phone,
idCardType: 1, // 身份证类型固定为1
gender: info.gender,
age: info.age,
birthDate: info.birthDate
})
// 保存成功
uni.showToast({
title: '保存成功',
icon: 'success'
})
// 延迟返回上一页
setTimeout(() => {
uni.navigateBack()
}, 1500)
} catch (err) {
console.error('保存选手失败:', err)
// 显示错误提示
this.toastMessage = '保存失败,请重试'
this.showToast = true
setTimeout(() => {
this.showToast = false
}, 2000)
}
}
}
};

View File

@@ -0,0 +1,250 @@
<template>
<view class="change-password-page">
<view class="form-container">
<view class="form-item">
<view class="label">旧密码</view>
<input
class="input"
type="password"
v-model="formData.oldPassword"
placeholder="请输入旧密码"
maxlength="20"
/>
</view>
<view class="form-item">
<view class="label">新密码</view>
<input
class="input"
type="password"
v-model="formData.newPassword"
placeholder="请输入新密码6-20位"
maxlength="20"
/>
</view>
<view class="form-item">
<view class="label">确认密码</view>
<input
class="input"
type="password"
v-model="formData.confirmPassword"
placeholder="请再次输入新密码"
maxlength="20"
/>
</view>
<view class="tips">
<text class="tip-item"> 密码长度为6-20</text>
<text class="tip-item"> 建议包含字母数字符号</text>
</view>
<view class="btn-wrapper">
<view class="submit-btn" @click="handleSubmit">确认修改</view>
</view>
</view>
</view>
</template>
<script>
import userAPI from '@/api/user.js'
export default {
data() {
return {
formData: {
oldPassword: '',
newPassword: '',
confirmPassword: ''
}
};
},
methods: {
/**
* 表单验证
*/
validateForm() {
const { oldPassword, newPassword, confirmPassword } = this.formData
if (!oldPassword) {
uni.showToast({
title: '请输入旧密码',
icon: 'none'
})
return false
}
if (!newPassword) {
uni.showToast({
title: '请输入新密码',
icon: 'none'
})
return false
}
if (newPassword.length < 6 || newPassword.length > 20) {
uni.showToast({
title: '密码长度为6-20位',
icon: 'none'
})
return false
}
if (!confirmPassword) {
uni.showToast({
title: '请确认新密码',
icon: 'none'
})
return false
}
if (newPassword !== confirmPassword) {
uni.showToast({
title: '两次密码输入不一致',
icon: 'none'
})
return false
}
if (oldPassword === newPassword) {
uni.showToast({
title: '新密码不能与旧密码相同',
icon: 'none'
})
return false
}
return true
},
/**
* 提交修改
*/
async handleSubmit() {
if (!this.validateForm()) {
return
}
try {
uni.showLoading({
title: '提交中...'
})
await userAPI.updatePassword({
oldPassword: this.formData.oldPassword,
newPassword: this.formData.newPassword,
confirmPassword: this.formData.confirmPassword
})
uni.hideLoading()
uni.showToast({
title: '密码修改成功',
icon: 'success',
duration: 2000
})
// 延迟返回上一页
setTimeout(() => {
uni.navigateBack()
}, 2000)
} catch (err) {
uni.hideLoading()
console.error('修改密码失败:', err)
// 根据错误类型显示不同提示
let errorMsg = '修改失败,请重试'
if (err && err.msg) {
errorMsg = err.msg
} else if (err && err.message) {
if (err.message.includes('旧密码') || err.message.includes('原密码')) {
errorMsg = '旧密码错误'
} else {
errorMsg = err.message
}
}
uni.showToast({
title: errorMsg,
icon: 'none',
duration: 2000
})
}
}
}
};
</script>
<style lang="scss" scoped>
.change-password-page {
min-height: 100vh;
background-color: #f5f5f5;
padding: 30rpx;
}
.form-container {
background-color: #fff;
border-radius: 16rpx;
padding: 40rpx 30rpx;
}
.form-item {
margin-bottom: 40rpx;
&:last-child {
margin-bottom: 0;
}
}
.label {
font-size: 28rpx;
color: #333333;
margin-bottom: 20rpx;
font-weight: 500;
}
.input {
width: 100%;
height: 80rpx;
background-color: #f8f8f8;
border-radius: 8rpx;
padding: 0 20rpx;
font-size: 28rpx;
color: #333333;
}
.tips {
margin-top: 30rpx;
padding: 20rpx;
background-color: #fff9e6;
border-radius: 8rpx;
border-left: 4rpx solid #faad14;
}
.tip-item {
display: block;
font-size: 24rpx;
color: #666666;
line-height: 40rpx;
}
.btn-wrapper {
margin-top: 60rpx;
}
.submit-btn {
width: 100%;
height: 88rpx;
background-color: #C93639;
color: #fff;
text-align: center;
line-height: 88rpx;
border-radius: 12rpx;
font-size: 32rpx;
font-weight: bold;
}
.submit-btn:active {
opacity: 0.8;
}
</style>

View File

@@ -59,6 +59,7 @@
<script>
import CustomTabs from '../../components/custom-tabs/custom-tabs.vue';
import ConfirmModal from '../../components/confirm-modal/confirm-modal.vue';
import athleteAPI from '@/api/athlete.js';
export default {
components: {
@@ -69,39 +70,51 @@ export default {
return {
tabs: ['选手', '联系人'],
currentTab: 0,
playerList: [
{
id: 1,
name: '张三',
idCard: '123456789000000000'
},
{
id: 2,
name: '张三',
idCard: '123456789000000000'
},
{
id: 3,
name: '张三',
idCard: '123456789000000000'
},
{
id: 4,
name: '张三',
idCard: '123456789000000000'
},
{
id: 5,
name: '张三',
idCard: '123456789000000000'
}
],
playerList: [],
showDeleteModal: false,
showSuccessToast: false,
currentItem: null
};
},
onLoad() {
this.loadPlayerList()
},
onShow() {
// 从新增/编辑页面返回时重新加载列表
this.loadPlayerList()
},
methods: {
/**
* 加载选手列表
*/
async loadPlayerList() {
try {
const res = await athleteAPI.getAthleteList({
current: 1,
size: 100
})
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
// 数据映射
this.playerList = list.map(item => ({
id: item.id,
name: item.name,
idCard: item.idCard || item.idCardNumber,
gender: item.gender,
team: item.team,
phone: item.phone
}))
} catch (err) {
console.error('加载选手列表失败:', err)
}
},
handleTabChange(index) {
this.currentTab = index;
},
@@ -125,18 +138,31 @@ export default {
this.currentItem = item;
this.showDeleteModal = true;
},
confirmDelete() {
async confirmDelete() {
this.showDeleteModal = false;
// 执行删除操作
const index = this.playerList.findIndex(item => item.id === this.currentItem.id);
if (index > -1) {
this.playerList.splice(index, 1);
try {
// 调用删除API
await athleteAPI.removeAthlete(this.currentItem.id)
// 从列表中移除
const index = this.playerList.findIndex(item => item.id === this.currentItem.id);
if (index > -1) {
this.playerList.splice(index, 1);
}
// 显示成功提示
this.showSuccessToast = true;
setTimeout(() => {
this.showSuccessToast = false;
}, 2000);
} catch (err) {
console.error('删除选手失败:', err)
uni.showToast({
title: '删除失败',
icon: 'none'
})
}
// 显示成功提示
this.showSuccessToast = true;
setTimeout(() => {
this.showSuccessToast = false;
}, 2000);
}
}
};

View File

@@ -42,6 +42,29 @@
/>
</view>
</view>
<view class="form-item">
<view class="form-label">所属单位</view>
<view class="form-value">
<input
class="form-input"
v-model="formData.organization"
placeholder="请输入所属单位"
/>
</view>
</view>
<view class="form-item">
<view class="form-label">联系电话</view>
<view class="form-value">
<input
class="form-input"
v-model="formData.phone"
type="number"
placeholder="请输入联系电话"
/>
</view>
</view>
</view>
<!-- 错误提示 -->
@@ -72,14 +95,19 @@
</template>
<script>
import athleteAPI from '@/api/athlete.js'
export default {
data() {
return {
playerId: '',
formData: {
idType: '身份证',
name: '张三',
idCard: '123456789000000000',
team: '少林寺武术学院'
name: '',
idCard: '',
team: '',
organization: '',
phone: ''
},
errors: [],
showHint: false,
@@ -94,7 +122,10 @@ export default {
this.formData.name &&
this.formData.idCard &&
this.formData.team &&
this.validateIdCard(this.formData.idCard)
this.formData.organization &&
this.formData.phone &&
this.validateIdCard(this.formData.idCard) &&
this.validatePhone(this.formData.phone)
);
}
},
@@ -107,27 +138,58 @@ export default {
},
'formData.team'(val) {
this.validateForm();
},
'formData.organization'(val) {
this.validateForm();
},
'formData.phone'(val) {
this.validateForm();
}
},
onLoad(options) {
if (options.id) {
// 加载选手数据
this.playerId = options.id
this.loadPlayerData(options.id);
}
},
methods: {
loadPlayerData(id) {
// 模拟加载数据
// 实际应该从后端获取
/**
* 加载选手数据
*/
async loadPlayerData(id) {
try {
const res = await athleteAPI.getAthleteDetail(id)
// 回显数据(使用后端实体类的字段名)
this.formData = {
idType: res.idCardType === 1 ? '身份证' : '其他',
name: res.playerName || '',
idCard: res.idCard || '',
team: res.teamName || '',
organization: res.organization || '',
phone: res.contactPhone || ''
}
} catch (err) {
console.error('加载选手数据失败:', err)
uni.showToast({
title: '加载失败',
icon: 'none'
})
}
},
validateIdCard(idCard) {
return /^\d{18}$/.test(idCard);
// 身份证号验证18位最后一位可以是数字或字母X
return /^\d{17}[\dXx]$/.test(idCard);
},
validatePhone(phone) {
// 手机号验证11位数字
return /^1[3-9]\d{9}$/.test(phone);
},
validateForm() {
this.errors = [];
this.showHint = false;
if (!this.formData.name || !this.formData.idCard || !this.formData.team) {
if (!this.formData.name || !this.formData.idCard || !this.formData.team || !this.formData.organization || !this.formData.phone) {
this.showHint = true;
this.errors.push({
label: '有空文本时弹出:',
@@ -141,20 +203,91 @@ export default {
message: '按钮置灰'
});
}
if (this.formData.phone && !this.validatePhone(this.formData.phone)) {
this.errors.push({
label: '手机号格式不正确:',
message: '按钮置灰'
});
}
},
handleSave() {
/**
* 从身份证号中提取信息
*/
extractInfoFromIdCard(idCard) {
if (!idCard || idCard.length !== 18) {
return {
gender: null,
age: null,
birthDate: null
}
}
// 提取出生日期
const year = idCard.substring(6, 10)
const month = idCard.substring(10, 12)
const day = idCard.substring(12, 14)
const birthDate = `${year}-${month}-${day}`
// 计算年龄
const birthYear = parseInt(year)
const currentYear = new Date().getFullYear()
const age = currentYear - birthYear
// 提取性别(倒数第二位,奇数为男,偶数为女)
const genderCode = parseInt(idCard.substring(16, 17))
const gender = genderCode % 2 === 1 ? 1 : 2
return {
gender,
age,
birthDate
}
},
async handleSave() {
if (!this.isFormValid) {
return;
}
this.toastMessage = '身份证号码格式不正确';
this.showToast = true;
setTimeout(() => {
this.showToast = false;
}, 2000);
try {
// 从身份证号中提取信息
const info = this.extractInfoFromIdCard(this.formData.idCard)
// 实际保存逻辑
// uni.navigateBack();
// 调用API更新选手信息使用后端实体类的字段名
await athleteAPI.submitAthlete({
id: this.playerId,
playerName: this.formData.name,
idCard: this.formData.idCard,
teamName: this.formData.team,
organization: this.formData.organization,
contactPhone: this.formData.phone,
idCardType: 1, // 身份证类型固定为1
gender: info.gender,
age: info.age,
birthDate: info.birthDate
})
// 保存成功
uni.showToast({
title: '保存成功',
icon: 'success'
})
// 延迟返回上一页
setTimeout(() => {
uni.navigateBack()
}, 1500)
} catch (err) {
console.error('保存选手失败:', err)
// 显示错误提示
this.toastMessage = '保存失败,请重试'
this.showToast = true
setTimeout(() => {
this.showToast = false
}, 2000)
}
}
}
};

View File

@@ -76,30 +76,98 @@
</template>
<script>
import competitionAPI from '@/api/competition.js'
export default {
data() {
return {
eventId: '',
eventInfo: {
id: 1,
title: '2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛',
location: '天津市-天津市体育中心',
registerTime: '2025.02.01-2025.02.10',
matchTime: '2025.02.01-2025.02.10',
registerCount: '25212',
status: 'open' // open, finished
id: '',
title: '',
location: '',
registerTime: '',
matchTime: '',
registerCount: '0',
status: 'open'
}
};
},
onLoad(options) {
if (options.id) {
this.loadEventDetail(options.id);
this.eventId = options.id
this.loadEventDetail(options.id)
}
},
methods: {
loadEventDetail(id) {
// 加载赛事详情
// 实际应该从后端获取
/**
* 加载赛事详情
* @param {String|Number} id 赛事ID
*/
async loadEventDetail(id) {
try {
const res = await competitionAPI.getCompetitionDetail(id)
console.log('赛事详情API返回:', res)
// 尝试多个可能的时间字段
const regStartTime = res.registrationStartTime || res.registerStartTime || res.signUpStartTime
const regEndTime = res.registrationEndTime || res.registerEndTime || res.signUpEndTime
const startTime = res.startTime || res.competitionStartTime || res.beginTime || res.startDate
const endTime = res.endTime || res.competitionEndTime || res.finishTime || res.endDate
// 数据映射
this.eventInfo = {
id: res.id,
title: res.name || res.title || res.competitionName || '未命名赛事',
location: res.location || res.address || res.venue || '待定',
registerTime: this.formatTimeRange(regStartTime, regEndTime) ||
res.registerTime || res.registrationPeriod || '待定',
matchTime: this.formatTimeRange(startTime, endTime) ||
res.matchTime || res.competitionTime || '待定',
registerCount: res.registrationCount || res.registerCount || res.signUpCount || '0',
status: this.getStatus(res.status)
}
console.log('格式化后的赛事信息:', this.eventInfo)
} catch (err) {
console.error('加载赛事详情失败:', err)
uni.showToast({
title: '加载失败,请重试',
icon: 'none'
})
}
},
/**
* 格式化时间范围
*/
formatTimeRange(startTime, endTime) {
if (!startTime || !endTime) return ''
const formatDate = (dateStr) => {
if (!dateStr) return ''
const date = new Date(dateStr)
const year = date.getFullYear()
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)}`
},
/**
* 获取赛事状态
*/
getStatus(status) {
// 1: 报名中, 2: 进行中, 3: 已结束
if (status === 3 || status === '3' || status === 'finished') {
return 'finished'
}
return 'open'
},
handleFunction(type) {
const routeMap = {
'info': '/pages/event-info/event-info',
@@ -115,7 +183,10 @@ export default {
const url = routeMap[type];
if (url) {
uni.navigateTo({ url });
// 跳转时传递赛事ID
uni.navigateTo({
url: `${url}?eventId=${this.eventId}`
})
} else {
uni.showToast({
title: '功能开发中',
@@ -202,8 +273,8 @@ export default {
}
.function-icon-img {
width: 120rpx;
height: 120rpx;
width: 90rpx;
height: 90rpx;
}
.function-text {
@@ -226,9 +297,9 @@ export default {
background-color: #C93639;
color: #fff;
text-align: center;
padding: 30rpx;
padding: 20rpx;
border-radius: 12rpx;
font-size: 32rpx;
font-size: 28rpx;
font-weight: bold;
}

View File

@@ -0,0 +1,233 @@
<template>
<view class="info-detail-page">
<!-- 信息标题 -->
<view class="detail-header">
<view class="info-tag" :class="infoDetail.type">{{ infoDetail.typeText }}</view>
<view class="info-title">{{ infoDetail.title }}</view>
<view class="info-time">
<text class="time-icon">🕐</text>
<text>{{ infoDetail.time }}</text>
</view>
</view>
<!-- 分割线 -->
<view class="divider"></view>
<!-- 信息内容 -->
<view class="detail-content">
<text class="content-text">{{ infoDetail.content }}</text>
</view>
<!-- 附件区域如果有 -->
<view class="attachments" v-if="infoDetail.attachments && infoDetail.attachments.length > 0">
<view class="attachment-title">附件</view>
<view class="attachment-item" v-for="(item, index) in infoDetail.attachments" :key="index">
<text class="attachment-icon">📎</text>
<text class="attachment-name">{{ item.name }}</text>
</view>
</view>
<!-- 底部操作栏 -->
<view class="bottom-bar">
<view class="bar-item" @click="handleShare">
<text class="bar-icon">📤</text>
<text class="bar-text">分享</text>
</view>
<view class="bar-item" @click="handleCollect">
<text class="bar-icon"></text>
<text class="bar-text">收藏</text>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
infoId: '',
infoDetail: {
id: '',
type: 'notice',
typeText: '通知',
title: '',
content: '',
time: '',
attachments: []
}
};
},
onLoad(options) {
console.log('详情页接收参数:', options)
if (options.id) {
this.infoId = options.id
}
// 接收从列表页传递的数据
if (options.type) {
this.infoDetail.type = options.type
}
if (options.typeText) {
this.infoDetail.typeText = decodeURIComponent(options.typeText)
}
if (options.title) {
this.infoDetail.title = decodeURIComponent(options.title)
}
if (options.content) {
this.infoDetail.content = decodeURIComponent(options.content)
}
if (options.time) {
this.infoDetail.time = decodeURIComponent(options.time)
}
},
methods: {
handleShare() {
uni.showToast({
title: '分享功能开发中',
icon: 'none'
})
},
handleCollect() {
uni.showToast({
title: '收藏成功',
icon: 'success'
})
}
}
};
</script>
<style lang="scss" scoped>
.info-detail-page {
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 120rpx;
}
.detail-header {
background-color: #fff;
padding: 40rpx 30rpx;
}
.info-tag {
display: inline-block;
font-size: 24rpx;
padding: 8rpx 20rpx;
border-radius: 8rpx;
color: #fff;
margin-bottom: 20rpx;
}
.info-tag.notice {
background-color: #C93639;
}
.info-tag.announcement {
background-color: #FF8C00;
}
.info-tag.important {
background-color: #DC143C;
}
.info-title {
font-size: 36rpx;
font-weight: bold;
color: #333333;
line-height: 1.5;
margin-bottom: 20rpx;
}
.info-time {
display: flex;
align-items: center;
gap: 10rpx;
font-size: 26rpx;
color: #999999;
}
.time-icon {
font-size: 28rpx;
}
.divider {
height: 20rpx;
background-color: #f5f5f5;
}
.detail-content {
background-color: #fff;
padding: 40rpx 30rpx;
min-height: 400rpx;
}
.content-text {
font-size: 30rpx;
color: #333333;
line-height: 1.8;
white-space: pre-wrap;
word-break: break-all;
}
.attachments {
background-color: #fff;
margin-top: 20rpx;
padding: 30rpx;
}
.attachment-title {
font-size: 28rpx;
font-weight: bold;
color: #333333;
margin-bottom: 20rpx;
}
.attachment-item {
display: flex;
align-items: center;
gap: 15rpx;
padding: 20rpx;
background-color: #f5f5f5;
border-radius: 12rpx;
margin-bottom: 15rpx;
}
.attachment-icon {
font-size: 32rpx;
}
.attachment-name {
flex: 1;
font-size: 28rpx;
color: #333333;
}
.bottom-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background-color: #fff;
display: flex;
padding: 20rpx 30rpx;
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.05);
}
.bar-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
gap: 10rpx;
}
.bar-icon {
font-size: 40rpx;
}
.bar-text {
font-size: 24rpx;
color: #666666;
}
</style>

View File

@@ -20,43 +20,180 @@
</template>
<script>
import infoAPI from '@/api/info.js'
export default {
data() {
return {
infoList: [
eventId: '',
infoList: []
};
},
onLoad(options) {
if (options.eventId) {
this.eventId = options.eventId
this.loadInfoList(options.eventId)
}
},
methods: {
/**
* 加载信息发布列表
*/
async loadInfoList(eventId) {
try {
const res = await infoAPI.getInfoPublishList({ competitionId: eventId })
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
// 如果后端没有数据,使用模拟数据
if (list.length === 0) {
list = this.getMockData()
}
// 数据映射
this.infoList = list.map(item => ({
id: item.id,
type: this.getInfoType(item.infoType || item.info_type || item.type),
typeText: this.getInfoTypeText(item.infoType || item.info_type || item.type),
title: item.title || item.infoTitle,
desc: item.content || item.description || item.infoContent || '',
time: this.formatTime(item.publishTime || item.publish_time || item.createTime)
}))
} catch (err) {
console.error('加载信息列表失败:', err)
// 加载失败时使用模拟数据
const list = this.getMockData()
this.infoList = list.map(item => ({
id: item.id,
type: this.getInfoType(item.info_type || item.type),
typeText: this.getInfoTypeText(item.info_type || item.type),
title: item.title,
desc: item.content,
time: this.formatTime(item.publishTime)
}))
}
},
/**
* 获取模拟数据
*/
getMockData() {
return [
{
id: 1,
type: 'notice',
typeText: '通知',
title: '关于赛事报名截止时间的通知',
desc: '本次赛事报名将于2025年2月10日24:00截止请各位选手抓紧时间报名...',
time: '2025-01-20 10:30'
info_type: 3,
title: '重要通知:赛事报名截止时间变更',
content: '由于场馆调整本次赛事报名截止时间延长至2025年12月20日请各位选手抓紧时间报名。如有疑问请联系赛事组委会。',
publishTime: '2025-01-10 09:00:00'
},
{
id: 2,
type: 'announcement',
typeText: '公告',
title: '比赛场地变更公告',
desc: '因场馆维护比赛场地由原定的A馆变更为B馆请各位参赛选手注意...',
time: '2025-01-18 14:20'
info_type: 1,
title: '参赛选手须知',
content: '请各位参赛选手提前1小时到达比赛场地进行检录携带身份证原件及复印件。比赛期间请遵守赛场纪律服从裁判判决。',
publishTime: '2025-01-09 14:30:00'
},
{
id: 3,
type: 'important',
typeText: '重要',
title: '疫情防控须知',
desc: '所有参赛人员需提供48小时内核酸检测阴性证明并配合现场测温...',
time: '2025-01-15 09:00'
info_type: 2,
title: '比赛场地及交通指引',
content: '本次赛事在市体育中心举行地址XX市XX区XX路100号。可乘坐地铁2号线至体育中心站下车或乘坐公交车88路、99路至体育中心站。场馆提供免费停车位。',
publishTime: '2025-01-08 16:00:00'
},
{
id: 4,
info_type: 1,
title: '赛前训练安排通知',
content: '为方便各位选手熟悉场地组委会安排在比赛前一天12月24日下午14:00-17:00开放场地供选手训练。请需要训练的选手提前联系组委会预约。',
publishTime: '2025-01-07 10:20:00'
},
{
id: 5,
info_type: 2,
title: '比赛流程及注意事项',
content: '比赛采用淘汰赛制分为预赛、半决赛和决赛三个阶段。每场比赛时长为5分钟选手需提前做好热身准备。比赛过程中严禁使用违禁器材。',
publishTime: '2025-01-06 11:45:00'
},
{
id: 6,
info_type: 1,
title: '医疗保障及安全提示',
content: '赛事现场配备专业医疗团队和救护车,设有医疗服务点。建议选手自备常用药品,如有特殊疾病请提前告知组委会。比赛前请充分热身,避免受伤。',
publishTime: '2025-01-05 15:10:00'
},
{
id: 7,
info_type: 3,
title: '关于赛事直播安排的通知',
content: '本次赛事将进行全程网络直播届时可通过官方网站和APP观看。精彩瞬间将在赛后剪辑发布敬请期待',
publishTime: '2025-01-04 13:00:00'
},
{
id: 8,
info_type: 2,
title: '志愿者招募公告',
content: '赛事组委会现招募志愿者50名负责现场引导、秩序维护、后勤保障等工作。有意者请扫描海报二维码报名报名截止时间为12月15日。',
publishTime: '2025-01-03 09:30:00'
}
]
};
},
methods: {
},
/**
* 获取信息类型样式类名
*/
getInfoType(type) {
const typeMap = {
1: 'notice',
2: 'announcement',
3: 'important',
'notice': 'notice',
'announcement': 'announcement',
'important': 'important'
}
return typeMap[type] || 'notice'
},
/**
* 获取信息类型文本
*/
getInfoTypeText(type) {
const typeMap = {
1: '通知',
2: '公告',
3: '重要',
'notice': '通知',
'announcement': '公告',
'important': '重要'
}
return typeMap[type] || '通知'
},
/**
* 格式化时间
*/
formatTime(timeStr) {
if (!timeStr) return ''
const date = new Date(timeStr)
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}`
},
handleItemClick(item) {
uni.showToast({
title: '查看详情',
icon: 'none'
});
// 跳转到信息详情页
uni.navigateTo({
url: `/pages/event-info-detail/event-info-detail?id=${item.id}&type=${item.type}&typeText=${encodeURIComponent(item.typeText)}&title=${encodeURIComponent(item.title)}&content=${encodeURIComponent(item.desc)}&time=${encodeURIComponent(item.time)}`
})
}
}
};

View File

@@ -100,6 +100,8 @@
</template>
<script>
import competitionAPI from '@/api/competition.js'
export default {
data() {
return {
@@ -112,58 +114,176 @@ export default {
areaPickerValue: [0],
dateOptions: ['2025-04-09', '2025-04-10', '2025-04-11'],
areaOptions: ['乌鲁木齐', '天津市', '北京市'],
eventList: [
{
id: 1,
title: '2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛',
location: '天津市-天津市体育中心',
registerTime: '2025.02.01-2025.02.10',
matchTime: '2025.02.01-2025.02.10',
registerCount: '25212',
status: 'open'
},
{
id: 2,
title: '2025年全国武术套路锦标赛',
location: '天津市-天津市体育中心',
registerTime: '2025.02.01-2025.02.10',
matchTime: '2025.02.01-2025.02.10',
registerCount: '25212',
status: 'finished'
},
{
id: 3,
title: '2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛',
location: '天津市-天津市体育中心',
registerTime: '2025.02.01-2025.02.10',
matchTime: '2025.02.01-2025.02.10',
registerCount: '25212',
status: 'open'
},
{
id: 4,
title: '2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛',
location: '天津市-天津市体育中心',
registerTime: '2025.02.01-2025.02.10',
matchTime: '2025.02.01-2025.02.10',
registerCount: '25212',
status: 'open'
}
]
eventList: [],
// 分页参数
pageParams: {
current: 1,
size: 20
},
hasMore: true
};
},
onLoad() {
this.loadEventList()
},
// 下拉刷新
onPullDownRefresh() {
this.pageParams.current = 1
this.loadEventList(true)
},
// 上拉加载更多
onReachBottom() {
if (this.hasMore) {
this.pageParams.current++
this.loadEventList(false, true)
}
},
computed: {
filteredEventList() {
return this.eventList.filter(item => {
if (this.searchText && !item.title.includes(this.searchText)) {
return false;
}
// 可以添加更多筛选条件
return true;
});
// 前端筛选(作为后备方案)
let list = this.eventList
// 如果有搜索关键字,进行前端筛选
if (this.searchText) {
list = list.filter(item => item.title && item.title.includes(this.searchText))
}
return list
}
},
// 监听搜索关键字变化
watch: {
searchText(newVal, oldVal) {
// 防抖处理
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.pageParams.current = 1
this.loadEventList(true)
}, 500)
},
selectedDate() {
this.pageParams.current = 1
this.loadEventList(true)
},
selectedArea() {
this.pageParams.current = 1
this.loadEventList(true)
}
},
methods: {
/**
* 加载赛事列表
* @param {Boolean} refresh 是否刷新(重置列表)
* @param {Boolean} loadMore 是否加载更多(追加列表)
*/
async loadEventList(refresh = false, loadMore = false) {
try {
// 构建查询参数
const params = {
current: this.pageParams.current,
size: this.pageParams.size
}
// 添加搜索关键字
// 注意:后端接口参数名待确认,可能是 name/keyword/search
if (this.searchText) {
params.name = this.searchText
}
// 添加地区筛选
if (this.selectedArea) {
params.location = this.selectedArea
}
// 调用API
const res = await competitionAPI.getCompetitionList(params)
console.log('赛事列表API返回:', res)
let list = []
let total = 0
// 处理分页数据
if (res.records) {
list = res.records
total = res.total || 0
} else if (Array.isArray(res)) {
list = res
total = res.length
}
// 数据映射
const mappedList = list.map(item => {
// 尝试多个可能的时间字段
const regStartTime = item.registrationStartTime || item.registerStartTime || item.signUpStartTime
const regEndTime = item.registrationEndTime || item.registerEndTime || item.signUpEndTime
const startTime = item.startTime || item.competitionStartTime || item.beginTime
const endTime = item.endTime || item.competitionEndTime || item.finishTime
return {
id: item.id,
title: item.name || item.title || item.competitionName || '未命名赛事',
location: item.location || item.address || item.venue || '待定',
registerTime: this.formatTimeRange(regStartTime, regEndTime) ||
item.registerTime || item.registrationPeriod || '待定',
matchTime: this.formatTimeRange(startTime, endTime) ||
item.matchTime || item.competitionTime || '待定',
registerCount: item.registrationCount || item.registerCount || item.signUpCount || '0',
status: this.getStatus(item.status)
}
})
console.log('格式化后的赛事列表:', mappedList)
// 刷新或加载更多
if (refresh || !loadMore) {
this.eventList = mappedList
} else {
this.eventList = [...this.eventList, ...mappedList]
}
// 判断是否还有更多数据
this.hasMore = this.eventList.length < total
// 停止下拉刷新
if (refresh) {
uni.stopPullDownRefresh()
}
} catch (err) {
console.error('加载赛事列表失败:', err)
uni.stopPullDownRefresh()
}
},
/**
* 格式化时间范围
*/
formatTimeRange(startTime, endTime) {
if (!startTime || !endTime) return ''
const formatDate = (dateStr) => {
if (!dateStr) return ''
const date = new Date(dateStr)
const year = date.getFullYear()
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)}`
},
/**
* 获取赛事状态
*/
getStatus(status) {
// 1: 报名中, 2: 进行中, 3: 已结束
if (status === 3 || status === '3' || status === 'finished') {
return 'finished'
}
return 'open'
},
handleDateChange(e) {
this.datePickerValue = e.detail.value;
},

View File

@@ -29,47 +29,108 @@
</template>
<script>
import infoAPI from '@/api/info.js'
export default {
data() {
return {
liveList: [
{
time: '16:45',
type: 'highlight',
typeText: '精彩瞬间',
content: '张三选手以一记精彩的侧踢得分,现场观众掌声雷动!',
images: []
},
{
time: '16:30',
type: 'score',
typeText: '比分',
content: '男子散打决赛:张三 3:2 李四,比赛进入白热化阶段',
images: []
},
{
time: '16:15',
type: 'news',
typeText: '赛况',
content: '男子散打决赛正式开始,双方选手入场,裁判宣读比赛规则',
images: []
},
{
time: '16:00',
type: 'news',
typeText: '赛况',
content: '上一场比赛结束,场地准备中...',
images: []
},
{
time: '15:45',
type: 'highlight',
typeText: '精彩瞬间',
content: '半决赛第二场,王五选手表现出色,成功晋级决赛',
images: []
}
]
eventId: '',
liveList: []
};
},
onLoad(options) {
if (options.eventId) {
this.eventId = options.eventId
this.loadLiveList(options.eventId)
}
},
// 下拉刷新
onPullDownRefresh() {
this.loadLiveList(this.eventId, true)
},
methods: {
/**
* 加载比赛实况列表
*/
async loadLiveList(eventId, refresh = false) {
try {
const res = await infoAPI.getLiveUpdateList({ competitionId: eventId })
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
// 数据映射
this.liveList = list.map(item => ({
time: this.formatTime(item.updateTime || item.time || item.createTime),
type: this.getLiveType(item.type || item.updateType),
typeText: this.getLiveTypeText(item.type || item.updateType),
content: item.content || item.updateContent || '',
images: item.images || item.imageList || []
}))
// 停止下拉刷新
if (refresh) {
uni.stopPullDownRefresh()
}
} catch (err) {
console.error('加载实况列表失败:', err)
if (refresh) {
uni.stopPullDownRefresh()
}
}
},
/**
* 获取实况类型样式类名
*/
getLiveType(type) {
const typeMap = {
1: 'highlight',
2: 'score',
3: 'news',
'highlight': 'highlight',
'score': 'score',
'news': 'news'
}
return typeMap[type] || 'news'
},
/**
* 获取实况类型文本
*/
getLiveTypeText(type) {
const typeMap = {
1: '精彩瞬间',
2: '比分',
3: '赛况',
'highlight': '精彩瞬间',
'score': '比分',
'news': '赛况'
}
return typeMap[type] || '赛况'
},
/**
* 格式化时间(只取时分)
*/
formatTime(timeStr) {
if (!timeStr) return ''
// 如果已经是 HH:MM 格式
if (/^\d{2}:\d{2}$/.test(timeStr)) {
return timeStr
}
const date = new Date(timeStr)
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
return `${hours}:${minutes}`
}
}
};
</script>

View File

@@ -42,19 +42,13 @@
</template>
<script>
import resultAPI from '@/api/result.js'
export default {
data() {
return {
medalsList: [
{ rank: 1, team: '北京队', gold: 8, silver: 5, bronze: 3, total: 16 },
{ rank: 2, team: '上海队', gold: 6, silver: 7, bronze: 5, total: 18 },
{ rank: 3, team: '广东队', gold: 5, silver: 4, bronze: 6, total: 15 },
{ rank: 4, team: '天津队', gold: 4, silver: 5, bronze: 4, total: 13 },
{ rank: 5, team: '江苏队', gold: 3, silver: 3, bronze: 5, total: 11 },
{ rank: 6, team: '浙江队', gold: 2, silver: 4, bronze: 3, total: 9 },
{ rank: 7, team: '湖北队', gold: 2, silver: 2, bronze: 4, total: 8 },
{ rank: 8, team: '河北队', gold: 1, silver: 3, bronze: 2, total: 6 }
]
eventId: '',
medalsList: []
};
},
computed: {
@@ -64,6 +58,41 @@ export default {
totalMedals() {
return this.medalsList.reduce((sum, item) => sum + item.total, 0);
}
},
onLoad(options) {
if (options.eventId) {
this.eventId = options.eventId
this.loadMedalsList(options.eventId)
}
},
methods: {
/**
* 加载奖牌榜
*/
async loadMedalsList(eventId) {
try {
const res = await resultAPI.getMedalsList(eventId)
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
// 数据映射
this.medalsList = list.map((item, index) => ({
rank: item.rank || item.ranking || (index + 1),
team: item.teamName || item.team,
gold: item.goldMedals || item.gold || 0,
silver: item.silverMedals || item.silver || 0,
bronze: item.bronzeMedals || item.bronze || 0,
total: item.totalMedals || item.total || 0
}))
} catch (err) {
console.error('加载奖牌榜失败:', err)
}
}
}
};
</script>

View File

@@ -2,8 +2,13 @@
<view class="event-players-page">
<!-- 搜索框 -->
<view class="search-bar">
<input class="search-input" placeholder="搜索选手姓名或编号" v-model="searchKey" />
<view class="search-icon">🔍</view>
<input
class="search-input"
placeholder="搜索选手姓名或编号"
v-model="searchKey"
@confirm="handleSearch"
/>
<view class="search-icon" @click="handleSearch">🔍</view>
</view>
<!-- 分类筛选 -->
@@ -12,83 +17,211 @@
class="category-tab"
v-for="(category, index) in categories"
:key="index"
:class="{ active: currentCategory === index }"
@click="currentCategory = index"
:class="{ active: currentCategory === category.value }"
@click="handleCategoryChange(category.value)"
>
{{ category }}
{{ category.label }}
</view>
</view>
<!-- 统计信息 -->
<view class="stats-bar" v-if="totalCount > 0">
<text class="stats-text"> {{ totalCount }} 名选手</text>
<text class="stats-text">已确认 {{ confirmedCount }} </text>
</view>
<!-- 选手列表 -->
<view class="players-list">
<view class="player-item" v-for="(player, index) in playersList" :key="index">
<view class="player-number">{{ player.number }}</view>
<view class="players-list" v-if="playersList.length > 0">
<view
class="player-item"
v-for="(player, index) in playersList"
:key="player.id"
@click="handlePlayerClick(player)"
>
<view class="player-number">{{ player.playerNo || (index + 1).toString().padStart(3, '0') }}</view>
<view class="player-info">
<view class="player-name">{{ player.name }}</view>
<view class="player-name">
{{ player.playerName }}
<text class="gender-tag" v-if="player.gender">{{ player.gender === 1 ? '' : '' }}</text>
</view>
<view class="player-detail">
<text class="detail-text">{{ player.team }}</text>
<text class="detail-divider">|</text>
<text class="detail-text">{{ player.category }}</text>
<text class="detail-text" v-if="player.organization">{{ player.organization }}</text>
<text class="detail-divider" v-if="player.organization && player.projectName">|</text>
<text class="detail-text" v-if="player.projectName">{{ player.projectName }}</text>
</view>
<view class="player-extra" v-if="player.category">
<text class="extra-text">{{ player.category }}</text>
</view>
</view>
<view class="player-status" :class="player.status">
{{ player.statusText }}
<view class="player-status" :class="getStatusClass(player.registrationStatus)">
{{ getStatusText(player.registrationStatus) }}
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-state" v-else-if="!loading">
<text class="empty-icon">👤</text>
<text class="empty-text">暂无参赛选手</text>
</view>
<!-- 加载状态 -->
<view class="loading-state" v-if="loading">
<text class="loading-text">加载中...</text>
</view>
<!-- 加载更多 -->
<view class="load-more" v-if="hasMore && !loading" @click="loadMore">
<text class="load-more-text">加载更多</text>
</view>
</view>
</template>
<script>
import athleteAPI from '@/api/athlete.js'
export default {
data() {
return {
eventId: '',
searchKey: '',
currentCategory: 0,
categories: ['全部', '男子组', '女子组'],
playersList: [
{
number: '001',
name: '张三',
team: '北京队',
category: '男子散打',
status: 'confirmed',
statusText: '已确认'
},
{
number: '002',
name: '李四',
team: '上海队',
category: '男子散打',
status: 'confirmed',
statusText: '已确认'
},
{
number: '003',
name: '王五',
team: '广东队',
category: '男子套路',
status: 'pending',
statusText: '待确认'
},
{
number: '004',
name: '赵六',
team: '天津队',
category: '男子散打',
status: 'confirmed',
statusText: '已确认'
},
{
number: '005',
name: '刘七',
team: '江苏队',
category: '男子套路',
status: 'confirmed',
statusText: '已确认'
}
]
currentCategory: '',
categories: [
{ label: '全部', value: '' },
{ label: '男子组', value: '1' },
{ label: '女子组', value: '2' }
],
playersList: [],
totalCount: 0,
confirmedCount: 0,
loading: false,
page: 1,
pageSize: 20,
hasMore: true
};
},
onLoad(options) {
if (options.eventId) {
this.eventId = options.eventId
this.loadPlayersList()
}
},
methods: {
/**
* 加载选手列表
*/
async loadPlayersList(isLoadMore = false) {
if (this.loading) return
this.loading = true
try {
const params = {
competitionId: this.eventId,
current: isLoadMore ? this.page : 1,
size: this.pageSize
}
// 添加搜索条件
if (this.searchKey) {
params.playerName = this.searchKey
}
// 添加性别筛选
if (this.currentCategory) {
params.gender = this.currentCategory
}
const res = await athleteAPI.getAthleteList(params)
if (res.code === 200 && res.data) {
const records = res.data.records || []
if (isLoadMore) {
this.playersList = [...this.playersList, ...records]
} else {
this.playersList = records
this.page = 1
}
this.totalCount = res.data.total || 0
this.hasMore = this.playersList.length < this.totalCount
// 统计已确认人数
this.confirmedCount = this.playersList.filter(p => p.registrationStatus === 1).length
}
} catch (error) {
console.error('加载选手列表失败:', error)
uni.showToast({
title: '加载失败,请重试',
icon: 'none'
})
} finally {
this.loading = false
}
},
/**
* 搜索
*/
handleSearch() {
this.page = 1
this.loadPlayersList()
},
/**
* 切换分类
*/
handleCategoryChange(value) {
this.currentCategory = value
this.page = 1
this.loadPlayersList()
},
/**
* 加载更多
*/
loadMore() {
if (this.hasMore && !this.loading) {
this.page++
this.loadPlayersList(true)
}
},
/**
* 点击选手
*/
handlePlayerClick(player) {
// 可以跳转到选手详情页
uni.showToast({
title: `选手:${player.playerName}`,
icon: 'none'
})
},
/**
* 获取状态样式类
*/
getStatusClass(status) {
const statusMap = {
0: 'pending', // 待确认
1: 'confirmed', // 已确认
2: 'cancelled' // 已取消
}
return statusMap[status] || 'pending'
},
/**
* 获取状态文本
*/
getStatusText(status) {
const statusMap = {
0: '待确认',
1: '已确认',
2: '已取消'
}
return statusMap[status] || '未知'
}
}
};
</script>
@@ -97,6 +230,7 @@ export default {
.event-players-page {
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 20rpx;
}
.search-bar {
@@ -117,6 +251,7 @@ export default {
.search-icon {
font-size: 32rpx;
cursor: pointer;
}
.category-tabs {
@@ -133,6 +268,7 @@ export default {
font-size: 26rpx;
color: #666666;
background-color: #f5f5f5;
transition: all 0.3s;
}
.category-tab.active {
@@ -140,8 +276,21 @@ export default {
color: #fff;
}
.stats-bar {
background-color: #fff;
padding: 20rpx 30rpx;
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
}
.stats-text {
font-size: 26rpx;
color: #666666;
}
.players-list {
padding: 0 30rpx 20rpx;
padding: 0 30rpx;
}
.player-item {
@@ -152,6 +301,12 @@ export default {
display: flex;
align-items: center;
gap: 20rpx;
transition: all 0.3s;
&:active {
background-color: #f8f8f8;
transform: scale(0.98);
}
}
.player-number {
@@ -170,6 +325,7 @@ export default {
.player-info {
flex: 1;
min-width: 0;
}
.player-name {
@@ -177,17 +333,38 @@ export default {
font-weight: bold;
color: #333333;
margin-bottom: 8rpx;
display: flex;
align-items: center;
gap: 10rpx;
}
.gender-tag {
font-size: 20rpx;
padding: 4rpx 12rpx;
border-radius: 4rpx;
background-color: #E3F2FD;
color: #2196F3;
font-weight: normal;
}
.player-detail {
font-size: 24rpx;
color: #666666;
margin-bottom: 6rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.detail-divider {
margin: 0 10rpx;
}
.player-extra {
font-size: 22rpx;
color: #999999;
}
.player-status {
padding: 8rpx 20rpx;
border-radius: 8rpx;
@@ -204,4 +381,50 @@ export default {
background-color: #FFF3E0;
color: #FF9800;
}
.player-status.cancelled {
background-color: #FFEBEE;
color: #F44336;
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120rpx 0;
gap: 20rpx;
}
.empty-icon {
font-size: 120rpx;
opacity: 0.3;
}
.empty-text {
font-size: 28rpx;
color: #999999;
}
.loading-state {
display: flex;
justify-content: center;
padding: 40rpx 0;
}
.loading-text {
font-size: 28rpx;
color: #999999;
}
.load-more {
display: flex;
justify-content: center;
padding: 30rpx 0;
}
.load-more-text {
font-size: 28rpx;
color: #C93639;
}
</style>

View File

@@ -20,7 +20,7 @@
<!-- 步骤1选择选手信息 -->
<view class="step-content" v-if="currentStep === 1">
<view class="selected-count">已选<text class="count">26</text> </view>
<view class="selected-count">已选<text class="count">{{ selectedCount }}</text> </view>
<view class="add-player-btn" @click="goToAddPlayer">
<text class="add-icon"></text>
@@ -82,7 +82,9 @@
<view class="info-hint">(注意是否用此号码接收信息)</view>
<view class="info-item participants-item">
<text class="label">参赛选手</text>
<text class="value participants">{{ eventInfo.participants }}</text>
<text class="value participants" style="color: #C93639; font-weight: bold;">
{{ eventInfo.participants || '未选择选手' }}
</text>
<view class="view-cert-btn" @click="showPlayers">
<text>查看证件</text>
<text class="arrow"></text>
@@ -93,11 +95,11 @@
<view class="payment-info">
<view class="payment-row">
<text class="label">人数</text>
<text class="value">26</text>
<text class="value">{{ selectedCount }}</text>
</view>
<view class="payment-row total">
<text class="label">合计</text>
<text class="value price">¥ 29999</text>
<text class="value price">¥ {{ totalPrice }}</text>
</view>
</view>
@@ -130,7 +132,7 @@
<text class="value">{{ eventInfo.contact }}</text>
</view>
<view class="participants-title">参赛选手26</view>
<view class="participants-title">参赛选手{{ selectedPlayers.length }}</view>
<view class="participants-detail">
<view class="participant-item" v-for="(item, index) in selectedPlayers" :key="index">
<view class="participant-name">{{ item.name }}</view>
@@ -166,63 +168,199 @@
</template>
<script>
import competitionAPI from '@/api/competition.js'
import athleteAPI from '@/api/athlete.js'
import registrationAPI from '@/api/registration.js'
export default {
data() {
return {
currentStep: 1,
eventId: '',
selectedProjects: [],
eventInfo: {
title: '2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛',
location: '天津市-天津市体育中心',
matchTime: '2025.02.01-2025.02.10',
projects: '男子组剑术、男子组太极拳、男子组套路、男子组其他项目',
contact: '18666666666',
participants: '张三、李四、王二、张三、张三、李四、王二、张三、李四'
title: '',
location: '',
matchTime: '',
projects: '',
contact: '',
participants: ''
},
playerList: [
{
id: 1,
name: '张三',
idCard: '123456789000000000',
selected: false
},
{
id: 2,
name: '张三',
idCard: '123456789000000000',
selected: true
},
{
id: 3,
name: '张三',
idCard: '123456789000000000',
selected: true
}
],
selectedPlayers: [
{
name: '张三',
idCard: '123456789000000000',
number: '123-4567898275'
},
{
name: '李四',
idCard: '123456789000000000',
number: '123-4567898276'
}
],
showPlayerModal: false
playerList: [],
selectedPlayers: [],
showPlayerModal: false,
totalPrice: 0,
registrationId: ''
};
},
computed: {
selectedCount() {
return this.playerList.filter(item => item.selected).length
},
participantsText() {
return this.playerList
.filter(item => item.selected)
.map(item => item.name)
.join('、')
}
},
onLoad(options) {
if (options.eventId) {
this.eventId = options.eventId;
this.eventId = options.eventId
this.loadEventDetail(options.eventId)
}
if (options.projects) {
try {
// 尝试解码(可能被双重编码)
let projectsStr = decodeURIComponent(options.projects)
// 如果还包含 %,说明被双重编码了,再解码一次
if (projectsStr.includes('%')) {
projectsStr = decodeURIComponent(projectsStr)
}
this.selectedProjects = JSON.parse(projectsStr)
} catch (err) {
console.error('解析项目数据失败:', err)
}
}
// 加载选手列表
this.loadPlayerList()
},
onShow() {
// 从新增/编辑页面返回时重新加载列表
if (this.currentStep === 1) {
this.loadPlayerList()
}
},
methods: {
/**
* 加载赛事详情
*/
async loadEventDetail(id) {
try {
const res = await competitionAPI.getCompetitionDetail(id)
// 尝试多个可能的时间字段名
const startTime = res.startTime || res.competitionStartTime || res.beginTime || res.startDate
const endTime = res.endTime || res.competitionEndTime || res.finishTime || res.endDate
// 如果没有时间字段,尝试使用其他字段
let matchTime = this.formatTimeRange(startTime, endTime)
if (!matchTime && res.matchTime) {
matchTime = res.matchTime
} else if (!matchTime && res.competitionTime) {
matchTime = res.competitionTime
} else if (!matchTime) {
matchTime = '待定'
}
this.eventInfo = {
title: res.name || res.title || res.competitionName || '未命名赛事',
location: res.location || res.address || res.venue || '待定',
matchTime: matchTime,
projects: this.selectedProjects && this.selectedProjects.length > 0
? this.selectedProjects.map(p => p.name).join('、')
: '',
contact: res.contactPhone || res.contact || res.phone || '',
participants: ''
}
} catch (err) {
console.error('加载赛事详情失败:', err)
// 设置默认值,防止页面显示空白
this.eventInfo = {
title: '未命名赛事',
location: '待定',
matchTime: '待定',
projects: '',
contact: '',
participants: ''
}
}
},
/**
* 加载选手列表
*/
async loadPlayerList() {
try {
const res = await athleteAPI.getAthleteList({
current: 1,
size: 100
})
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
// 数据映射 - 尝试多个可能的字段名
this.playerList = list.map(item => ({
id: item.id,
// 尝试多个可能的姓名字段
name: item.name || item.athleteName || item.playerName || item.realName || item.userName || '未命名',
// 尝试多个可能的身份证字段
idCard: item.idCard || item.idCardNumber || item.idCardNo || item.identityCard || '',
selected: false
}))
} catch (err) {
console.error('加载选手列表失败:', err)
uni.showToast({
title: '加载选手列表失败',
icon: 'none'
})
}
},
/**
* 格式化时间范围
*/
formatTimeRange(startTime, endTime) {
if (!startTime || !endTime) return ''
const formatDate = (dateStr) => {
if (!dateStr) return ''
const date = new Date(dateStr)
const year = date.getFullYear()
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)}`
},
/**
* 计算总价
*/
calculateTotalPrice() {
const count = this.selectedCount
if (!this.selectedProjects || this.selectedProjects.length === 0) {
return 0
}
// 计算所有项目的总价(将字符串转换为数字)
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) {
item.selected = !item.selected;
this.$forceUpdate();
const index = this.playerList.findIndex(p => p.id === item.id)
if (index !== -1) {
const newValue = !this.playerList[index].selected
this.$set(this.playerList[index], 'selected', newValue)
}
},
goToAddPlayer() {
uni.navigateTo({
@@ -234,27 +372,157 @@ export default {
url: '/pages/edit-player/edit-player?id=' + item.id
});
},
handleDelete(item) {
uni.showModal({
title: '删除选手',
content: '确定要删除该选手吗?',
success: (res) => {
if (res.confirm) {
const index = this.playerList.findIndex(p => p.id === item.id);
if (index > -1) {
this.playerList.splice(index, 1);
}
async handleDelete(item) {
try {
const confirmRes = await new Promise((resolve) => {
uni.showModal({
title: '删除选手',
content: '确定要删除该选手吗?',
success: (res) => resolve(res)
})
})
if (confirmRes.confirm) {
await athleteAPI.removeAthlete(item.id)
const index = this.playerList.findIndex(p => p.id === item.id);
if (index > -1) {
this.playerList.splice(index, 1);
}
uni.showToast({
title: '删除成功',
icon: 'success'
})
}
});
} catch (err) {
console.error('删除选手失败:', err)
uni.showToast({
title: '删除失败',
icon: 'none'
})
}
},
goToStep2() {
this.currentStep = 2;
const selected = this.playerList.filter(item => item.selected)
if (selected.length === 0) {
uni.showToast({
title: '请至少选择一名选手',
icon: 'none'
})
return
}
// 更新参赛选手信息
const participantsText = selected.map(p => p.name).join('、')
// 使用 $set 确保响应式更新
this.$set(this.eventInfo, 'participants', participantsText)
this.totalPrice = this.calculateTotalPrice()
// 延迟切换步骤,确保数据更新完成
this.$nextTick(() => {
this.currentStep = 2
})
},
goToStep3() {
this.currentStep = 3;
async goToStep3() {
try {
// 获取选中的选手
const selected = this.playerList.filter(item => item.selected)
// 检查必填字段
if (!this.eventId) {
uni.showToast({
title: '赛事ID缺失',
icon: 'none'
})
return
}
if (!this.selectedProjects || this.selectedProjects.length === 0) {
uni.showToast({
title: '请选择报名项目',
icon: 'none'
})
return
}
if (selected.length === 0) {
uni.showToast({
title: '请选择参赛选手',
icon: 'none'
})
return
}
// 生成订单号:格式 BMyyyyMMddHHmmss + 随机4位数
const now = new Date()
const year = now.getFullYear()
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都是数字类型
const submitData = {
orderNo: orderNo,
competitionId: parseInt(this.eventId),
projectIds: this.selectedProjects.map(p => parseInt(p.id)),
athleteIds: selected.map(p => parseInt(p.id)),
contactPhone: this.eventInfo.contact || '',
totalAmount: parseFloat(this.totalPrice) || 0
}
console.log('=== 提交报名数据 ===')
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)
// 保存报名ID
this.registrationId = res.id || res.registrationId
// 更新选中的选手列表(包含编号)
this.selectedPlayers = selected.map(item => ({
name: item.name,
idCard: item.idCard,
number: item.number || `${this.registrationId}-${item.id}`
}))
this.currentStep = 3;
uni.showToast({
title: '报名成功',
icon: 'success'
})
} catch (err) {
console.error('提交报名失败:', err)
uni.showToast({
title: '报名失败,请重试',
icon: 'none'
})
}
},
showPlayers() {
// 更新选中的选手列表
this.selectedPlayers = this.playerList
.filter(item => item.selected)
.map(item => ({
name: item.name,
idCard: item.idCard,
number: ''
}))
this.showPlayerModal = true;
},
handleClose() {

View File

@@ -1,28 +1,134 @@
<template>
<view class="event-rules-page">
<!-- 章节列表 -->
<view class="rules-list">
<view class="rules-item" v-for="(item, index) in rulesList" :key="index" @click="toggleSection(index)">
<view class="rules-header">
<view class="chapter-number">{{ item.chapter }}</view>
<view class="chapter-title">{{ item.title }}</view>
<view class="arrow" :class="{ expanded: item.expanded }"></view>
</view>
<view class="rules-content" v-if="item.expanded">
<view class="content-item" v-for="(content, idx) in item.contents" :key="idx">
<text class="content-text">{{ content }}</text>
<!-- 附件下载区 -->
<view class="attachments-section" v-if="attachments.length > 0">
<view class="section-title">
<text class="title-icon">📎</text>
<text class="title-text">规程附件</text>
</view>
<view class="attachments-list">
<view class="attachment-item" v-for="(file, index) in attachments" :key="index" @click="downloadFile(file)">
<view class="file-info">
<text class="file-icon">{{ getFileIcon(file.fileType) }}</text>
<view class="file-details">
<text class="file-name">{{ file.fileName }}</text>
<text class="file-size">{{ file.fileSize }}</text>
</view>
</view>
<view class="download-btn">
<text class="download-icon"></text>
</view>
</view>
</view>
</view>
<!-- 规程内容区 -->
<view class="content-section" v-if="rulesList.length > 0">
<view class="section-title">
<text class="title-icon">📄</text>
<text class="title-text">规程内容</text>
</view>
<view class="rules-list">
<view class="rules-item" v-for="(item, index) in rulesList" :key="index" @click="toggleSection(index)">
<view class="rules-header">
<view class="chapter-number">{{ item.chapter }}</view>
<view class="chapter-title">{{ item.title }}</view>
<view class="arrow" :class="{ expanded: item.expanded }"></view>
</view>
<view class="rules-content" v-if="item.expanded">
<view class="content-item" v-for="(content, idx) in item.contents" :key="idx">
<text class="content-text">{{ content }}</text>
</view>
</view>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-state" v-if="attachments.length === 0 && rulesList.length === 0">
<text class="empty-icon">📋</text>
<text class="empty-text">暂无规程信息</text>
</view>
</view>
</template>
<script>
import competitionAPI from '@/api/competition.js'
export default {
data() {
return {
rulesList: [
eventId: '',
// 附件列表
attachments: [],
// 规程章节列表
rulesList: []
};
},
onLoad(options) {
if (options.eventId) {
this.eventId = options.eventId
this.loadRulesData()
}
},
methods: {
/**
* 加载规程数据
*/
async loadRulesData() {
try {
// 调用API获取规程数据
const res = await competitionAPI.getCompetitionRules(this.eventId)
// 处理附件数据
if (res.attachments && res.attachments.length > 0) {
this.attachments = res.attachments.map(file => ({
id: file.id,
fileName: file.name || file.fileName,
fileUrl: file.url || file.fileUrl,
fileSize: this.formatFileSize(file.size || file.fileSize),
fileType: this.getFileType(file.name || file.fileName)
}))
}
// 处理规程内容数据
if (res.chapters && res.chapters.length > 0) {
this.rulesList = res.chapters.map(chapter => ({
chapter: chapter.chapterNumber || chapter.number,
title: chapter.title || chapter.name,
expanded: false,
contents: chapter.contents || chapter.items || []
}))
}
} catch (err) {
console.error('加载规程数据失败:', err)
// 如果API失败使用模拟数据
this.loadMockData()
}
},
/**
* 加载模拟数据(用于开发测试)
*/
loadMockData() {
this.attachments = [
{
id: '1',
fileName: '2025年郑州武术大赛规程.pdf',
fileUrl: 'https://example.com/rules.pdf',
fileSize: '2.5 MB',
fileType: 'pdf'
},
{
id: '2',
fileName: '参赛报名表.docx',
fileUrl: 'https://example.com/form.docx',
fileSize: '156 KB',
fileType: 'docx'
}
]
this.rulesList = [
{
chapter: '第一章',
title: '总则',
@@ -64,11 +170,102 @@ export default {
]
}
]
};
},
methods: {
},
/**
* 切换章节展开/收起
*/
toggleSection(index) {
this.rulesList[index].expanded = !this.rulesList[index].expanded;
this.rulesList[index].expanded = !this.rulesList[index].expanded
},
/**
* 下载文件
*/
downloadFile(file) {
uni.showLoading({
title: '准备下载'
})
// 下载文件
uni.downloadFile({
url: file.fileUrl,
success: (res) => {
if (res.statusCode === 200) {
// 保存文件到本地
const filePath = res.tempFilePath
// 打开文档
uni.openDocument({
filePath: filePath,
fileType: file.fileType,
success: () => {
uni.hideLoading()
uni.showToast({
title: '打开成功',
icon: 'success'
})
},
fail: (err) => {
uni.hideLoading()
console.error('打开文件失败:', err)
uni.showToast({
title: '打开失败',
icon: 'none'
})
}
})
}
},
fail: (err) => {
uni.hideLoading()
console.error('下载失败:', err)
uni.showToast({
title: '下载失败',
icon: 'none'
})
}
})
},
/**
* 获取文件类型
*/
getFileType(fileName) {
const ext = fileName.split('.').pop().toLowerCase()
return ext
},
/**
* 获取文件图标
*/
getFileIcon(fileType) {
const iconMap = {
'pdf': '📕',
'doc': '📘',
'docx': '📘',
'xls': '📗',
'xlsx': '📗',
'ppt': '📙',
'pptx': '📙',
'txt': '📄',
'zip': '📦',
'rar': '📦'
}
return iconMap[fileType] || '📄'
},
/**
* 格式化文件大小
*/
formatFileSize(bytes) {
if (!bytes || bytes === 0) return '0 B'
if (typeof bytes === 'string') return bytes
const k = 1024
const sizes = ['B', 'KB', 'MB', 'GB']
const i = Math.floor(Math.log(bytes) / Math.log(k))
return (bytes / Math.pow(k, i)).toFixed(2) + ' ' + sizes[i]
}
}
};
@@ -81,6 +278,108 @@ export default {
padding: 20rpx 30rpx;
}
// 区块标题
.section-title {
display: flex;
align-items: center;
gap: 10rpx;
margin-bottom: 20rpx;
padding: 0 10rpx;
}
.title-icon {
font-size: 32rpx;
}
.title-text {
font-size: 30rpx;
font-weight: bold;
color: #333333;
}
// 附件下载区
.attachments-section {
margin-bottom: 30rpx;
}
.attachments-list {
display: flex;
flex-direction: column;
gap: 15rpx;
}
.attachment-item {
background-color: #fff;
border-radius: 16rpx;
padding: 25rpx 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
transition: all 0.3s;
&:active {
background-color: #f8f8f8;
transform: scale(0.98);
}
}
.file-info {
display: flex;
align-items: center;
gap: 20rpx;
flex: 1;
min-width: 0;
}
.file-icon {
font-size: 48rpx;
flex-shrink: 0;
}
.file-details {
display: flex;
flex-direction: column;
gap: 8rpx;
flex: 1;
min-width: 0;
}
.file-name {
font-size: 28rpx;
color: #333333;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.file-size {
font-size: 24rpx;
color: #999999;
}
.download-btn {
width: 60rpx;
height: 60rpx;
background-color: #C93639;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.download-icon {
font-size: 32rpx;
color: #fff;
}
// 规程内容区
.content-section {
margin-bottom: 30rpx;
}
.rules-list {
display: flex;
flex-direction: column;
@@ -91,6 +390,7 @@ export default {
background-color: #fff;
border-radius: 16rpx;
overflow: hidden;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
}
.rules-header {
@@ -98,6 +398,11 @@ export default {
align-items: center;
padding: 30rpx;
gap: 15rpx;
transition: background-color 0.3s;
&:active {
background-color: #f8f8f8;
}
}
.chapter-number {
@@ -127,6 +432,18 @@ export default {
.rules-content {
padding: 0 30rpx 30rpx;
border-top: 1rpx solid #f5f5f5;
animation: slideDown 0.3s ease;
}
@keyframes slideDown {
from {
opacity: 0;
transform: translateY(-10rpx);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.content-item {
@@ -151,4 +468,24 @@ export default {
color: #666666;
line-height: 1.8;
}
// 空状态
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120rpx 0;
gap: 20rpx;
}
.empty-icon {
font-size: 120rpx;
opacity: 0.3;
}
.empty-text {
font-size: 28rpx;
color: #999999;
}
</style>

View File

@@ -33,42 +33,461 @@
</template>
<script>
import infoAPI from '@/api/info.js'
export default {
data() {
return {
eventId: '',
currentDate: 0,
dates: [
{ day: '2月1日', text: '周六' },
{ day: '2月2日', text: '周日' },
{ day: '2月3日', text: '周一' }
],
schedules: {
0: [
{ time: '08:00', title: '签到开始', location: '主会场大厅' },
{ time: '09:00', title: '开幕式', location: '主赛场' },
{ time: '10:00', title: '预赛第一轮', location: 'A赛场' },
{ time: '14:00', title: '预赛第二轮', location: 'A赛场' },
{ time: '18:00', title: '当日比赛结束', location: '' }
],
1: [
{ time: '08:30', title: '选手签到', location: '主会场大厅' },
{ time: '09:30', title: '半决赛', location: 'A赛场' },
{ time: '14:00', title: '表演赛', location: 'B赛场' },
{ time: '16:00', title: '决赛', location: '主赛场' },
{ time: '18:30', title: '当日比赛结束', location: '' }
],
2: [
{ time: '09:00', title: '颁奖典礼', location: '主赛场' },
{ time: '11:00', title: '闭幕式', location: '主赛场' },
{ time: '12:00', title: '赛事圆满结束', location: '' }
]
}
dates: [],
schedules: {}
};
},
computed: {
currentSchedule() {
return this.schedules[this.currentDate] || [];
}
},
onLoad(options) {
if (options.eventId) {
this.eventId = options.eventId
this.loadScheduleDates(options.eventId)
}
},
watch: {
currentDate(newVal) {
if (this.dates[newVal] && this.dates[newVal].date) {
this.loadScheduleByDate(this.eventId, this.dates[newVal].date)
}
}
},
methods: {
/**
* 加载日程日期列表
*/
async loadScheduleDates(eventId) {
try {
const res = await infoAPI.getActivityScheduleList({ competitionId: eventId })
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
// 如果后端没有数据,使用模拟数据
if (list.length === 0) {
list = this.getMockScheduleData()
}
// 提取唯一日期
const dateSet = new Set()
list.forEach(item => {
const date = item.scheduleDate || item.schedule_date || item.date
if (date) {
dateSet.add(date)
}
})
// 格式化日期选项卡并排序
this.dates = Array.from(dateSet)
.sort((a, b) => new Date(a) - new Date(b)) // 按日期升序排序
.map(date => {
const d = new Date(date)
const month = d.getMonth() + 1
const day = d.getDate()
const weekDay = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][d.getDay()]
return {
date: date,
day: `${month}${day}`,
text: weekDay
}
})
// 按日期分组日程
list.forEach(item => {
const date = item.scheduleDate || item.schedule_date || item.date
const dateIndex = this.dates.findIndex(d => d.date === date)
if (dateIndex >= 0) {
if (!this.schedules[dateIndex]) {
this.schedules[dateIndex] = []
}
this.schedules[dateIndex].push({
time: this.formatTime(item.scheduleTime || item.schedule_time || item.time),
timeRaw: item.scheduleTime || item.schedule_time || item.time, // 保存原始时间用于排序
title: item.eventName || item.event_name || item.title || item.activityName || item.scheduleName,
location: item.venue || item.location || ''
})
}
})
// 对每个日期内的日程按时间排序
Object.keys(this.schedules).forEach(dateIndex => {
this.schedules[dateIndex].sort((a, b) => {
const timeA = a.timeRaw || a.time
const timeB = b.timeRaw || b.time
return timeA.localeCompare(timeB)
})
})
// 加载第一天的日程
if (this.dates.length > 0 && this.dates[0].date) {
this.loadScheduleByDate(eventId, this.dates[0].date)
}
} catch (err) {
console.error('加载日程日期失败:', err)
// 加载失败时使用模拟数据
const list = this.getMockScheduleData()
// 提取唯一日期
const dateSet = new Set()
list.forEach(item => {
if (item.scheduleDate) {
dateSet.add(item.scheduleDate)
}
})
// 格式化日期选项卡并排序
this.dates = Array.from(dateSet)
.sort((a, b) => new Date(a) - new Date(b)) // 按日期升序排序
.map(date => {
const d = new Date(date)
const month = d.getMonth() + 1
const day = d.getDate()
const weekDay = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][d.getDay()]
return {
date: date,
day: `${month}${day}`,
text: weekDay
}
})
// 按日期分组日程
list.forEach(item => {
const dateIndex = this.dates.findIndex(d => d.date === item.scheduleDate)
if (dateIndex >= 0) {
if (!this.schedules[dateIndex]) {
this.schedules[dateIndex] = []
}
this.schedules[dateIndex].push({
time: this.formatTime(item.scheduleTime),
timeRaw: item.scheduleTime, // 保存原始时间用于排序
title: item.eventName,
location: item.venue || ''
})
}
})
// 对每个日期内的日程按时间排序
Object.keys(this.schedules).forEach(dateIndex => {
this.schedules[dateIndex].sort((a, b) => {
const timeA = a.timeRaw || a.time
const timeB = b.timeRaw || b.time
return timeA.localeCompare(timeB)
})
})
}
},
/**
* 加载指定日期的日程
*/
async loadScheduleByDate(eventId, date) {
try {
const res = await infoAPI.getScheduleList({ competitionId: eventId, date: date })
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
const dateIndex = this.dates.findIndex(d => d.date === date)
if (dateIndex >= 0) {
this.schedules[dateIndex] = list
.map(item => ({
time: this.formatTime(item.scheduleTime || item.schedule_time || item.time),
timeRaw: item.scheduleTime || item.schedule_time || item.time,
title: item.eventName || item.event_name || item.title || item.activityName || item.scheduleName,
location: item.venue || item.location || ''
}))
.sort((a, b) => {
const timeA = a.timeRaw || a.time
const timeB = b.timeRaw || b.time
return timeA.localeCompare(timeB)
})
// 触发视图更新
this.$forceUpdate()
}
} catch (err) {
console.error('加载日程详情失败:', err)
}
},
/**
* 格式化时间(只取时分)
*/
formatTime(timeStr) {
if (!timeStr) return ''
// 如果已经是 HH:MM 格式
if (/^\d{2}:\d{2}$/.test(timeStr)) {
return timeStr
}
// 如果是 HH:MM:SS 格式直接截取前5位
if (/^\d{2}:\d{2}:\d{2}$/.test(timeStr)) {
return timeStr.substring(0, 5)
}
// 尝试解析完整的日期时间字符串
const date = new Date(timeStr)
if (!isNaN(date.getTime())) {
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
return `${hours}:${minutes}`
}
// 如果无法解析,返回原字符串
return timeStr
},
/**
* 获取模拟日程数据
*/
getMockScheduleData() {
return [
// 第一天2025-12-25 (报到日)
{
id: 2001,
competitionId: 200,
scheduleDate: '2025-12-25',
scheduleTime: '08:00',
eventName: '运动员报到',
venue: '赛事组委会接待处',
status: 1
},
{
id: 2002,
competitionId: 200,
scheduleDate: '2025-12-25',
scheduleTime: '09:00',
eventName: '领取参赛证件及装备',
venue: '赛事组委会接待处',
status: 1
},
{
id: 2003,
competitionId: 200,
scheduleDate: '2025-12-25',
scheduleTime: '10:00',
eventName: '赛前技术会议',
venue: '会议室A',
status: 1
},
{
id: 2004,
competitionId: 200,
scheduleDate: '2025-12-25',
scheduleTime: '14:00',
eventName: '场地开放训练',
venue: '主赛场',
status: 1
},
{
id: 2005,
competitionId: 200,
scheduleDate: '2025-12-25',
scheduleTime: '16:00',
eventName: '裁判员培训会',
venue: '会议室B',
status: 1
},
{
id: 2006,
competitionId: 200,
scheduleDate: '2025-12-25',
scheduleTime: '18:00',
eventName: '开幕式彩排',
venue: '主赛场',
status: 1
},
// 第二天2025-12-26 (正式比赛第一天)
{
id: 2007,
competitionId: 200,
scheduleDate: '2025-12-26',
scheduleTime: '07:30',
eventName: '运动员检录',
venue: '检录处',
status: 1
},
{
id: 2008,
competitionId: 200,
scheduleDate: '2025-12-26',
scheduleTime: '08:30',
eventName: '开幕式',
venue: '主赛场',
status: 1
},
{
id: 2009,
competitionId: 200,
scheduleDate: '2025-12-26',
scheduleTime: '09:00',
eventName: '男子长拳预赛',
venue: '主赛场',
status: 1
},
{
id: 2010,
competitionId: 200,
scheduleDate: '2025-12-26',
scheduleTime: '10:30',
eventName: '女子长拳预赛',
venue: '主赛场',
status: 1
},
{
id: 2011,
competitionId: 200,
scheduleDate: '2025-12-26',
scheduleTime: '12:00',
eventName: '午休',
venue: '',
status: 1
},
{
id: 2012,
competitionId: 200,
scheduleDate: '2025-12-26',
scheduleTime: '14:00',
eventName: '男子太极拳预赛',
venue: '主赛场',
status: 1
},
{
id: 2013,
competitionId: 200,
scheduleDate: '2025-12-26',
scheduleTime: '15:30',
eventName: '女子太极拳预赛',
venue: '主赛场',
status: 1
},
{
id: 2014,
competitionId: 200,
scheduleDate: '2025-12-26',
scheduleTime: '17:00',
eventName: '当日赛事总结会',
venue: '会议室A',
status: 1
},
// 第三天2025-12-27 (正式比赛第二天 - 决赛日)
{
id: 2015,
competitionId: 200,
scheduleDate: '2025-12-27',
scheduleTime: '07:30',
eventName: '运动员检录',
venue: '检录处',
status: 1
},
{
id: 2016,
competitionId: 200,
scheduleDate: '2025-12-27',
scheduleTime: '08:30',
eventName: '男子长拳半决赛',
venue: '主赛场',
status: 1
},
{
id: 2017,
competitionId: 200,
scheduleDate: '2025-12-27',
scheduleTime: '10:00',
eventName: '女子长拳半决赛',
venue: '主赛场',
status: 1
},
{
id: 2018,
competitionId: 200,
scheduleDate: '2025-12-27',
scheduleTime: '12:00',
eventName: '午休',
venue: '',
status: 1
},
{
id: 2019,
competitionId: 200,
scheduleDate: '2025-12-27',
scheduleTime: '14:00',
eventName: '男子长拳决赛',
venue: '主赛场',
status: 1
},
{
id: 2020,
competitionId: 200,
scheduleDate: '2025-12-27',
scheduleTime: '15:00',
eventName: '女子长拳决赛',
venue: '主赛场',
status: 1
},
{
id: 2021,
competitionId: 200,
scheduleDate: '2025-12-27',
scheduleTime: '16:00',
eventName: '男子太极拳决赛',
venue: '主赛场',
status: 1
},
{
id: 2022,
competitionId: 200,
scheduleDate: '2025-12-27',
scheduleTime: '17:00',
eventName: '女子太极拳决赛',
venue: '主赛场',
status: 1
},
{
id: 2023,
competitionId: 200,
scheduleDate: '2025-12-27',
scheduleTime: '18:00',
eventName: '颁奖典礼',
venue: '主赛场',
status: 1
},
{
id: 2024,
competitionId: 200,
scheduleDate: '2025-12-27',
scheduleTime: '19:00',
eventName: '闭幕式',
venue: '主赛场',
status: 1
}
]
}
}
};
</script>

View File

@@ -9,7 +9,7 @@
:class="{ active: currentCategory === index }"
@click="currentCategory = index"
>
{{ category }}
{{ category.name }}
</view>
</view>
@@ -38,33 +38,94 @@
</template>
<script>
import resultAPI from '@/api/result.js'
import competitionAPI from '@/api/competition.js'
export default {
data() {
return {
eventId: '',
currentCategory: 0,
categories: ['男子散打', '男子套路', '女子散打', '女子套路'],
scores: {
0: [
{ rank: 1, name: '张三', team: '北京队', score: '9.85' },
{ rank: 2, name: '李四', team: '上海队', score: '9.72' },
{ rank: 3, name: '王五', team: '广东队', score: '9.68' },
{ rank: 4, name: '赵六', team: '天津队', score: '9.55' },
{ rank: 5, name: '刘七', team: '江苏队', score: '9.48' }
],
1: [
{ rank: 1, name: '孙八', team: '浙江队', score: '9.90' },
{ rank: 2, name: '周九', team: '湖北队', score: '9.75' },
{ rank: 3, name: '吴十', team: '河北队', score: '9.60' }
],
2: [],
3: []
}
categories: [],
scores: {}
};
},
computed: {
currentScores() {
return this.scores[this.currentCategory] || [];
}
},
onLoad(options) {
if (options.eventId) {
this.eventId = options.eventId
this.loadCategories(options.eventId)
}
},
watch: {
currentCategory(newVal) {
if (this.categories[newVal] && this.categories[newVal].id) {
this.loadScoresByCategory(this.eventId, this.categories[newVal].id)
}
}
},
methods: {
/**
* 加载项目分类
*/
async loadCategories(eventId) {
try {
const res = await competitionAPI.getProjectList({ competitionId: eventId })
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
// 提取项目分类
this.categories = list.map(item => ({
id: item.id,
name: item.name || item.projectName
}))
// 加载第一个分类的成绩
if (this.categories.length > 0) {
this.loadScoresByCategory(eventId, this.categories[0].id)
}
} catch (err) {
console.error('加载项目分类失败:', err)
}
},
/**
* 加载指定分类的成绩
*/
async loadScoresByCategory(eventId, projectId) {
try {
const res = await resultAPI.getResultList(eventId, { projectId })
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
const categoryIndex = this.currentCategory
this.scores[categoryIndex] = list.map((item, index) => ({
rank: item.rank || item.ranking || (index + 1),
name: item.athleteName || item.name,
team: item.teamName || item.team,
score: item.score || item.finalScore || '0.00'
}))
// 触发视图更新
this.$forceUpdate()
} catch (err) {
console.error('加载成绩失败:', err)
}
}
}
};
</script>

View File

@@ -53,45 +53,136 @@
</template>
<script>
import competitionAPI from '@/api/competition.js'
export default {
data() {
return {
banners: [
'/static/images/bananer1.png',
'/static/images/bananer2.png'
],
eventList: [
{
id: 1,
title: '2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛',
location: '天津市-天津市体育中心',
registerTime: '2025.02.01-2025.02.10',
matchTime: '2025.02.01-2025.02.10',
registerCount: '25212',
status: 'open'
},
{
id: 2,
title: '2025年全国武术套路锦标赛',
location: '天津市-天津市体育中心',
registerTime: '2025.02.01-2025.02.10',
matchTime: '2025.02.01-2025.02.10',
registerCount: '25212',
status: 'finished'
},
{
id: 3,
title: '2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛',
location: '天津市-天津市体育中心',
registerTime: '2025.02.01-2025.02.10',
matchTime: '2025.02.01-2025.02.10',
registerCount: '25212',
status: 'open'
}
]
banners: [],
eventList: []
};
},
onLoad() {
this.loadBanners()
this.loadEvents()
},
methods: {
/**
* 加载轮播图
*/
async loadBanners() {
try {
const res = await competitionAPI.getBannerList({
current: 1,
size: 5
})
// 如果后端返回的是分页数据
if (res.records) {
this.banners = res.records.map(item => item.imageUrl || item.image || item.url)
} else if (Array.isArray(res)) {
this.banners = res.map(item => item.imageUrl || item.image || item.url)
}
// 如果没有数据,使用默认轮播图
if (this.banners.length === 0) {
this.banners = [
'/static/images/bananer1.png',
'/static/images/bananer2.png'
]
}
} catch (err) {
console.error('加载轮播图失败:', err)
// 使用默认轮播图
this.banners = [
'/static/images/bananer1.png',
'/static/images/bananer2.png'
]
}
},
/**
* 加载精品赛事
*/
async loadEvents() {
try {
const res = await competitionAPI.getCompetitionList({
current: 1,
size: 10
})
console.log('赛事列表API返回:', res)
// 如果后端返回的是分页数据
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
// 数据映射:将后端字段转换为前端需要的字段
this.eventList = list.map(item => {
// 尝试多个可能的时间字段
const regStartTime = item.registrationStartTime || item.registerStartTime || item.signUpStartTime
const regEndTime = item.registrationEndTime || item.registerEndTime || item.signUpEndTime
const startTime = item.startTime || item.competitionStartTime || item.beginTime
const endTime = item.endTime || item.competitionEndTime || item.finishTime
return {
id: item.id,
title: item.name || item.title || item.competitionName || '未命名赛事',
location: item.location || item.address || item.venue || '待定',
registerTime: this.formatTimeRange(regStartTime, regEndTime) ||
item.registerTime || item.registrationPeriod || '待定',
matchTime: this.formatTimeRange(startTime, endTime) ||
item.matchTime || item.competitionTime || '待定',
registerCount: item.registrationCount || item.registerCount || item.signUpCount || '0',
status: this.getStatus(item.status)
}
})
console.log('格式化后的赛事列表:', this.eventList)
} catch (err) {
console.error('加载赛事列表失败:', err)
}
},
/**
* 格式化时间范围
* @param {String} startTime 开始时间
* @param {String} endTime 结束时间
* @returns {String}
*/
formatTimeRange(startTime, endTime) {
if (!startTime || !endTime) return ''
const formatDate = (dateStr) => {
if (!dateStr) return ''
const date = new Date(dateStr)
const year = date.getFullYear()
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)}`
},
/**
* 获取赛事状态
* @param {Number|String} status 状态码
* @returns {String}
*/
getStatus(status) {
// 根据后端状态码映射为前端需要的状态
// 1: 报名中, 2: 进行中, 3: 已结束
if (status === 3 || status === '3' || status === 'finished') {
return 'finished'
}
return 'open'
},
goToEventList() {
uni.navigateTo({
url: '/pages/event-list/event-list'
@@ -227,9 +318,9 @@ export default {
.register-btn {
background-color: #C93639;
color: #fff;
padding: 16rpx 50rpx;
padding: 10rpx 30rpx;
border-radius: 50rpx;
font-size: 28rpx;
font-size: 24rpx;
border: none;
}

View File

@@ -63,6 +63,8 @@
<script>
import CustomTabs from '../../components/custom-tabs/custom-tabs.vue';
import registrationAPI from '@/api/registration.js'
import competitionAPI from '@/api/competition.js'
export default {
components: {
@@ -72,40 +74,30 @@ export default {
return {
tabs: ['全部', '待开始', '进行中', '已结束'],
currentTab: 0,
eventList: [
{
id: 1,
status: 'ongoing',
title: '2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛',
location: '天津市-天津市体育中心',
matchTime: '2025.02.01-2025.02.10',
projects: '男子组剑术、男子组太极拳',
contact: '18666666666',
participants: '张三、李四四、王二、张三、李四四、张三、李四四、王二、张三、李四四'
},
{
id: 2,
status: 'pending',
title: '2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛',
location: '天津市-天津市体育中心',
matchTime: '2025.02.01-2025.02.10',
projects: '男子组剑术、男子组太极拳',
contact: '18666666666',
participants: '张三、李四四、王二、张三、李四四、张三、李四四、王二、张三、李四四'
},
{
id: 3,
status: 'finished',
title: '2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛',
location: '天津市-天津市体育中心',
matchTime: '2025.02.01-2025.02.10',
projects: '男子组剑术、男子组太极拳',
contact: '18666666666',
participants: '张三、李四四、王二、张三、李四四、张三、李四四、王二、张三、李四四'
}
]
eventList: [],
// 分页参数
pageParams: {
current: 1,
size: 20
},
hasMore: true
};
},
onLoad() {
this.loadRegistrationList()
},
// 下拉刷新
onPullDownRefresh() {
this.pageParams.current = 1
this.loadRegistrationList(true)
},
// 上拉加载更多
onReachBottom() {
if (this.hasMore) {
this.pageParams.current++
this.loadRegistrationList(false, true)
}
},
computed: {
filteredList() {
if (this.currentTab === 0) {
@@ -120,8 +112,182 @@ export default {
}
},
methods: {
/**
* 加载我的报名列表
* @param {Boolean} refresh 是否刷新(重置列表)
* @param {Boolean} loadMore 是否加载更多(追加列表)
*/
async loadRegistrationList(refresh = false, loadMore = false) {
try {
const params = {
current: this.pageParams.current,
size: this.pageParams.size
}
// 添加状态筛选
if (this.currentTab > 0) {
params.status = this.currentTab
}
const res = await registrationAPI.getRegistrationList(params)
console.log('=== 我的报名列表 - 后端返回的原始数据 ===')
console.log('完整响应:', res)
let list = []
let total = 0
// 处理分页数据
if (res.records) {
list = res.records
total = res.total || 0
} else if (Array.isArray(res)) {
list = res
total = res.length
}
// 为每条报名记录获取详情(包含关联数据)
const detailPromises = list.map(item => this.getRegistrationDetailData(item))
const mappedList = await Promise.all(detailPromises)
// 过滤掉获取失败的记录
const validList = mappedList.filter(item => item !== null)
// 刷新或加载更多
if (refresh || !loadMore) {
this.eventList = validList
} else {
this.eventList = [...this.eventList, ...validList]
}
// 判断是否还有更多数据
this.hasMore = this.eventList.length < total
// 停止下拉刷新
if (refresh) {
uni.stopPullDownRefresh()
}
} catch (err) {
console.error('加载报名列表失败:', err)
uni.stopPullDownRefresh()
}
},
/**
* 获取单条报名记录的详细信息
* @param {Object} orderItem 订单基本信息
* @returns {Promise<Object>} 包含完整信息的记录
*/
async getRegistrationDetailData(orderItem) {
try {
console.log('=== 获取报名详情 ===', orderItem.id)
// 获取报名详情
const detail = await registrationAPI.getRegistrationDetail(orderItem.id)
console.log('报名详情:', detail)
// 获取赛事详情
let competitionInfo = null
if (orderItem.competitionId || detail.competitionId) {
const competitionId = orderItem.competitionId || detail.competitionId
competitionInfo = await competitionAPI.getCompetitionDetail(competitionId)
console.log('赛事详情:', competitionInfo)
}
// 构建映射数据
const mapped = {
id: orderItem.id,
status: this.getStatus(orderItem.status),
title: competitionInfo?.name || detail.competitionName || '未知赛事',
location: competitionInfo?.location || competitionInfo?.address || detail.location || '',
matchTime: this.formatTimeRange(
competitionInfo?.startTime || detail.startTime,
competitionInfo?.endTime || detail.endTime
) || '',
projects: detail.projectNames || this.formatProjects(detail.projects || detail.projectList) || '',
contact: orderItem.contactPhone || detail.contactPhone || '',
participants: detail.athleteNames || this.formatParticipants(detail.athletes || detail.athleteList) || ''
}
console.log('映射后的数据:', mapped)
return mapped
} catch (err) {
console.error('获取报名详情失败:', err, orderItem.id)
// 返回基本信息,避免整个记录丢失
return {
id: orderItem.id,
status: this.getStatus(orderItem.status),
title: '获取详情失败',
location: '',
matchTime: '',
projects: '',
contact: orderItem.contactPhone || '',
participants: `${orderItem.totalParticipants || 0}`
}
}
},
/**
* 格式化时间范围
*/
formatTimeRange(startTime, endTime) {
if (!startTime || !endTime) return ''
const formatDate = (dateStr) => {
if (!dateStr) return ''
const date = new Date(dateStr)
const year = date.getFullYear()
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)}`
},
/**
* 获取报名状态
*/
getStatus(status) {
// 1: 待开始, 2: 进行中, 3: 已结束
const statusMap = {
1: 'pending',
2: 'ongoing',
3: 'finished',
'pending': 'pending',
'ongoing': 'ongoing',
'finished': 'finished'
}
return statusMap[status] || 'pending'
},
/**
* 格式化报名项目
*/
formatProjects(projects) {
if (!projects) return ''
if (Array.isArray(projects)) {
return projects.map(p => p.name || p.projectName).join('、')
}
return projects
},
/**
* 格式化参赛选手
*/
formatParticipants(athletes) {
if (!athletes) return ''
if (Array.isArray(athletes)) {
return athletes.map(a => a.name || a.athleteName).join('、')
}
return athletes
},
handleTabChange(index) {
this.currentTab = index;
// 切换tab时重新加载
this.pageParams.current = 1
this.loadRegistrationList(true)
},
getStatusClass(status) {
return {

View File

@@ -7,8 +7,8 @@
<view class="avatar-circle"></view>
</view>
<view class="user-detail">
<view class="user-name">用户名字</view>
<view class="user-id">ID: 1234565</view>
<view class="user-name">{{ userInfo.name || '用户' }}</view>
<view class="user-id">ID: {{ userInfo.id }}</view>
</view>
</view>
</view>
@@ -48,16 +48,46 @@
</template>
<script>
import userAPI from '@/api/user.js'
export default {
data() {
return {
userInfo: {
name: '用户名字',
id: '1234565'
name: '',
id: '',
phone: '',
username: ''
}
};
},
onLoad() {
this.loadUserInfo()
},
onShow() {
// 每次显示时刷新用户信息
this.loadUserInfo()
},
methods: {
/**
* 加载用户信息
*/
async loadUserInfo() {
try {
const res = await userAPI.getUserInfo()
this.userInfo = {
name: res.name || res.username || res.realName || '用户',
id: res.id || res.userId || '',
phone: res.phone || res.mobile || '',
username: res.username || res.account || ''
}
} catch (err) {
console.error('加载用户信息失败:', err)
// 失败时不显示错误提示,使用默认值
}
},
goToMyRegistration() {
uni.navigateTo({
url: '/pages/my-registration/my-registration'
@@ -69,9 +99,8 @@ export default {
});
},
handleChangePassword() {
uni.showToast({
title: '修改密码功能',
icon: 'none'
uni.navigateTo({
url: '/pages/change-password/change-password'
});
},
handleContactUs() {
@@ -86,10 +115,21 @@ export default {
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
// 清除本地存储的token
uni.removeStorageSync('token')
uni.removeStorageSync('userInfo')
uni.showToast({
title: '退出成功',
icon: 'success'
});
})
// 延迟跳转到登录页
setTimeout(() => {
uni.reLaunch({
url: '/pages/login/login'
})
}, 1500)
}
}
});

View File

@@ -26,48 +26,56 @@
</template>
<script>
import competitionAPI from '@/api/competition.js'
export default {
data() {
return {
eventId: '',
type: '',
projectList: [
{
id: 1,
name: '男子组剑术',
price: 199,
selected: true
},
{
id: 2,
name: '女子组太极拳',
price: 99,
selected: false
},
{
id: 3,
name: '女子组单鞭',
price: 1299,
selected: false
},
{
id: 4,
name: '男子组太极拳',
price: 299,
selected: true
}
]
projectList: []
};
},
onLoad(options) {
if (options.eventId) {
this.eventId = options.eventId;
this.loadProjectList(options.eventId)
}
if (options.type) {
this.type = options.type;
}
},
methods: {
/**
* 加载报名项目列表
*/
async loadProjectList(eventId) {
try {
const res = await competitionAPI.getProjectList({ competitionId: eventId })
let list = []
if (res.records) {
list = res.records
} else if (Array.isArray(res)) {
list = res
}
// 数据映射
this.projectList = list.map(item => ({
id: item.id,
name: item.name || item.projectName,
price: item.price || item.registrationFee || 0,
selected: false
}))
} catch (err) {
console.error('加载项目列表失败:', err)
uni.showToast({
title: '加载失败',
icon: 'none'
})
}
},
toggleProject(item) {
item.selected = !item.selected;
this.$forceUpdate();
@@ -83,7 +91,7 @@ export default {
}
uni.navigateTo({
url: `/pages/event-register/event-register?eventId=${this.eventId}&projects=${JSON.stringify(selectedProjects)}`
url: `/pages/event-register/event-register?eventId=${this.eventId}&projects=${encodeURIComponent(JSON.stringify(selectedProjects))}`
});
}
}