Compare commits

...

19 Commits

Author SHA1 Message Date
DevOps
412069524e fix: 新增联系人后刷新列表
- 问题2: 在onShow生命周期中自动刷新联系人列表

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-01-08 16:08:39 +08:00
DevOps
53cc4600a8 重构项4: 小程序出场顺序页面改用真实数据
- 修改api/schedule.js添加getScheduleStatus和getLineup方法
- 重写event-lineup.vue,从硬编码mock数据改为调用后端API
- 添加编排未完成状态的友好提示

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-01-08 15:42:55 +08:00
DevOps
3b05e7fc28 fix: 新增选手时传递createUser字段
- 在add-player页面提交选手时添加createUser字段
- 确保选手记录能正确关联到当前登录用户
- 解决新增选手后无法在列表中显示的问题

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-01-06 17:58:38 +08:00
DevOps
0ab8312bbb fix: 比赛结束后不允许报名
- 修改getStatus方法,增加比赛结束时间检查
- 如果比赛已结束,即使报名时间还在有效期内,也显示报名已结束

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-01-05 17:49:28 +08:00
DevOps
13eb311575 feat: add contact management and various bug fixes
- Add contact API methods in athlete.js
- Add contact list display in common-info.vue
- Update add-contact.vue for contact creation
- Create edit-contact page for contact editing
- Fix event-register.vue with contact picker modal
- Fix home.vue registration status display
- Fix my-registration.vue cert modal display

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-01-05 15:12:04 +08:00
DevOps
4eddc5a194 fix(event-players): 修复选手列表API响应处理 2025-12-31 15:20:59 +08:00
DevOps
c249c9e213 fix(my-registration): 修复信息展示不全问题
- 地址过长时显示省略号
- 空字段显示"暂无"
2025-12-31 14:38:06 +08:00
DevOps
5911a55432 fix(registration): API层添加teamIds字段支持集体报名 2025-12-31 13:48:26 +08:00
DevOps
adbafedb5b fix(register): 确保集体项目报名时传递type字段
- 在项目列表中保存type字段
- 跳转报名页面时传递完整的项目信息(包含type)
- 确保集体项目报名时显示集体选择而非选手选择
2025-12-31 13:30:39 +08:00
DevOps
a56ca34cc3 fix(team): 修复编辑集体时id字段丢失的问题
- 将id字段改为teamId,与后端DTO保持一致
- 使用String类型传递teamId和memberIds,避免精度丢失
2025-12-31 13:10:17 +08:00
DevOps
1e053f62c0 feat(team): 添加集体编辑页面 2025-12-31 11:51:39 +08:00
DevOps
bb0f620d12 fix(team): 修复删除集体时参数传递问题 2025-12-31 11:40:51 +08:00
DevOps
ecb9fcba6b fix(registration): 修复我的报名跳转赛事详情时传递错误ID的问题 2025-12-31 10:56:26 +08:00
DevOps
3baa14a6b6 feat(registration): 支持集体项目报名
- 修改event-register页面支持集体项目
- 根据项目类型(个人/集体)显示不同选择界面
- 添加集体API到athlete.js
- 集体项目报名时选择集体而非选手
2025-12-30 18:02:19 +08:00
DevOps
b5a8c811aa fix(add-player): 修复新增选手页面问题
- 移除一直显示的悬浮提示弹窗 (Issue #8)
- 添加登录状态检查
- 优化表单验证逻辑
- 改进错误提示显示方式
2025-12-30 17:26:46 +08:00
DevOps
c6c9f9a5d1 feat(common-info): 添加集体标签页
- 在常用信息页面添加集体Tab
- 创建新增集体页面(add-team)
- 支持集体成员管理
- 修复Issue #6: 常用信息标签页里没有集体
2025-12-30 17:20:29 +08:00
DevOps
d22944e575 fix(select-event): 根据参赛类型过滤项目列表
- 单人赛只显示type=1的项目
- 集体赛只显示type=2的项目
- 修复Issue #5: 单人/集体比赛区分问题
2025-12-30 17:16:44 +08:00
DevOps
5a09cceab0 docs: 更新README,简化内容并更新域名 2025-12-29 14:21:52 +08:00
DevOps
541c770f27 fix: 修复赛事规程下载文件无后缀问题
- event-rules页面H5环境使用a标签download属性指定文件名
- 修复api.config.js生产环境API地址配置
- 优化多个页面的附件展示

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 15:45:30 +08:00
21 changed files with 2819 additions and 1741 deletions

290
README.md
View File

@@ -1,251 +1,71 @@
# 武术赛事报名系统 # 武术赛事管理系统 - 用户端
基于uniapp框架开发的武术赛事报名系统支持H5和微信小程序。 基于 UniApp 开发的武术赛事报名小程序,支持 H5 和微信小程序。
## 项目概述 ## 在线访问
本项目是一个完整的武术赛事报名管理系统,实现了从赛事浏览、报名到信息管理的完整流程。 | 服务 | 地址 |
|------|------|
| 用户端 H5 | https://martial.aitisai.com |
| 后端 API | https://martial-api.aitisai.com |
### 技术栈 ## 功能特点
- **框架**: uniapp - 赛事浏览与搜索
- 在线报名与支付
- 选手信息管理
- 报名记录查询
- 赛事详情查看
## 技术栈
- **框架**: UniApp
- **平台**: H5、微信小程序 - **平台**: H5、微信小程序
- **样式**: SCSS、rpx响应式单位 - **样式**: SCSS
- **版本**: 2.0
## 快速开始
```bash
# 安装依赖
npm install
# H5 开发
npm run dev:h5
# 微信小程序开发
npm run dev:mp-weixin
# 构建 H5
npm run build:h5
```
## 项目结构 ## 项目结构
``` ```
martial-mini/ martial-mini/
├── pages/ # 页面目录 ├── pages/
│ ├── home/ # 首页(武术赛事通) │ ├── home/ # 首页
│ ├── profile/ # 个人中心 │ ├── profile/ # 个人中心
│ ├── common-info/ # 常用信息 │ ├── event-list/ # 赛事列表
│ ├── add-player/ # 新增选手 │ ├── event-detail/ # 赛事详情
│ ├── edit-player/ # 编辑选手 │ ├── event-register/ # 赛事报名
│ ├── add-contact/ # 新增联系人 │ ├── my-registration/ # 我的报名
│ ├── my-registration/ # 我的报名 │ ├── add-player/ # 新增选手
── event-list/ # 全部赛事列表 ── common-info/ # 常用信息
│ ├── event-detail/ # 赛事详情 ├── components/ # 公共组件
│ ├── register-type/ # 选择报名类型 ├── static/ # 静态资源
│ ├── select-event/ # 选择报名项目 ├── pages.json # 页面配置
│ └── event-register/ # 赛事报名流程 └── manifest.json # 应用配置
├── components/ # 公共组件目录
│ ├── custom-navbar/ # 自定义导航栏
│ ├── custom-tabs/ # Tab切换组件
│ └── confirm-modal/ # 确认弹窗组件
├── static/ # 静态资源目录
│ └── images/ # 图片资源
├── image/ # 设计稿图片
├── App.vue # 应用主组件
├── main.js # 应用入口文件
├── pages.json # 页面配置
├── manifest.json # 应用配置
├── uni.scss # 全局样式变量
├── index.html # H5入口页面
├── package.json # 项目依赖配置
├── check-pages.js # 页面完成度检查工具
└── README.md # 项目说明文档
``` ```
## 功能模块 ## 相关仓库
### 1. 首页(武术赛事通) | 仓库 | 说明 |
- 轮播图展示 |------|------|
- 精品赛事列表 | [martial-master](https://git.waypeak.work/martial/martial-master) | 后端 API |
- 赛事状态显示(报名中/已结束) | [martial-web](https://git.waypeak.work/martial/martial-web) | 管理后台 |
- 快速报名入口 | [martial-admin-mini](https://git.waypeak.work/martial/martial-admin-mini) | 裁判端小程序 |
### 2. 个人中心 ---
- 用户信息展示
- 我的报名入口
- 常用信息管理
- 修改密码
- 联系我们
- 退出登录
### 3. 常用信息管理 **最后更新**: 2024-12-29
- 选手信息管理(新增/编辑/删除)
- 集体信息管理
- 联系人信息管理
- Tab切换界面
### 4. 选手管理
- 证件类型选择(身份证)
- 姓名输入
- 证件号码输入18位身份证号验证
- 队伍名称输入
- 表单验证提示
### 5. 联系人管理
- 证件信息
- 手机号码(格式验证)
- 邮箱地址
- 联系地址
- 设置默认联系人开关
### 6. 我的报名
- 全部/待开始/进行中/已结束 Tab切换
- 赛事状态标签
- 赛事详细信息展示
- 参赛选手列表
- 查看证件功能
### 7. 赛事列表
- 搜索功能
- 日期筛选
- 地区筛选
- 赛事卡片展示
- 报名状态显示
### 8. 赛事详情
- 赛事基本信息
- 功能网格入口:
- 信息发布
- 赛事规程
- 活动日程
- 参赛选手
- 比赛实况
- 出场顺序
- 成绩
- 奖牌榜
- 图片直播
- 报名按钮
### 9. 报名流程
- **选择报名类型**:单人赛/集体赛
- **选择报名项目**:多选项目,显示价格
- **报名三步骤**
1. 选择选手信息(可新增/编辑/删除选手)
2. 订单支付(显示赛事信息、联系人、参赛选手、总价)
3. 报名成功(显示选手编号信息)
## 设计特点
### 配色方案
- 主题色:#C93639(中国红)
- 文字色:#333333(深灰)、#666666(中灰)、#999999(浅灰)
- 背景色:#f5f5f5(浅灰背景)、#ffffff(白色)
### 样式规范
- 使用rpx响应式单位自适应不同屏幕
- 圆角统一16rpx常规、24rpx大圆角
- 间距统一30rpx页面内边距
- 字体大小:
- 标题36-38rpx
- 正文28-32rpx
- 辅助文字24-26rpx
### UI组件
- 自定义导航栏(支持返回按钮、标题、右侧操作区)
- Tab切换组件带下划线指示器
- 确认弹窗组件(取消/确定)
- 表单输入组件
- 按钮组件(主按钮/禁用按钮)
## 开发说明
### 环境要求
- Node.js 12+
- HBuilderX推荐或 VSCode + uni-app插件
### 安装依赖
```bash
npm install
```
### 运行项目
#### H5开发
```bash
npm run dev:h5
```
#### 微信小程序开发
```bash
npm run dev:mp-weixin
```
### 构建项目
#### 构建H5
```bash
npm run build:h5
```
#### 构建微信小程序
```bash
npm run build:mp-weixin
```
### 检查页面完成度
```bash
node check-pages.js
```
## 页面列表
1. **首页** - `/pages/home/home`
2. **个人中心** - `/pages/profile/profile`
3. **常用信息** - `/pages/common-info/common-info`
4. **新增选手** - `/pages/add-player/add-player`
5. **编辑选手** - `/pages/edit-player/edit-player`
6. **新增联系人** - `/pages/add-contact/add-contact`
7. **我的报名** - `/pages/my-registration/my-registration`
8. **全部赛事列表** - `/pages/event-list/event-list`
9. **赛事详情** - `/pages/event-detail/event-detail`
10. **选择报名类型** - `/pages/register-type/register-type`
11. **选择报名项目** - `/pages/select-event/select-event`
12. **赛事报名流程** - `/pages/event-register/event-register`
## 注意事项
1. 所有静态页面已完成,数据为模拟数据
2. 实际开发时需要对接后端API接口
3. 图片资源需要替换为实际的设计图
4. 部分功能如支付需要集成第三方SDK
5. 微信小程序需要配置appid和相关权限
## 后续开发建议
1. **接口对接**
- 用户登录/注册
- 赛事列表获取
- 报名信息提交
- 支付接口对接
2. **功能完善**
- 图片上传功能
- 消息通知
- 数据缓存优化
- 错误处理机制
3. **性能优化**
- 图片懒加载
- 列表虚拟滚动
- 页面预加载
4. **用户体验**
- 加载动画
- 骨架屏
- 下拉刷新
- 上拉加载更多
## 检查报告
运行 `node check-pages.js` 可查看详细的页面完成度报告。
当前完成度:**100%** ✓
- 配置文件7/7 完成
- 公共组件3/3 完成
- 页面文件12/12 完成
## 版本信息
- 版本号V 2.0
- 开发时间2025年1月
## 许可证
MIT License

11
package-lock.json generated
View File

@@ -77,7 +77,6 @@
"version": "7.28.5", "version": "7.28.5",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.5.tgz", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.5.tgz",
"integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==",
"peer": true,
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.27.1", "@babel/code-frame": "^7.27.1",
"@babel/generator": "^7.28.5", "@babel/generator": "^7.28.5",
@@ -2856,7 +2855,6 @@
"resolved": "https://registry.npmjs.org/@vue/cli-service/-/cli-service-4.5.19.tgz", "resolved": "https://registry.npmjs.org/@vue/cli-service/-/cli-service-4.5.19.tgz",
"integrity": "sha512-+Wpvj8fMTCt9ZPOLu5YaLkFCQmB4MrZ26aRmhhKiCQ/4PMoL6mLezfqdt6c+m2htM+1WV5RunRo+0WHl2DfwZA==", "integrity": "sha512-+Wpvj8fMTCt9ZPOLu5YaLkFCQmB4MrZ26aRmhhKiCQ/4PMoL6mLezfqdt6c+m2htM+1WV5RunRo+0WHl2DfwZA==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"@intervolga/optimize-cssnano-plugin": "^1.0.5", "@intervolga/optimize-cssnano-plugin": "^1.0.5",
"@soda/friendly-errors-webpack-plugin": "^1.7.1", "@soda/friendly-errors-webpack-plugin": "^1.7.1",
@@ -3517,7 +3515,6 @@
"version": "6.12.6", "version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"peer": true,
"dependencies": { "dependencies": {
"fast-deep-equal": "^3.1.1", "fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0", "fast-json-stable-stringify": "^2.0.0",
@@ -4414,7 +4411,6 @@
"url": "https://github.com/sponsors/ai" "url": "https://github.com/sponsors/ai"
} }
], ],
"peer": true,
"dependencies": { "dependencies": {
"baseline-browser-mapping": "^2.9.0", "baseline-browser-mapping": "^2.9.0",
"caniuse-lite": "^1.0.30001759", "caniuse-lite": "^1.0.30001759",
@@ -5334,7 +5330,6 @@
"resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-5.1.2.tgz", "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-5.1.2.tgz",
"integrity": "sha512-Uh7crJAco3AjBvgAy9Z75CjK8IG+gxaErro71THQ+vv/bl4HaQcpkexAY8KVW/T6D2W2IRr+couF/knIRkZMIQ==", "integrity": "sha512-Uh7crJAco3AjBvgAy9Z75CjK8IG+gxaErro71THQ+vv/bl4HaQcpkexAY8KVW/T6D2W2IRr+couF/knIRkZMIQ==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"cacache": "^12.0.3", "cacache": "^12.0.3",
"find-cache-dir": "^2.1.0", "find-cache-dir": "^2.1.0",
@@ -7382,7 +7377,6 @@
"resolved": "https://registry.npmjs.org/file-loader/-/file-loader-4.3.0.tgz", "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-4.3.0.tgz",
"integrity": "sha512-aKrYPYjF1yG3oX0kWRrqrSMfgftm7oJW5M+m4owoldH5C51C0RkIwB++JbRvEW3IU6/ZG5n8UvEcdgwOt2UOWA==", "integrity": "sha512-aKrYPYjF1yG3oX0kWRrqrSMfgftm7oJW5M+m4owoldH5C51C0RkIwB++JbRvEW3IU6/ZG5n8UvEcdgwOt2UOWA==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"loader-utils": "^1.2.3", "loader-utils": "^1.2.3",
"schema-utils": "^2.5.0" "schema-utils": "^2.5.0"
@@ -8454,7 +8448,6 @@
"version": "4.5.2", "version": "4.5.2",
"resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-4.5.2.tgz", "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-4.5.2.tgz",
"integrity": "sha512-q5oYdzjKUIPQVjOosjgvCHQOv9Ett9CYYHlgvJeXG0qQvdSojnBq4vAdQBwn1+yGveAwHCoe/rMR86ozX3+c2A==", "integrity": "sha512-q5oYdzjKUIPQVjOosjgvCHQOv9Ett9CYYHlgvJeXG0qQvdSojnBq4vAdQBwn1+yGveAwHCoe/rMR86ozX3+c2A==",
"peer": true,
"dependencies": { "dependencies": {
"@types/html-minifier-terser": "^5.0.0", "@types/html-minifier-terser": "^5.0.0",
"@types/tapable": "^1.0.5", "@types/tapable": "^1.0.5",
@@ -11314,7 +11307,6 @@
"version": "2.16.105", "version": "2.16.105",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.16.105.tgz", "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.16.105.tgz",
"integrity": "sha512-J4dn41spsAwUxCpEoVf6GVoz908IAA3mYiLmNxg8J9kfRXc2jxpbUepcP0ocp0alVNLFthTAM8DZ1RaHh8sU0A==", "integrity": "sha512-J4dn41spsAwUxCpEoVf6GVoz908IAA3mYiLmNxg8J9kfRXc2jxpbUepcP0ocp0alVNLFthTAM8DZ1RaHh8sU0A==",
"license": "Apache-2.0",
"dependencies": { "dependencies": {
"dommatrix": "^1.0.3", "dommatrix": "^1.0.3",
"web-streams-polyfill": "^3.2.1" "web-streams-polyfill": "^3.2.1"
@@ -11436,7 +11428,6 @@
"resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.39.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.39.tgz",
"integrity": "sha512-yioayjNbHn6z1/Bywyb2Y4s3yvDAeXGOyxqD+LnVOinq6Mdmd++SW2wUNVzavyyHxd6+DxzWGIuosg6P1Rj8uA==", "integrity": "sha512-yioayjNbHn6z1/Bywyb2Y4s3yvDAeXGOyxqD+LnVOinq6Mdmd++SW2wUNVzavyyHxd6+DxzWGIuosg6P1Rj8uA==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"picocolors": "^0.2.1", "picocolors": "^0.2.1",
"source-map": "^0.6.1" "source-map": "^0.6.1"
@@ -13063,7 +13054,6 @@
"resolved": "https://registry.npmjs.org/sass/-/sass-1.96.0.tgz", "resolved": "https://registry.npmjs.org/sass/-/sass-1.96.0.tgz",
"integrity": "sha512-8u4xqqUeugGNCYwr9ARNtQKTOj4KmYiJAVKXf2CTIivTCR51j96htbMKWDru8H5SaQWpyVgTfOF8Ylyf5pun1Q==", "integrity": "sha512-8u4xqqUeugGNCYwr9ARNtQKTOj4KmYiJAVKXf2CTIivTCR51j96htbMKWDru8H5SaQWpyVgTfOF8Ylyf5pun1Q==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"chokidar": "^4.0.0", "chokidar": "^4.0.0",
"immutable": "^5.0.2", "immutable": "^5.0.2",
@@ -16080,7 +16070,6 @@
"version": "4.47.0", "version": "4.47.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.47.0.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.47.0.tgz",
"integrity": "sha512-td7fYwgLSrky3fI1EuU5cneU4+pbH6GgOfuKNS1tNPcfdGinGELAqsb/BP4nnvZyKSG2i/xFGU7+n2PvZA8HJQ==", "integrity": "sha512-td7fYwgLSrky3fI1EuU5cneU4+pbH6GgOfuKNS1tNPcfdGinGELAqsb/BP4nnvZyKSG2i/xFGU7+n2PvZA8HJQ==",
"peer": true,
"dependencies": { "dependencies": {
"@webassemblyjs/ast": "1.9.0", "@webassemblyjs/ast": "1.9.0",
"@webassemblyjs/helper-module-context": "1.9.0", "@webassemblyjs/helper-module-context": "1.9.0",

View File

@@ -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,54 @@ 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?id=' + id, {})
},
// ========== 联系人相关 API ==========
getContactList(params = {}) {
return request.get('/martial/contact/list', {
current: params.current || 1,
size: params.size || 100,
...params
})
},
getContactDetail(id) {
return request.get('/martial/contact/detail', { id })
},
saveContact(data) {
return request.post('/martial/contact/submit', data)
},
removeContact(id) {
return request.post('/martial/contact/remove?ids=' + id, {})
} }
} }

View File

@@ -7,26 +7,23 @@ import request from '@/utils/request.js'
export default { export default {
/** /**
* 提交报名订单 * 提交报名订单
* @param {Object} data 报名数据 { competitionId, projectIds, athleteIds, contactPhone, totalAmount }
* @returns {Promise}
*/ */
submitRegistration(data) { submitRegistration(data) {
// 处理数组参数:将数组转换为逗号分隔的字符串
const formattedData = { const formattedData = {
orderNo: data.orderNo, orderNo: data.orderNo,
competitionId: data.competitionId, competitionId: data.competitionId,
projectIds: Array.isArray(data.projectIds) ? data.projectIds.join(',') : data.projectIds, projectIds: Array.isArray(data.projectIds) ? data.projectIds.join(',') : data.projectIds,
athleteIds: Array.isArray(data.athleteIds) ? data.athleteIds.join(',') : data.athleteIds, athleteIds: Array.isArray(data.athleteIds) ? data.athleteIds.join(',') : (data.athleteIds || ''),
teamIds: Array.isArray(data.teamIds) ? data.teamIds.join(',') : (data.teamIds || ''),
contactPhone: data.contactPhone, contactPhone: data.contactPhone,
totalAmount: data.totalAmount totalAmount: data.totalAmount
} }
console.log('=== API层转换后的数据 ===') console.log('=== API层转换后的数据 ===')
console.log('订单号:', formattedData.orderNo) console.log('订单号:', formattedData.orderNo)
console.log('转换前 projectIds:', data.projectIds) console.log('projectIds:', formattedData.projectIds)
console.log('转换后 projectIds:', formattedData.projectIds) console.log('athleteIds:', formattedData.athleteIds)
console.log('转换前 athleteIds:', data.athleteIds) console.log('teamIds:', formattedData.teamIds)
console.log('转换后 athleteIds:', formattedData.athleteIds)
console.log('最终发送到后端的完整数据:', formattedData) console.log('最终发送到后端的完整数据:', formattedData)
return request.post('/martial/registrationOrder/submit', formattedData) return request.post('/martial/registrationOrder/submit', formattedData)
@@ -34,8 +31,6 @@ export default {
/** /**
* 获取报名订单列表 * 获取报名订单列表
* @param {Object} params 查询参数 { current, size, status }
* @returns {Promise}
*/ */
getRegistrationList(params = {}) { getRegistrationList(params = {}) {
return request.get('/martial/registrationOrder/list', { return request.get('/martial/registrationOrder/list', {
@@ -47,8 +42,6 @@ export default {
/** /**
* 获取报名订单详情 * 获取报名订单详情
* @param {String|Number} id 订单ID
* @returns {Promise}
*/ */
getRegistrationDetail(id) { getRegistrationDetail(id) {
return request.get('/martial/registrationOrder/detail', { id }) return request.get('/martial/registrationOrder/detail', { id })
@@ -56,8 +49,6 @@ export default {
/** /**
* 取消报名 * 取消报名
* @param {String|Array} ids 订单ID或ID数组
* @returns {Promise}
*/ */
cancelRegistration(ids) { cancelRegistration(ids) {
return request.post('/martial/registrationOrder/remove', { return request.post('/martial/registrationOrder/remove', {

View File

@@ -91,6 +91,27 @@ export function saveDispatch(data) {
return request.post('/martial/schedule/save-dispatch', data) return request.post('/martial/schedule/save-dispatch', data)
} }
/**
* 获取编排状态(小程序用)
* @param {Number} competitionId - 赛事ID
*/
export function getScheduleStatus(competitionId) {
return request.get('/mini/schedule/status', {
params: { competitionId }
})
}
/**
* 获取出场顺序(小程序用)
* @param {Number} competitionId - 赛事ID
* @param {Number} projectId - 项目ID (可选)
*/
export function getLineup(competitionId, projectId) {
return request.get('/mini/schedule/lineup', {
params: { competitionId, projectId }
})
}
export default { export default {
getScheduleResult, getScheduleResult,
triggerAutoArrange, triggerAutoArrange,
@@ -99,5 +120,7 @@ export default {
moveScheduleGroup, moveScheduleGroup,
getDispatchData, getDispatchData,
adjustOrder, adjustOrder,
saveDispatch saveDispatch,
getScheduleStatus,
getLineup
} }

View File

@@ -1,236 +1,35 @@
{ {
"pages": [ "pages": [
{ {"path": "pages/login/login", "style": {"navigationBarTitleText": "登录", "navigationStyle": "custom"}},
"path": "pages/login/login", {"path": "pages/register/register", "style": {"navigationBarTitleText": "注册", "navigationStyle": "custom"}},
"style": { {"path": "pages/home/home", "style": {"navigationBarTitleText": "武术赛事通", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"navigationBarTitleText": "登录", {"path": "pages/profile/profile", "style": {"navigationBarTitleText": "个人中心", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"navigationStyle": "custom" {"path": "pages/change-password/change-password", "style": {"navigationBarTitleText": "修改密码", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
} {"path": "pages/common-info/common-info", "style": {"navigationBarTitleText": "常用信息", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
}, {"path": "pages/add-player/add-player", "style": {"navigationBarTitleText": "新增选手", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
{ {"path": "pages/add-team/add-team", "style": {"navigationBarTitleText": "新增集体", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"path": "pages/register/register", {"path": "pages/edit-team/edit-team", "style": {"navigationBarTitleText": "编辑集体", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"style": { {"path": "pages/edit-player/edit-player", "style": {"navigationBarTitleText": "编辑选手", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"navigationBarTitleText": "注册", {"path": "pages/add-contact/add-contact", "style": {"navigationBarTitleText": "新增联系人", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"navigationStyle": "custom" {"path": "pages/edit-contact/edit-contact", "style": {"navigationBarTitleText": "编辑联系人", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
} {"path": "pages/my-registration/my-registration", "style": {"navigationBarTitleText": "我的报名", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
}, {"path": "pages/event-list/event-list", "style": {"navigationBarTitleText": "全部赛事列表", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
{ {"path": "pages/event-detail/event-detail", "style": {"navigationBarTitleText": "赛事详情", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"path": "pages/home/home", {"path": "pages/select-event/select-event", "style": {"navigationBarTitleText": "选择报名项目", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"style": { {"path": "pages/event-register/event-register", "style": {"navigationBarTitleText": "赛事报名", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"navigationBarTitleText": "武术赛事通", {"path": "pages/register-type/register-type", "style": {"navigationBarTitleText": "选择报名", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"navigationBarBackgroundColor": "#C93639", {"path": "pages/event-info/event-info", "style": {"navigationBarTitleText": "信息发布", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"navigationBarTextStyle": "white" {"path": "pages/event-info-detail/event-info-detail", "style": {"navigationBarTitleText": "信息详情", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
} {"path": "pages/event-rules/event-rules", "style": {"navigationBarTitleText": "赛事规程", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
}, {"path": "pages/event-schedule/event-schedule", "style": {"navigationBarTitleText": "活动日程", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
{ {"path": "pages/event-players/event-players", "style": {"navigationBarTitleText": "参赛选手", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"path": "pages/profile/profile", {"path": "pages/event-live/event-live", "style": {"navigationBarTitleText": "比赛实况", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"style": { {"path": "pages/event-lineup/event-lineup", "style": {"navigationBarTitleText": "出场顺序", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"navigationBarTitleText": "个人中心", {"path": "pages/event-score/event-score", "style": {"navigationBarTitleText": "成绩", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"navigationBarBackgroundColor": "#C93639", {"path": "pages/event-medals/event-medals", "style": {"navigationBarTitleText": "奖牌榜", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
"navigationBarTextStyle": "white" {"path": "pages/attachment-view/attachment-view", "style": {"navigationBarTitleText": "附件查看", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}},
} {"path": "pages/event-photos/event-photos", "style": {"navigationBarTitleText": "图片直播", "navigationBarBackgroundColor": "#C93639", "navigationBarTextStyle": "white"}}
},
{
"path": "pages/change-password/change-password",
"style": {
"navigationBarTitleText": "修改密码",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/common-info/common-info",
"style": {
"navigationBarTitleText": "常用信息",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/add-player/add-player",
"style": {
"navigationBarTitleText": "新增选手",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/edit-player/edit-player",
"style": {
"navigationBarTitleText": "编辑选手",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/add-contact/add-contact",
"style": {
"navigationBarTitleText": "新增联系人",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/my-registration/my-registration",
"style": {
"navigationBarTitleText": "我的报名",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-list/event-list",
"style": {
"navigationBarTitleText": "全部赛事列表",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-detail/event-detail",
"style": {
"navigationBarTitleText": "赛事详情",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/select-event/select-event",
"style": {
"navigationBarTitleText": "选择报名项目",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-register/event-register",
"style": {
"navigationBarTitleText": "赛事报名",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/register-type/register-type",
"style": {
"navigationBarTitleText": "选择报名",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-info/event-info",
"style": {
"navigationBarTitleText": "信息发布",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-info-detail/event-info-detail",
"style": {
"navigationBarTitleText": "信息详情",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-rules/event-rules",
"style": {
"navigationBarTitleText": "赛事规程",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-schedule/event-schedule",
"style": {
"navigationBarTitleText": "活动日程",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-players/event-players",
"style": {
"navigationBarTitleText": "参赛选手",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-live/event-live",
"style": {
"navigationBarTitleText": "比赛实况",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-lineup/event-lineup",
"style": {
"navigationBarTitleText": "出场顺序",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-score/event-score",
"style": {
"navigationBarTitleText": "成绩",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-medals/event-medals",
"style": {
"navigationBarTitleText": "奖牌榜",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/attachment-view/attachment-view",
"style": {
"navigationBarTitleText": "附件查看",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/event-photos/event-photos",
"style": {
"navigationBarTitleText": "图片直播",
"navigationBarBackgroundColor": "#C93639",
"navigationBarTextStyle": "white"
}
}
], ],
"globalStyle": { "globalStyle": {"navigationBarTextStyle": "white", "navigationBarTitleText": "武术赛事", "navigationBarBackgroundColor": "#C93639", "backgroundColor": "#F8F8F8"},
"navigationBarTextStyle": "white", "tabBar": {"color": "#999999", "selectedColor": "#C93639", "backgroundColor": "#ffffff", "borderStyle": "black", "list": [{"pagePath": "pages/home/home", "text": "首页", "iconPath": "static/images/首页灰@3x.png", "selectedIconPath": "static/images/首页亮@3x.png"}, {"pagePath": "pages/profile/profile", "text": "个人中心", "iconPath": "static/images/个人中心灰@3x.png", "selectedIconPath": "static/images/个人中心亮@3x.png"}]}
"navigationBarTitleText": "武术赛事",
"navigationBarBackgroundColor": "#C93639",
"backgroundColor": "#F8F8F8"
},
"tabBar": {
"color": "#999999",
"selectedColor": "#C93639",
"backgroundColor": "#ffffff",
"borderStyle": "black",
"list": [
{
"pagePath": "pages/home/home",
"text": "首页",
"iconPath": "static/images/首页灰@3x.png",
"selectedIconPath": "static/images/首页亮@3x.png"
},
{
"pagePath": "pages/profile/profile",
"text": "个人中心",
"iconPath": "static/images/个人中心灰@3x.png",
"selectedIconPath": "static/images/个人中心亮@3x.png"
}
]
}
} }

View File

@@ -13,82 +13,46 @@
<view class="form-item"> <view class="form-item">
<view class="form-label">姓名</view> <view class="form-label">姓名</view>
<view class="form-value"> <view class="form-value">
<input <input class="form-input" v-model="formData.name" placeholder="请输入姓名" placeholder-class="placeholder" />
class="form-input"
v-model="formData.name"
placeholder="请输入姓名"
placeholder-class="placeholder"
/>
</view> </view>
</view> </view>
<view class="form-item"> <view class="form-item">
<view class="form-label">证件号码</view> <view class="form-label">证件号码</view>
<view class="form-value"> <view class="form-value">
<input <input class="form-input" v-model="formData.idCard" placeholder="请输入身份证号码" placeholder-class="placeholder" />
class="form-input"
v-model="formData.idCard"
placeholder="请输入身份证号码"
placeholder-class="placeholder"
/>
</view> </view>
</view> </view>
<view class="form-item"> <view class="form-item">
<view class="form-label">手机号码</view> <view class="form-label">手机号码</view>
<view class="form-value"> <view class="form-value">
<input <input class="form-input" v-model="formData.phone" placeholder="请输入手机号码" placeholder-class="placeholder" type="number" />
class="form-input"
v-model="formData.phone"
placeholder="请输入手机号码"
placeholder-class="placeholder"
type="number"
/>
</view> </view>
</view> </view>
<view class="form-item"> <view class="form-item">
<view class="form-label">邮箱</view> <view class="form-label">邮箱</view>
<view class="form-value"> <view class="form-value">
<input <input class="form-input" v-model="formData.email" placeholder="请输入邮箱" placeholder-class="placeholder" />
class="form-input"
v-model="formData.email"
placeholder="请输入邮箱"
placeholder-class="placeholder"
/>
</view> </view>
</view> </view>
<view class="form-item"> <view class="form-item">
<view class="form-label">地址</view> <view class="form-label">地址</view>
<view class="form-value"> <view class="form-value">
<input <input class="form-input" v-model="formData.address" placeholder="请输入地址" placeholder-class="placeholder" />
class="form-input"
v-model="formData.address"
placeholder="请输入地址"
placeholder-class="placeholder"
/>
</view> </view>
</view> </view>
<view class="form-item switch-item"> <view class="form-item switch-item">
<view class="form-label">设置为默认联系人</view> <view class="form-label">设置为默认联系人</view>
<view class="form-value"> <view class="form-value">
<switch <switch :checked="formData.isDefault" @change="handleSwitchChange" color="#C93639" />
:checked="formData.isDefault"
@change="handleSwitchChange"
color="#C93639"
/>
</view> </view>
</view> </view>
</view> </view>
<!-- 提示信息 -->
<view class="hint-message" v-if="showHint">
<text class="hint-icon"></text>
<text class="hint-text">{{ hintText }}</text>
</view>
<!-- Toast提示 --> <!-- Toast提示 -->
<view class="toast-message" v-if="showToast"> <view class="toast-message" v-if="showToast">
<text class="toast-text">{{ toastMessage }}</text> <text class="toast-text">{{ toastMessage }}</text>
@@ -96,13 +60,16 @@
<!-- 按钮 --> <!-- 按钮 -->
<view class="btn-wrapper"> <view class="btn-wrapper">
<view class="btn save-btn disabled" v-if="!isFormValid">保存</view> <view class="btn save-btn" :class="{ disabled: !isFormValid || saving }" @click="handleSave">
<view class="btn save-btn" v-else @click="handleSave">保存</view> {{ saving ? '保存中...' : '保存' }}
</view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import athleteAPI from '@/api/athlete.js';
export default { export default {
data() { data() {
return { return {
@@ -115,27 +82,20 @@ export default {
address: '', address: '',
isDefault: false isDefault: false
}, },
showHint: false,
hintText: '',
showToast: false, showToast: false,
toastMessage: '', toastMessage: '',
showIdTypePicker: false saving: false
}; };
}, },
computed: { computed: {
isFormValid() { isFormValid() {
return ( return this.formData.name && this.formData.idCard && this.formData.phone &&
this.formData.name && this.validateIdCard(this.formData.idCard) && this.validatePhone(this.formData.phone);
this.formData.idCard &&
this.formData.phone &&
this.validateIdCard(this.formData.idCard) &&
this.validatePhone(this.formData.phone)
);
} }
}, },
methods: { methods: {
validateIdCard(idCard) { validateIdCard(idCard) {
return /^\d{18}$/.test(idCard); return /^\d{17}[\dXx]$/.test(idCard);
}, },
validatePhone(phone) { validatePhone(phone) {
return /^1\d{10}$/.test(phone); return /^1\d{10}$/.test(phone);
@@ -143,38 +103,34 @@ export default {
handleSwitchChange(e) { handleSwitchChange(e) {
this.formData.isDefault = e.detail.value; this.formData.isDefault = e.detail.value;
}, },
handleSave() { showToastMsg(msg) {
if (!this.isFormValid) { this.toastMessage = msg;
if (this.formData.phone && !this.validatePhone(this.formData.phone)) { this.showToast = true;
this.toastMessage = '手机号码格式不正确'; setTimeout(() => { this.showToast = false; }, 2000);
this.showToast = true; },
setTimeout(() => { async handleSave() {
this.showToast = false; if (!this.isFormValid || this.saving) return;
}, 2000);
} else if (this.formData.idCard && !this.validateIdCard(this.formData.idCard)) { if (!this.validatePhone(this.formData.phone)) {
this.toastMessage = '身份证号码格式不正确'; this.showToastMsg('手机号码格式不正确');
this.showToast = true; return;
setTimeout(() => { }
this.showToast = false; if (!this.validateIdCard(this.formData.idCard)) {
}, 2000); this.showToastMsg('身份证号码格式不正确');
} else {
this.hintText = '请完善信息';
this.showHint = true;
setTimeout(() => {
this.showHint = false;
}, 2000);
}
return; return;
} }
// 实际保存逻辑 this.saving = true;
uni.showToast({ try {
title: '保存成功', await athleteAPI.saveContact(this.formData);
icon: 'success' uni.showToast({ title: '保存成功', icon: 'success' });
}); setTimeout(() => { uni.navigateBack(); }, 1500);
setTimeout(() => { } catch (err) {
uni.navigateBack(); console.error('保存联系人失败:', err);
}, 1500); this.showToastMsg('保存失败,请重试');
} finally {
this.saving = false;
}
} }
} }
}; };
@@ -201,13 +157,8 @@ export default {
border-bottom: 1rpx solid #f5f5f5; border-bottom: 1rpx solid #f5f5f5;
} }
.form-item:last-child { .form-item:last-child { border-bottom: none; }
border-bottom: none; .switch-item { padding: 30rpx; }
}
.switch-item {
padding: 30rpx;
}
.form-label { .form-label {
width: 180rpx; width: 180rpx;
@@ -228,38 +179,8 @@ export default {
color: #333333; color: #333333;
} }
.placeholder { .placeholder { color: #cccccc; }
color: #cccccc; .arrow { font-size: 40rpx; color: #cccccc; margin-left: 10rpx; }
}
.arrow {
font-size: 40rpx;
color: #cccccc;
margin-left: 10rpx;
}
.hint-message {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.7);
color: #fff;
padding: 30rpx 50rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
gap: 15rpx;
z-index: 9999;
}
.hint-icon {
font-size: 40rpx;
}
.hint-text {
font-size: 28rpx;
}
.toast-message { .toast-message {
position: fixed; position: fixed;
@@ -273,26 +194,7 @@ export default {
z-index: 9999; z-index: 9999;
} }
.toast-text { .toast-text { font-size: 28rpx; }
font-size: 28rpx;
}
.info-text {
margin: 20rpx 30rpx;
text-align: center;
}
.info-hint {
font-size: 24rpx;
color: #C93639;
}
.warning-text {
margin: 20rpx 30rpx;
text-align: center;
font-size: 24rpx;
color: #C93639;
}
.btn-wrapper { .btn-wrapper {
position: fixed; position: fixed;

View File

@@ -72,29 +72,16 @@
</view> </view>
</view> </view>
<!-- 错误提示 --> <!-- 错误提示 - 只在有具体错误时显示 -->
<view class="error-hints" v-if="errors.length > 0"> <view class="error-hints" v-if="validationErrors.length > 0">
<view class="error-item" v-for="(error, index) in errors" :key="index"> <view class="error-item" v-for="(error, index) in validationErrors" :key="index">
<text class="error-label">{{ error.label }}</text> <text class="error-text">{{ error }}</text>
<text class="error-msg">{{ error.message }}</text>
</view> </view>
</view> </view>
<!-- 提示信息 -->
<view class="hint-message" v-if="showHint">
<text class="hint-icon"></text>
<text class="hint-text">请完善信息</text>
</view>
<!-- Toast提示 -->
<view class="toast-message" v-if="showToast">
<text class="toast-text">{{ toastMessage }}</text>
</view>
<!-- 按钮 --> <!-- 按钮 -->
<view class="btn-wrapper"> <view class="btn-wrapper">
<view class="btn save-btn disabled" v-if="!isFormValid">保存</view> <view class="btn save-btn" :class="{ disabled: !isFormValid }" @click="handleSave">保存</view>
<view class="btn save-btn" v-else @click="handleSave">保存</view>
</view> </view>
<!-- 证件类型选择器 --> <!-- 证件类型选择器 -->
@@ -114,6 +101,7 @@
<script> <script>
import athleteAPI from '@/api/athlete.js' import athleteAPI from '@/api/athlete.js'
import { getUserInfo, getToken } from '@/utils/auth.js'
export default { export default {
data() { data() {
@@ -128,25 +116,17 @@ export default {
}, },
competitionId: '', competitionId: '',
projectIds: [], projectIds: [],
errors: [], validationErrors: [],
showHint: false,
showToast: false,
toastMessage: '',
showIdTypePicker: false showIdTypePicker: false
}; };
}, },
onLoad(options) { onLoad(options) {
// 接收赛事ID和项目ID
if (options.competitionId) { if (options.competitionId) {
this.competitionId = options.competitionId this.competitionId = options.competitionId
} }
if (options.projectIds) { if (options.projectIds) {
this.projectIds = options.projectIds.split(',').map(id => parseInt(id)) this.projectIds = options.projectIds.split(',')
} }
console.log('新增选手页面接收参数:', {
competitionId: this.competitionId,
projectIds: this.projectIds
})
}, },
computed: { computed: {
isFormValid() { isFormValid() {
@@ -162,153 +142,138 @@ export default {
} }
}, },
watch: { watch: {
'formData.name'(val) {
this.validateForm();
},
'formData.idCard'(val) { 'formData.idCard'(val) {
this.validateForm(); this.updateValidationErrors();
},
'formData.team'(val) {
this.validateForm();
},
'formData.organization'(val) {
this.validateForm();
}, },
'formData.phone'(val) { 'formData.phone'(val) {
this.validateForm(); this.updateValidationErrors();
} }
}, },
methods: { methods: {
validateIdCard(idCard) { validateIdCard(idCard) {
// 身份证号验证18位最后一位可以是数字或字母X if (!idCard) return false;
return /^\d{17}[\dXx]$/.test(idCard); if (!/^\d{17}[\dXx]$/.test(idCard)) return false;
},
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 || !this.formData.organization || !this.formData.phone) { const year = parseInt(idCard.substring(6, 10))
this.showHint = true; const month = parseInt(idCard.substring(10, 12))
if (!this.formData.name || !this.formData.idCard || !this.formData.team || !this.formData.organization || !this.formData.phone) { const day = parseInt(idCard.substring(12, 14))
this.errors.push({
label: '有空文本时弹出:', if (month < 1 || month > 12) return false;
message: '按钮置灰' if (day < 1 || day > 31) return false;
});
} const currentYear = new Date().getFullYear()
if (year < 1900 || year > currentYear) return false;
const date = new Date(year, month - 1, day)
if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {
return false;
} }
return true;
},
validatePhone(phone) {
return /^1[3-9]\d{9}$/.test(phone);
},
updateValidationErrors() {
this.validationErrors = [];
if (this.formData.idCard && !this.validateIdCard(this.formData.idCard)) { if (this.formData.idCard && !this.validateIdCard(this.formData.idCard)) {
this.errors.push({ this.validationErrors.push('身份证号码格式不正确');
label: '身份证不足18位',
message: '按钮置灰'
});
this.errors.push({
label: '输入不合法:',
message: '按钮置灰'
});
} }
if (this.formData.phone && !this.validatePhone(this.formData.phone)) { if (this.formData.phone && !this.validatePhone(this.formData.phone)) {
this.errors.push({ this.validationErrors.push('手机号格式不正确');
label: '手机号格式不正确:',
message: '按钮置灰'
});
} }
}, },
handleIdTypeChange(e) { handleIdTypeChange(e) {
this.formData.idType = '身份证'; this.formData.idType = '身份证';
this.showIdTypePicker = false; this.showIdTypePicker = false;
}, },
/**
* 从身份证号中提取信息
*/
extractInfoFromIdCard(idCard) { extractInfoFromIdCard(idCard) {
if (!idCard || idCard.length !== 18) { if (!idCard || idCard.length !== 18) {
return { return { gender: null, age: null, birthDate: null }
gender: null,
age: null,
birthDate: null
}
} }
// 提取出生日期
const year = idCard.substring(6, 10) const year = idCard.substring(6, 10)
const month = idCard.substring(10, 12) const month = idCard.substring(10, 12)
const day = idCard.substring(12, 14) const day = idCard.substring(12, 14)
const birthDate = `${year}-${month}-${day}` const birthDate = `${year}-${month}-${day}`
// 计算年龄
const birthYear = parseInt(year) const birthYear = parseInt(year)
const currentYear = new Date().getFullYear() const currentYear = new Date().getFullYear()
const age = currentYear - birthYear const age = currentYear - birthYear
// 提取性别(倒数第二位,奇数为男,偶数为女)
const genderCode = parseInt(idCard.substring(16, 17)) const genderCode = parseInt(idCard.substring(16, 17))
const gender = genderCode % 2 === 1 ? 1 : 2 const gender = genderCode % 2 === 1 ? 1 : 2
return { return { gender, age, birthDate }
gender,
age,
birthDate
}
}, },
async handleSave() { async handleSave() {
if (!this.isFormValid) { if (!this.isFormValid) {
uni.showToast({
title: '请完善信息',
icon: 'none'
})
return;
}
// Check login status
const token = getToken()
if (!token) {
uni.showToast({
title: '请先登录',
icon: 'none'
})
setTimeout(() => {
uni.navigateTo({
url: '/pages/login/login'
})
}, 1500)
return; return;
} }
try { try {
// 从身份证号中提取信息
const info = this.extractInfoFromIdCard(this.formData.idCard) const info = this.extractInfoFromIdCard(this.formData.idCard)
// 调用API保存选手信息使用后端实体类的字段名 const userInfo = getUserInfo()
const submitData = { const submitData = {
playerName: this.formData.name, playerName: this.formData.name,
idCard: this.formData.idCard, idCard: this.formData.idCard,
teamName: this.formData.team, teamName: this.formData.team,
organization: this.formData.organization, organization: this.formData.organization,
contactPhone: this.formData.phone, contactPhone: this.formData.phone,
idCardType: 1, // 身份证类型固定为1 idCardType: 1,
gender: info.gender, gender: info.gender,
age: info.age, age: info.age,
birthDate: info.birthDate birthDate: info.birthDate,
createUser: userInfo ? userInfo.userId : null
} }
// 如果有赛事ID和项目ID一起提交
if (this.competitionId) { if (this.competitionId) {
submitData.competitionId = parseInt(this.competitionId) submitData.competitionId = this.competitionId
} }
if (this.projectIds && this.projectIds.length > 0) { if (this.projectIds && this.projectIds.length > 0) {
// 如果有多个项目取第一个项目ID
submitData.projectId = this.projectIds[0] submitData.projectId = this.projectIds[0]
} }
console.log('提交选手数据:', submitData) console.log('提交选手数据:', submitData)
await athleteAPI.submitAthlete(submitData) await athleteAPI.submitAthlete(submitData)
// 保存成功
uni.showToast({ uni.showToast({
title: '保存成功', title: '保存成功',
icon: 'success' icon: 'success'
}) })
// 延迟返回上一页
setTimeout(() => { setTimeout(() => {
uni.navigateBack() uni.navigateBack()
}, 1500) }, 1500)
} catch (err) { } catch (err) {
console.error('保存选手失败:', err) console.error('保存选手失败:', err)
// 显示错误提示 uni.showToast({
this.toastMessage = '保存失败,请重试' title: err.message || '保存失败,请重试',
this.showToast = true icon: 'none'
setTimeout(() => { })
this.showToast = false
}, 2000)
} }
} }
} }
@@ -370,64 +335,23 @@ export default {
} }
.error-hints { .error-hints {
margin: 30rpx; margin: 0 30rpx;
padding: 30rpx; padding: 20rpx;
background-color: #fff; background-color: #fff3f3;
border-radius: 16rpx; border-radius: 8rpx;
} }
.error-item { .error-item {
margin-bottom: 15rpx; margin-bottom: 10rpx;
} }
.error-label { .error-item:last-child {
margin-bottom: 0;
}
.error-text {
font-size: 26rpx; font-size: 26rpx;
color: #C93639; color: #C93639;
margin-right: 10rpx;
}
.error-msg {
font-size: 26rpx;
color: #C93639;
}
.hint-message {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.7);
color: #fff;
padding: 30rpx 50rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
gap: 15rpx;
z-index: 9999;
}
.hint-icon {
font-size: 40rpx;
}
.hint-text {
font-size: 28rpx;
}
.toast-message {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.7);
color: #fff;
padding: 30rpx 50rpx;
border-radius: 16rpx;
z-index: 9999;
}
.toast-text {
font-size: 28rpx;
} }
.btn-wrapper { .btn-wrapper {

View File

@@ -0,0 +1,374 @@
<template>
<view class="add-team-page">
<view class="form-section">
<view class="form-item">
<view class="form-label required">集体名称</view>
<input
class="form-input"
type="text"
v-model="formData.name"
placeholder="请输入集体名称"
/>
</view>
<view class="form-item">
<view class="form-label">备注</view>
<textarea
class="form-textarea"
v-model="formData.remark"
placeholder="请输入备注信息"
></textarea>
</view>
</view>
<!-- 成员列表 -->
<view class="member-section">
<view class="section-header">
<text class="section-title">成员列表</text>
<view class="add-member-btn" @click="showMemberPicker = true">
<text>+ 添加成员</text>
</view>
</view>
<view class="member-list" v-if="formData.members.length > 0">
<view class="member-item" v-for="(member, index) in formData.members" :key="index">
<view class="member-info">
<text class="member-name">{{ member.name }}</text>
</view>
<view class="remove-btn" @click="removeMember(index)">移除</view>
</view>
</view>
<view class="empty-members" v-else>
<text>暂无成员请添加</text>
</view>
</view>
<!-- 提交按钮 -->
<view class="submit-btn-wrapper">
<view class="submit-btn" @click="handleSubmit">保存</view>
</view>
<!-- 成员选择弹窗 -->
<view class="member-picker-mask" v-if="showMemberPicker" @click="showMemberPicker = false">
<view class="member-picker" @click.stop>
<view class="picker-header">
<text class="picker-title">选择成员</text>
<text class="picker-close" @click="showMemberPicker = false">×</text>
</view>
<view class="picker-list">
<view
class="picker-item"
v-for="(player, index) in availablePlayers"
:key="index"
@click="addMember(player)"
>
<text>{{ player.name }}</text>
<text class="add-icon">+</text>
</view>
<view class="empty-picker" v-if="availablePlayers.length === 0">
<text>暂无可选成员</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import athleteAPI from '@/api/athlete.js';
import { getUserInfo } from '@/utils/auth.js';
export default {
data() {
return {
formData: {
name: '',
remark: '',
members: []
},
playerList: [],
showMemberPicker: false
};
},
computed: {
availablePlayers() {
const memberIds = this.formData.members.map(m => m.id)
return this.playerList.filter(p => !memberIds.includes(p.id))
}
},
onLoad() {
this.loadPlayerList()
},
methods: {
async loadPlayerList() {
try {
const userInfo = getUserInfo()
if (!userInfo || !userInfo.userId) return
const res = await athleteAPI.getAthleteList({
current: 1,
size: 100,
createUser: userInfo.userId
})
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.playerName
}))
} catch (err) {
console.error('加载选手列表失败:', err)
}
},
addMember(player) {
this.formData.members.push({
id: player.id,
name: player.name
})
this.showMemberPicker = false
},
removeMember(index) {
this.formData.members.splice(index, 1)
},
async handleSubmit() {
if (!this.formData.name) {
uni.showToast({
title: '请输入集体名称',
icon: 'none'
})
return
}
if (this.formData.members.length === 0) {
uni.showToast({
title: '请添加至少一名成员',
icon: 'none'
})
return
}
try {
const userInfo = getUserInfo()
const data = {
teamName: this.formData.name,
remark: this.formData.remark,
memberIds: this.formData.members.map(m => m.id),
createUser: userInfo?.userId
}
if (athleteAPI.saveTeam) {
await athleteAPI.saveTeam(data)
}
uni.showToast({
title: '保存成功',
icon: 'success'
})
setTimeout(() => {
uni.navigateBack()
}, 1500)
} catch (err) {
console.error('保存失败:', err)
uni.showToast({
title: '保存失败',
icon: 'none'
})
}
}
}
};
</script>
<style lang="scss" scoped>
.add-team-page {
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 150rpx;
}
.form-section {
background-color: #fff;
padding: 30rpx;
margin-bottom: 20rpx;
}
.form-item {
margin-bottom: 30rpx;
}
.form-label {
font-size: 28rpx;
color: #333;
margin-bottom: 15rpx;
}
.form-label.required::before {
content: '*';
color: #C93639;
margin-right: 5rpx;
}
.form-input {
width: 100%;
height: 80rpx;
background-color: #f5f5f5;
border-radius: 8rpx;
padding: 0 20rpx;
font-size: 28rpx;
}
.form-textarea {
width: 100%;
height: 200rpx;
background-color: #f5f5f5;
border-radius: 8rpx;
padding: 20rpx;
font-size: 28rpx;
}
.member-section {
background-color: #fff;
padding: 30rpx;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
}
.section-title {
font-size: 30rpx;
font-weight: bold;
color: #333;
}
.add-member-btn {
color: #C93639;
font-size: 28rpx;
}
.member-list {
margin-top: 20rpx;
}
.member-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx;
background-color: #f5f5f5;
border-radius: 8rpx;
margin-bottom: 15rpx;
}
.member-name {
font-size: 28rpx;
color: #333;
}
.remove-btn {
color: #C93639;
font-size: 26rpx;
}
.empty-members {
text-align: center;
padding: 50rpx;
color: #999;
font-size: 28rpx;
}
.submit-btn-wrapper {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 30rpx;
background-color: #fff;
}
.submit-btn {
background-color: #C93639;
color: #fff;
text-align: center;
padding: 30rpx;
border-radius: 12rpx;
font-size: 32rpx;
font-weight: bold;
}
.member-picker-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
display: flex;
align-items: flex-end;
}
.member-picker {
width: 100%;
background-color: #fff;
border-radius: 20rpx 20rpx 0 0;
max-height: 70vh;
}
.picker-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #eee;
}
.picker-title {
font-size: 32rpx;
font-weight: bold;
}
.picker-close {
font-size: 40rpx;
color: #999;
}
.picker-list {
max-height: 60vh;
overflow-y: auto;
}
.picker-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #f5f5f5;
}
.add-icon {
color: #C93639;
font-size: 36rpx;
}
.empty-picker {
text-align: center;
padding: 50rpx;
color: #999;
}
</style>

View File

@@ -6,10 +6,10 @@
<!-- 新增按钮 --> <!-- 新增按钮 -->
<view class="add-btn-wrapper" @click="handleAdd"> <view class="add-btn-wrapper" @click="handleAdd">
<text class="add-icon"></text> <text class="add-icon"></text>
<text class="add-text">{{ currentTab === 0 ? '新增选手' : '新增联系人' }}</text> <text class="add-text">{{ addButtonText }}</text>
</view> </view>
<!-- 选手列表 --> <!-- 选手列表 (Tab 0) -->
<view class="player-list" v-if="currentTab === 0 && playerList.length > 0"> <view class="player-list" v-if="currentTab === 0 && playerList.length > 0">
<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-info"> <view class="player-info">
@@ -21,7 +21,7 @@
<image class="action-icon" src="/static/images/编辑@3x.png" mode="aspectFit"></image> <image class="action-icon" src="/static/images/编辑@3x.png" mode="aspectFit"></image>
<text>编辑</text> <text>编辑</text>
</view> </view>
<view class="action-btn delete-btn" @click.stop="handleDelete(item)"> <view class="action-btn delete-btn" @click.stop="handleDelete(item, 'player')">
<image class="action-icon" src="/static/images/删除@3x.png" mode="aspectFit"></image> <image class="action-icon" src="/static/images/删除@3x.png" mode="aspectFit"></image>
<text>删除</text> <text>删除</text>
</view> </view>
@@ -29,21 +29,69 @@
</view> </view>
</view> </view>
<!-- 空状态 --> <!-- 选手空状态 -->
<view class="empty-state" v-if="currentTab === 0 && playerList.length === 0"> <view class="empty-state" v-if="currentTab === 0 && playerList.length === 0">
<text class="empty-text">暂无选手信息</text> <text class="empty-text">暂无选手信息</text>
</view> </view>
<!-- 联系人Tab内容 --> <!-- 集体列表 (Tab 1) -->
<view class="empty-state" v-if="currentTab === 1"> <view class="player-list" v-if="currentTab === 1 && teamList.length > 0">
<view class="player-item" v-for="(item, index) in teamList" :key="index">
<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 edit-btn" @click.stop="handleEditTeam(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, 'team')">
<image class="action-icon" src="/static/images/删除@3x.png" mode="aspectFit"></image>
<text>删除</text>
</view>
</view>
</view>
</view>
<!-- 集体空状态 -->
<view class="empty-state" v-if="currentTab === 1 && teamList.length === 0">
<text class="empty-text">暂无集体信息</text>
</view>
<!-- 联系人列表 (Tab 2) -->
<view class="player-list" v-if="currentTab === 2 && contactList.length > 0">
<view class="player-item" v-for="(item, index) in contactList" :key="index">
<view class="player-info">
<view class="player-name">
{{ item.name }}
<text class="default-tag" v-if="item.isDefault">默认</text>
</view>
<view class="player-id">手机{{ item.phone }}</view>
</view>
<view class="player-actions">
<view class="action-btn edit-btn" @click.stop="handleEditContact(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, 'contact')">
<image class="action-icon" src="/static/images/删除@3x.png" mode="aspectFit"></image>
<text>删除</text>
</view>
</view>
</view>
</view>
<!-- 联系人空状态 -->
<view class="empty-state" v-if="currentTab === 2 && contactList.length === 0">
<text class="empty-text">暂无联系人信息</text> <text class="empty-text">暂无联系人信息</text>
</view> </view>
<!-- 删除确认弹窗 --> <!-- 删除确认弹窗 -->
<confirm-modal <confirm-modal
:show="showDeleteModal" :show="showDeleteModal"
title="删除选手" :title="deleteModalTitle"
content="确定要删除该选手吗?" :content="deleteModalContent"
@cancel="showDeleteModal = false" @cancel="showDeleteModal = false"
@confirm="confirmDelete" @confirm="confirmDelete"
></confirm-modal> ></confirm-modal>
@@ -69,52 +117,57 @@ export default {
}, },
data() { data() {
return { return {
tabs: ['选手', '联系人'], tabs: ['选手', '集体', '联系人'],
currentTab: 0, currentTab: 0,
playerList: [], playerList: [],
teamList: [],
contactList: [],
showDeleteModal: false, showDeleteModal: false,
showSuccessToast: false, showSuccessToast: false,
currentItem: null currentItem: null,
deleteType: 'player'
}; };
}, },
computed: {
addButtonText() {
if (this.currentTab === 0) return '新增选手'
if (this.currentTab === 1) return '新增集体'
return '新增联系人'
},
deleteModalTitle() {
if (this.deleteType === 'team') return '删除集体'
if (this.deleteType === 'contact') return '删除联系人'
return '删除选手'
},
deleteModalContent() {
if (this.deleteType === 'team') return '确定要删除该集体吗?'
if (this.deleteType === 'contact') return '确定要删除该联系人吗?'
return '确定要删除该选手吗?'
}
},
onLoad() { onLoad() {
this.loadPlayerList() this.loadPlayerList()
this.loadTeamList()
this.loadContactList()
}, },
onShow() { onShow() {
// 从新增/编辑页面返回时重新加载列表
this.loadPlayerList() this.loadPlayerList()
this.loadTeamList()
this.loadContactList()
}, },
methods: { methods: {
/**
* 加载选手列表
*/
async loadPlayerList() { async loadPlayerList() {
try { try {
// 获取当前用户信息
const userInfo = getUserInfo() const userInfo = getUserInfo()
if (!userInfo || !userInfo.userId) { if (!userInfo || !userInfo.userId) return
console.error('未获取到用户信息')
uni.showToast({
title: '请先登录',
icon: 'none'
})
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.playerName, name: item.name || item.playerName,
@@ -128,53 +181,113 @@ export default {
} }
}, },
async loadTeamList() {
try {
const userInfo = getUserInfo()
if (!userInfo || !userInfo.userId) return
if (athleteAPI.getTeamList) {
const res = await athleteAPI.getTeamList({
current: 1,
size: 100,
createUser: userInfo.userId
})
let list = res.records || (Array.isArray(res) ? res : [])
this.teamList = list.map(item => ({
id: item.id,
name: item.name || item.teamName,
memberCount: item.memberCount || item.members?.length || 0
}))
}
} catch (err) {
console.error('加载集体列表失败:', err)
this.teamList = []
}
},
async loadContactList() {
try {
const userInfo = getUserInfo()
if (!userInfo || !userInfo.userId) return
if (athleteAPI.getContactList) {
const res = await athleteAPI.getContactList({
current: 1,
size: 100,
createUser: userInfo.userId
})
let list = res.records || (Array.isArray(res) ? res : [])
this.contactList = list.map(item => ({
id: item.id,
name: item.name,
phone: item.phone,
idCard: item.idCard,
email: item.email,
address: item.address,
isDefault: item.isDefault
}))
}
} catch (err) {
console.error('加载联系人列表失败:', err)
this.contactList = []
}
},
handleTabChange(index) { handleTabChange(index) {
this.currentTab = index; this.currentTab = index;
}, },
handleAdd() { handleAdd() {
if (this.currentTab === 0) { if (this.currentTab === 0) {
uni.navigateTo({ uni.navigateTo({ url: '/pages/add-player/add-player' });
url: '/pages/add-player/add-player'
});
} else if (this.currentTab === 1) { } else if (this.currentTab === 1) {
uni.navigateTo({ uni.navigateTo({ url: '/pages/add-team/add-team' });
url: '/pages/add-contact/add-contact' } else if (this.currentTab === 2) {
}); uni.navigateTo({ url: '/pages/add-contact/add-contact' });
} }
}, },
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
});
}, },
handleDelete(item) { handleEditTeam(item) {
uni.navigateTo({ url: '/pages/edit-team/edit-team?id=' + item.id });
},
handleEditContact(item) {
uni.navigateTo({ url: '/pages/edit-contact/edit-contact?id=' + item.id });
},
handleDelete(item, type) {
this.currentItem = item; this.currentItem = item;
this.deleteType = type;
this.showDeleteModal = true; this.showDeleteModal = true;
}, },
async confirmDelete() { async confirmDelete() {
this.showDeleteModal = false; this.showDeleteModal = false;
try { try {
// 调用删除API if (this.deleteType === 'team') {
await athleteAPI.removeAthlete(this.currentItem.id) if (athleteAPI.removeTeam) {
await athleteAPI.removeTeam(this.currentItem.id)
// 从列表中移除 }
const index = this.playerList.findIndex(item => item.id === this.currentItem.id); const index = this.teamList.findIndex(item => item.id === this.currentItem.id);
if (index > -1) { if (index > -1) this.teamList.splice(index, 1);
this.playerList.splice(index, 1); } else if (this.deleteType === 'contact') {
if (athleteAPI.removeContact) {
await athleteAPI.removeContact(this.currentItem.id)
}
const index = this.contactList.findIndex(item => item.id === this.currentItem.id);
if (index > -1) this.contactList.splice(index, 1);
} else {
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; this.showSuccessToast = true;
setTimeout(() => { setTimeout(() => { this.showSuccessToast = false; }, 2000);
this.showSuccessToast = false;
}, 2000);
} catch (err) { } catch (err) {
console.error('删除选手失败:', err) console.error('删除失败:', err)
uni.showToast({ uni.showToast({ title: '删除失败', icon: 'none' })
title: '删除失败',
icon: 'none'
})
} }
} }
} }
@@ -227,6 +340,18 @@ export default {
font-weight: bold; font-weight: bold;
color: #333333; color: #333333;
margin-bottom: 10rpx; margin-bottom: 10rpx;
display: flex;
align-items: center;
gap: 10rpx;
}
.default-tag {
font-size: 22rpx;
color: #fff;
background-color: #C93639;
padding: 4rpx 12rpx;
border-radius: 6rpx;
font-weight: normal;
} }
.player-id { .player-id {
@@ -260,10 +385,6 @@ export default {
border-color: #C93639; border-color: #C93639;
} }
.icon {
font-size: 28rpx;
}
.action-icon { .action-icon {
width: 28rpx; width: 28rpx;
height: 28rpx; height: 28rpx;

View File

@@ -0,0 +1,249 @@
<template>
<view class="add-contact-page">
<view class="form-container">
<view class="form-item" @click="showIdTypePicker = true">
<view class="form-label">证件类型</view>
<view class="form-value">
<text>{{ formData.idType }}</text>
<text class="arrow"></text>
</view>
</view>
<view class="form-item">
<view class="form-label">姓名</view>
<view class="form-value">
<input class="form-input" v-model="formData.name" 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.idCard" 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" placeholder="请输入手机号码" placeholder-class="placeholder" type="number" />
</view>
</view>
<view class="form-item">
<view class="form-label">邮箱</view>
<view class="form-value">
<input class="form-input" v-model="formData.email" 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.address" placeholder="请输入地址" placeholder-class="placeholder" />
</view>
</view>
<view class="form-item switch-item">
<view class="form-label">设置为默认联系人</view>
<view class="form-value">
<switch :checked="formData.isDefault" @change="handleSwitchChange" color="#C93639" />
</view>
</view>
</view>
<view class="toast-message" v-if="showToast">
<text class="toast-text">{{ toastMessage }}</text>
</view>
<view class="btn-wrapper">
<view class="btn save-btn" :class="{ disabled: !isFormValid || saving }" @click="handleSave">
{{ saving ? '保存中...' : '保存' }}
</view>
</view>
</view>
</template>
<script>
import athleteAPI from '@/api/athlete.js';
export default {
data() {
return {
contactId: null,
formData: {
idType: '身份证',
name: '',
idCard: '',
phone: '',
email: '',
address: '',
isDefault: false
},
showToast: false,
toastMessage: '',
saving: false
};
},
computed: {
isFormValid() {
return this.formData.name && this.formData.idCard && this.formData.phone &&
this.validateIdCard(this.formData.idCard) && this.validatePhone(this.formData.phone);
}
},
onLoad(options) {
if (options.id) {
this.contactId = options.id;
this.loadContactDetail();
}
},
methods: {
validateIdCard(idCard) {
return /^\d{17}[\dXx]$/.test(idCard);
},
validatePhone(phone) {
return /^1\d{10}$/.test(phone);
},
handleSwitchChange(e) {
this.formData.isDefault = e.detail.value;
},
showToastMsg(msg) {
this.toastMessage = msg;
this.showToast = true;
setTimeout(() => { this.showToast = false; }, 2000);
},
async loadContactDetail() {
try {
const res = await athleteAPI.getContactDetail(this.contactId);
if (res) {
this.formData = {
idType: res.idType || '身份证',
name: res.name || '',
idCard: res.idCard || '',
phone: res.phone || '',
email: res.email || '',
address: res.address || '',
isDefault: res.isDefault || false
};
}
} catch (err) {
console.error('加载联系人详情失败:', err);
this.showToastMsg('加载失败');
}
},
async handleSave() {
if (!this.isFormValid || this.saving) return;
if (!this.validatePhone(this.formData.phone)) {
this.showToastMsg('手机号码格式不正确');
return;
}
if (!this.validateIdCard(this.formData.idCard)) {
this.showToastMsg('身份证号码格式不正确');
return;
}
this.saving = true;
try {
const data = { ...this.formData, id: this.contactId };
await athleteAPI.saveContact(data);
uni.showToast({ title: '保存成功', icon: 'success' });
setTimeout(() => { uni.navigateBack(); }, 1500);
} catch (err) {
console.error('保存联系人失败:', err);
this.showToastMsg('保存失败,请重试');
} finally {
this.saving = false;
}
}
}
};
</script>
<style lang="scss" scoped>
.add-contact-page {
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 200rpx;
}
.form-container {
background-color: #fff;
margin: 30rpx;
border-radius: 16rpx;
overflow: hidden;
}
.form-item {
display: flex;
align-items: center;
padding: 35rpx 30rpx;
border-bottom: 1rpx solid #f5f5f5;
}
.form-item:last-child { border-bottom: none; }
.switch-item { padding: 30rpx; }
.form-label {
width: 180rpx;
font-size: 30rpx;
color: #333333;
}
.form-value {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
}
.form-input {
flex: 1;
font-size: 30rpx;
color: #333333;
}
.placeholder { color: #cccccc; }
.arrow { font-size: 40rpx; color: #cccccc; margin-left: 10rpx; }
.toast-message {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.7);
color: #fff;
padding: 30rpx 50rpx;
border-radius: 16rpx;
z-index: 9999;
}
.toast-text { font-size: 28rpx; }
.btn-wrapper {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 30rpx;
background-color: #f5f5f5;
}
.btn {
width: 100%;
text-align: center;
padding: 30rpx;
border-radius: 12rpx;
font-size: 32rpx;
font-weight: bold;
}
.save-btn {
background-color: #C93639;
color: #fff;
}
.save-btn.disabled {
background-color: rgba(201, 54, 57, 0.5);
}
</style>

View File

@@ -0,0 +1,401 @@
<template>
<view class="add-team-page">
<view class="form-section">
<view class="form-item">
<view class="form-label required">集体名称</view>
<input
class="form-input"
type="text"
v-model="formData.name"
placeholder="请输入集体名称"
/>
</view>
<view class="form-item">
<view class="form-label">备注</view>
<textarea
class="form-textarea"
v-model="formData.remark"
placeholder="请输入备注信息"
></textarea>
</view>
</view>
<!-- 成员列表 -->
<view class="member-section">
<view class="section-header">
<text class="section-title">成员列表</text>
<view class="add-member-btn" @click="showMemberPicker = true">
<text>+ 添加成员</text>
</view>
</view>
<view class="member-list" v-if="formData.members.length > 0">
<view class="member-item" v-for="(member, index) in formData.members" :key="index">
<view class="member-info">
<text class="member-name">{{ member.name }}</text>
</view>
<view class="remove-btn" @click="removeMember(index)">移除</view>
</view>
</view>
<view class="empty-members" v-else>
<text>暂无成员请添加</text>
</view>
</view>
<!-- 提交按钮 -->
<view class="submit-btn-wrapper">
<view class="submit-btn" @click="handleSubmit">保存</view>
</view>
<!-- 成员选择弹窗 -->
<view class="member-picker-mask" v-if="showMemberPicker" @click="showMemberPicker = false">
<view class="member-picker" @click.stop>
<view class="picker-header">
<text class="picker-title">选择成员</text>
<text class="picker-close" @click="showMemberPicker = false">×</text>
</view>
<view class="picker-list">
<view
class="picker-item"
v-for="(player, index) in availablePlayers"
:key="index"
@click="addMember(player)"
>
<text>{{ player.name }}</text>
<text class="add-icon">+</text>
</view>
<view class="empty-picker" v-if="availablePlayers.length === 0">
<text>暂无可选成员</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import athleteAPI from '@/api/athlete.js';
import { getUserInfo } from '@/utils/auth.js';
export default {
data() {
return {
teamId: null,
formData: {
name: '',
remark: '',
members: []
},
playerList: [],
showMemberPicker: false
};
},
computed: {
availablePlayers() {
const memberIds = this.formData.members.map(m => m.id)
return this.playerList.filter(p => !memberIds.includes(p.id))
}
},
onLoad(options) {
if (options.id) {
this.teamId = options.id
this.loadTeamDetail()
}
this.loadPlayerList()
},
methods: {
async loadTeamDetail() {
try {
const res = await athleteAPI.getTeamDetail(this.teamId)
if (res) {
this.formData.name = res.teamName || res.name || ''
this.formData.remark = res.remark || ''
if (res.members && Array.isArray(res.members)) {
this.formData.members = res.members.map(m => ({
id: m.id,
name: m.name || m.playerName
}))
}
}
} catch (err) {
console.error('加载集体详情失败:', err)
uni.showToast({
title: '加载失败',
icon: 'none'
})
}
},
async loadPlayerList() {
try {
const userInfo = getUserInfo()
if (!userInfo || !userInfo.userId) return
const res = await athleteAPI.getAthleteList({
current: 1,
size: 100,
createUser: userInfo.userId
})
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.playerName
}))
} catch (err) {
console.error('加载选手列表失败:', err)
}
},
addMember(player) {
this.formData.members.push({
id: player.id,
name: player.name
})
this.showMemberPicker = false
},
removeMember(index) {
this.formData.members.splice(index, 1)
},
async handleSubmit() {
if (!this.formData.name) {
uni.showToast({
title: '请输入集体名称',
icon: 'none'
})
return
}
if (this.formData.members.length === 0) {
uni.showToast({
title: '请添加至少一名成员',
icon: 'none'
})
return
}
try {
const userInfo = getUserInfo()
const data = {
teamId: this.teamId ? String(this.teamId) : null,
teamName: this.formData.name,
remark: this.formData.remark,
memberIds: this.formData.members.map(m => String(m.id)),
createUser: userInfo?.userId
}
console.log('Submitting team data:', JSON.stringify(data))
await athleteAPI.saveTeam(data)
uni.showToast({
title: '保存成功',
icon: 'success'
})
setTimeout(() => {
uni.navigateBack()
}, 1500)
} catch (err) {
console.error('保存失败:', err)
uni.showToast({
title: '保存失败',
icon: 'none'
})
}
}
}
};
</script>
<style lang="scss" scoped>
.add-team-page {
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 150rpx;
}
.form-section {
background-color: #fff;
padding: 30rpx;
margin-bottom: 20rpx;
}
.form-item {
margin-bottom: 30rpx;
}
.form-label {
font-size: 28rpx;
color: #333;
margin-bottom: 15rpx;
}
.form-label.required::before {
content: '*';
color: #C93639;
margin-right: 5rpx;
}
.form-input {
width: 100%;
height: 80rpx;
background-color: #f5f5f5;
border-radius: 8rpx;
padding: 0 20rpx;
font-size: 28rpx;
}
.form-textarea {
width: 100%;
height: 200rpx;
background-color: #f5f5f5;
border-radius: 8rpx;
padding: 20rpx;
font-size: 28rpx;
}
.member-section {
background-color: #fff;
padding: 30rpx;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
}
.section-title {
font-size: 30rpx;
font-weight: bold;
color: #333;
}
.add-member-btn {
color: #C93639;
font-size: 28rpx;
}
.member-list {
margin-top: 20rpx;
}
.member-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx;
background-color: #f5f5f5;
border-radius: 8rpx;
margin-bottom: 15rpx;
}
.member-name {
font-size: 28rpx;
color: #333;
}
.remove-btn {
color: #C93639;
font-size: 26rpx;
}
.empty-members {
text-align: center;
padding: 50rpx;
color: #999;
font-size: 28rpx;
}
.submit-btn-wrapper {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 30rpx;
background-color: #fff;
}
.submit-btn {
background-color: #C93639;
color: #fff;
text-align: center;
padding: 30rpx;
border-radius: 12rpx;
font-size: 32rpx;
font-weight: bold;
}
.member-picker-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
display: flex;
align-items: flex-end;
}
.member-picker {
width: 100%;
background-color: #fff;
border-radius: 20rpx 20rpx 0 0;
max-height: 70vh;
}
.picker-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #eee;
}
.picker-title {
font-size: 32rpx;
font-weight: bold;
}
.picker-close {
font-size: 40rpx;
color: #999;
}
.picker-list {
max-height: 60vh;
overflow-y: auto;
}
.picker-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #f5f5f5;
}
.add-icon {
color: #C93639;
font-size: 36rpx;
}
.empty-picker {
text-align: center;
padding: 50rpx;
color: #999;
}
</style>

View File

@@ -1,5 +1,27 @@
<template> <template>
<view class="event-info-page"> <view class="event-info-page">
<!-- 附件下载区 -->
<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="info-list"> <view class="info-list">
<view class="info-item" v-for="(item, index) in infoList" :key="index" @click="handleItemClick(item)"> <view class="info-item" v-for="(item, index) in infoList" :key="index" @click="handleItemClick(item)">
@@ -13,7 +35,7 @@
</view> </view>
<!-- 空状态 --> <!-- 空状态 -->
<view class="empty-state" v-if="infoList.length === 0"> <view class="empty-state" v-if="infoList.length === 0 && attachments.length === 0">
<text class="empty-text">暂无信息发布</text> <text class="empty-text">暂无信息发布</text>
</view> </view>
</view> </view>
@@ -21,21 +43,57 @@
<script> <script>
import infoAPI from '@/api/info.js' import infoAPI from '@/api/info.js'
import competitionAPI from '@/api/competition.js'
export default { export default {
data() { data() {
return { return {
eventId: '', eventId: '',
infoList: [] infoList: [],
attachments: []
}; };
}, },
onLoad(options) { onLoad(options) {
if (options.eventId) { if (options.eventId) {
this.eventId = options.eventId this.eventId = options.eventId
this.loadInfoList(options.eventId) this.loadInfoList(options.eventId)
this.loadAttachments(options.eventId)
} }
}, },
methods: { methods: {
/**
* 加载附件列表
*/
async loadAttachments(eventId) {
try {
const res = await competitionAPI.getAttachments({
competitionId: eventId,
type: 'info'
})
let list = []
if (res && Array.isArray(res)) {
list = res
} else if (res && res.records) {
list = res.records
} else if (res && res.data && Array.isArray(res.data)) {
list = res.data
}
if (list.length > 0) {
this.attachments = list.map(file => ({
id: file.id,
fileName: file.fileName || file.name,
fileUrl: file.fileUrl || file.url,
fileSize: this.formatFileSize(file.fileSize || file.size),
fileType: file.fileType || this.getFileType(file.fileName || file.name)
}))
}
} catch (err) {
console.error('加载附件失败:', err)
}
},
/** /**
* 加载信息发布列表 * 加载信息发布列表
*/ */
@@ -50,11 +108,6 @@ export default {
list = res list = res
} }
// 如果后端没有数据,使用模拟数据
if (list.length === 0) {
list = this.getMockData()
}
// 数据映射 // 数据映射
this.infoList = list.map(item => ({ this.infoList = list.map(item => ({
id: item.id, id: item.id,
@@ -66,81 +119,100 @@ export default {
})) }))
} catch (err) { } catch (err) {
console.error('加载信息列表失败:', 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() { downloadFile(file) {
return [ const fileExt = file.fileType || this.getFileType(file.fileName) || 'pdf'
{
id: 1, // #ifdef H5
info_type: 3, const link = document.createElement('a')
title: '重要通知:赛事报名截止时间变更', link.href = file.fileUrl
content: '由于场馆调整本次赛事报名截止时间延长至2025年12月20日请各位选手抓紧时间报名。如有疑问请联系赛事组委会。', link.download = file.fileName
publishTime: '2025-01-10 09:00:00' link.target = '_blank'
link.style.display = 'none'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
uni.showToast({
title: '开始下载',
icon: 'success'
})
return
// #endif
// #ifndef H5
uni.showLoading({ title: '准备下载' })
uni.downloadFile({
url: file.fileUrl,
success: (res) => {
if (res.statusCode === 200) {
uni.openDocument({
filePath: res.tempFilePath,
fileType: fileExt,
success: () => {
uni.hideLoading()
uni.showToast({ title: '打开成功', icon: 'success' })
},
fail: (err) => {
uni.hideLoading()
console.error('打开文件失败:', err)
uni.showToast({ title: '打开失败', icon: 'none' })
}
})
}
}, },
{ fail: (err) => {
id: 2, uni.hideLoading()
info_type: 1, console.error('下载失败:', err)
title: '参赛选手须知', uni.showToast({ title: '下载失败', icon: 'none' })
content: '请各位参赛选手提前1小时到达比赛场地进行检录携带身份证原件及复印件。比赛期间请遵守赛场纪律服从裁判判决。',
publishTime: '2025-01-09 14:30:00'
},
{
id: 3,
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'
} }
] })
// #endif
},
/**
* 获取文件类型
*/
getFileType(fileName) {
if (!fileName) return 'pdf'
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]
}, },
/** /**
@@ -190,7 +262,6 @@ export default {
}, },
handleItemClick(item) { handleItemClick(item) {
// 跳转到信息详情页
uni.navigateTo({ 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)}` 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)}`
}) })
@@ -206,6 +277,103 @@ export default {
padding: 20rpx 30rpx; 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;
}
.info-list { .info-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@@ -1,135 +1,127 @@
<template> <template>
<view class="event-lineup-page"> <view class="event-lineup-page">
<!-- 组别选择 --> <view v-if="loading" class="loading-container">
<view class="group-tabs"> <text>加载中...</text>
<view
class="group-tab"
v-for="(group, index) in groups"
:key="index"
:class="{ active: currentGroup === index }"
@click="currentGroup = index"
>
{{ group }}
</view>
</view> </view>
<!-- 出场顺序列表 --> <view v-else-if="!isScheduleCompleted" class="not-ready">
<view class="lineup-list"> <view class="not-ready-icon">📋</view>
<view class="lineup-item" v-for="(item, index) in currentLineup" :key="index"> <text class="not-ready-text">赛程编排尚未完成</text>
<view class="lineup-order"> <text class="not-ready-hint">请等待赛事组织方完成编排后查看</text>
<view class="order-number">{{ item.order }}</view> </view>
<text class="order-text"></text>
</view> <template v-else>
<view class="lineup-info"> <!-- 组别选择 -->
<view class="lineup-name">{{ item.name }}</view> <view class="group-tabs">
<view class="lineup-detail"> <view
<text class="detail-item">{{ item.team }}</text> class="group-tab"
<text class="divider">|</text> v-for="(group, index) in groups"
<text class="detail-item">{{ item.time }}</text> :key="index"
</view> :class="{ active: currentGroupIndex === index }"
</view> @click="currentGroupIndex = index"
<view class="lineup-status" :class="item.status"> >
{{ item.statusText }} {{ group.groupName }}
</view> </view>
</view> </view>
</view>
<!-- 出场顺序列表 -->
<view class="lineup-list" v-if="currentGroup">
<view class="group-header">
<text class="group-venue">{{ currentGroup.venueName }}</text>
<text class="group-time">{{ currentGroup.timeSlot }}</text>
<text class="group-table">表号: {{ currentGroup.tableNo }}</text>
</view>
<view class="lineup-item" v-for="(item, index) in currentGroup.participants" :key="index">
<view class="lineup-order">
<view class="order-number">{{ item.order }}</view>
<text class="order-text"></text>
</view>
<view class="lineup-info">
<view class="lineup-name">{{ item.playerName }}</view>
<view class="lineup-detail">
<text class="detail-item">{{ item.organization }}</text>
</view>
</view>
<view class="lineup-status" :class="item.status">
{{ getStatusText(item.status) }}
</view>
</view>
<view v-if="!currentGroup.participants || currentGroup.participants.length === 0" class="empty-list">
<text>暂无参赛者信息</text>
</view>
</view>
</template>
</view> </view>
</template> </template>
<script> <script>
import { getScheduleStatus, getLineup } from '@/api/schedule.js'
export default { export default {
data() { data() {
return { return {
currentGroup: 0, eventId: '',
groups: ['男子A组', '男子B组', '女子A组'], loading: true,
lineups: { isScheduleCompleted: false,
0: [ currentGroupIndex: 0,
{ groups: []
order: 1, }
name: '张三',
team: '北京队',
time: '09:00',
status: 'finished',
statusText: '已完成'
},
{
order: 2,
name: '李四',
team: '上海队',
time: '09:15',
status: 'finished',
statusText: '已完成'
},
{
order: 3,
name: '王五',
team: '广东队',
time: '09:30',
status: 'ongoing',
statusText: '进行中'
},
{
order: 4,
name: '赵六',
team: '天津队',
time: '09:45',
status: 'waiting',
statusText: '待出场'
},
{
order: 5,
name: '刘七',
team: '江苏队',
time: '10:00',
status: 'waiting',
statusText: '待出场'
}
],
1: [
{
order: 1,
name: '孙八',
team: '浙江队',
time: '10:30',
status: 'waiting',
statusText: '待出场'
},
{
order: 2,
name: '周九',
team: '湖北队',
time: '10:45',
status: 'waiting',
statusText: '待出场'
}
],
2: [
{
order: 1,
name: '小红',
team: '四川队',
time: '14:00',
status: 'waiting',
statusText: '待出场'
},
{
order: 2,
name: '小芳',
team: '河南队',
time: '14:15',
status: 'waiting',
statusText: '待出场'
}
]
}
};
}, },
computed: { computed: {
currentLineup() { currentGroup() {
return this.lineups[this.currentGroup] || []; return this.groups[this.currentGroupIndex] || null
}
},
onLoad(options) {
if (options.eventId) {
this.eventId = options.eventId
this.checkScheduleStatus()
}
},
methods: {
async checkScheduleStatus() {
try {
const res = await getScheduleStatus(this.eventId)
if (res.data) {
this.isScheduleCompleted = res.data.isCompleted
if (this.isScheduleCompleted) {
await this.loadLineup()
}
}
} catch (error) {
console.error('检查编排状态失败:', error)
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
this.loading = false
}
},
async loadLineup() {
try {
const res = await getLineup(this.eventId)
if (res.data && res.data.groups) {
this.groups = res.data.groups
}
} catch (error) {
console.error('加载出场顺序失败:', error)
}
},
getStatusText(status) {
const map = {
'waiting': '待出场',
'ongoing': '进行中',
'finished': '已完成'
}
return map[status] || '待出场'
} }
} }
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -138,6 +130,38 @@ export default {
background-color: #f5f5f5; background-color: #f5f5f5;
} }
.loading-container {
display: flex;
justify-content: center;
align-items: center;
height: 300rpx;
color: #666;
}
.not-ready {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 100rpx 40rpx;
}
.not-ready-icon {
font-size: 80rpx;
margin-bottom: 30rpx;
}
.not-ready-text {
font-size: 32rpx;
color: #333;
margin-bottom: 15rpx;
}
.not-ready-hint {
font-size: 26rpx;
color: #999;
}
.group-tabs { .group-tabs {
background-color: #fff; background-color: #fff;
display: flex; display: flex;
@@ -166,6 +190,21 @@ export default {
padding: 0 30rpx 20rpx; padding: 0 30rpx 20rpx;
} }
.group-header {
background-color: #fff;
border-radius: 16rpx;
padding: 20rpx 30rpx;
margin-bottom: 20rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
.group-venue, .group-time, .group-table {
font-size: 26rpx;
color: #666;
}
.lineup-item { .lineup-item {
background-color: #fff; background-color: #fff;
border-radius: 16rpx; border-radius: 16rpx;
@@ -216,10 +255,6 @@ export default {
color: #666666; color: #666666;
} }
.divider {
margin: 0 10rpx;
}
.lineup-status { .lineup-status {
padding: 8rpx 20rpx; padding: 8rpx 20rpx;
border-radius: 8rpx; border-radius: 8rpx;
@@ -241,4 +276,11 @@ export default {
background-color: #F5F5F5; background-color: #F5F5F5;
color: #999999; color: #999999;
} }
.empty-list {
text-align: center;
padding: 60rpx;
color: #999;
font-size: 28rpx;
}
</style> </style>

View File

@@ -134,22 +134,23 @@ export default {
const res = await athleteAPI.getAthleteList(params) const res = await athleteAPI.getAthleteList(params)
if (res.code === 200 && res.data) { console.log('=== 选手列表响应 ===', res)
const records = res.data.records || []
if (isLoadMore) { // request.js already extracts data.data, so res is the actual data
this.playersList = [...this.playersList, ...records] const records = res.records || res || []
} else {
this.playersList = records
this.page = 1
}
this.totalCount = res.data.total || 0 if (isLoadMore) {
this.hasMore = this.playersList.length < this.totalCount this.playersList = [...this.playersList, ...records]
} else {
// 统计已确认人数 this.playersList = Array.isArray(records) ? records : []
this.confirmedCount = this.playersList.filter(p => p.registrationStatus === 1).length this.page = 1
} }
this.totalCount = res.total || this.playersList.length
this.hasMore = this.playersList.length < this.totalCount
// 统计已确认人数
this.confirmedCount = this.playersList.filter(p => p.registrationStatus === 1).length
} catch (error) { } catch (error) {
console.error('加载选手列表失败:', error) console.error('加载选手列表失败:', error)
uni.showToast({ uni.showToast({

View File

@@ -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>
@@ -62,30 +98,30 @@
<view class="event-info-card"> <view class="event-info-card">
<view class="event-title">{{ eventInfo.title }}</view> <view class="event-title">{{ eventInfo.title }}</view>
<view class="divider"></view> <view class="divider"></view>
<view class="info-item"> <view class="info-item contact-item" @click="showContactPicker = true">
<text class="label">地点</text> <text class="label">地点</text>
<text class="value">{{ eventInfo.location }}</text> <text class="value">{{ eventInfo.location }}</text>
</view> </view>
<view class="info-item"> <view class="info-item contact-item" @click="showContactPicker = true">
<text class="label">比赛时间</text> <text class="label">比赛时间</text>
<text class="value">{{ eventInfo.matchTime }}</text> <text class="value">{{ eventInfo.matchTime }}</text>
</view> </view>
<view class="info-item"> <view class="info-item contact-item" @click="showContactPicker = true">
<text class="label">报名项目</text> <text class="label">报名项目</text>
<text class="value">{{ eventInfo.projects }}</text> <text class="value">{{ eventInfo.projects }}</text>
</view> </view>
<view class="info-item"> <view class="info-item contact-item" @click="showContactPicker = true">
<text class="label">联系人</text> <text class="label">联系人</text>
<text class="value">{{ eventInfo.contact }}</text> <text class="value" :class="{ placeholder: !selectedContact }">{{ selectedContact ? selectedContact.name + " " + selectedContact.phone : "请选择联系人" }}</text>
<text class="edit-icon">📋</text> <text class="arrow"></text>
</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>
@@ -115,31 +151,42 @@
<view class="event-info-card"> <view class="event-info-card">
<view class="event-title">{{ eventInfo.title }}</view> <view class="event-title">{{ eventInfo.title }}</view>
<view class="divider"></view> <view class="divider"></view>
<view class="info-item"> <view class="info-item contact-item" @click="showContactPicker = true">
<text class="label">地点</text> <text class="label">地点</text>
<text class="value">{{ eventInfo.location }}</text> <text class="value">{{ eventInfo.location }}</text>
</view> </view>
<view class="info-item"> <view class="info-item contact-item" @click="showContactPicker = true">
<text class="label">比赛时间</text> <text class="label">比赛时间</text>
<text class="value">{{ eventInfo.matchTime }}</text> <text class="value">{{ eventInfo.matchTime }}</text>
</view> </view>
<view class="info-item"> <view class="info-item contact-item" @click="showContactPicker = true">
<text class="label">报名项目</text> <text class="label">报名项目</text>
<text class="value">{{ eventInfo.projects }}</text> <text class="value">{{ eventInfo.projects }}</text>
</view> </view>
<view class="info-item"> <view class="info-item contact-item" @click="showContactPicker = true">
<text class="label">联系人</text> <text class="label">联系人</text>
<text class="value">{{ eventInfo.contact }}</text> <text class="value" :class="{ placeholder: !selectedContact }">{{ selectedContact ? selectedContact.name + " " + selectedContact.phone : "请选择联系人" }}</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">
@@ -164,6 +211,32 @@
</scroll-view> </scroll-view>
</view> </view>
</view> </view>
<!-- 联系人选择弹窗 -->
<view class="contact-modal" v-if="showContactPicker" @click="showContactPicker = false">
<view class="modal-content" @click.stop>
<view class="modal-header">
<text class="modal-title">选择联系人</text>
<text class="close-icon" @click="showContactPicker = false"></text>
</view>
<view class="add-contact-btn" @click="goToAddContact">
<text class="add-icon"></text>
<text>新增联系人</text>
</view>
<scroll-view class="modal-body contact-list" scroll-y>
<view class="contact-item" v-for="(item, index) in contactList" :key="index" @click="selectContact(item)">
<view class="contact-info">
<view class="contact-name">{{ item.name }}</view>
<view class="contact-phone">{{ item.phone }}</view>
</view>
<view class="contact-check" v-if="selectedContact && selectedContact.id === item.id"></view>
</view>
<view class="empty-state" v-if="contactList.length === 0">
<text class="empty-text">暂无联系人请先新增</text>
</view>
</scroll-view>
</view>
</view>
</view> </view>
</template> </template>
@@ -179,6 +252,7 @@ export default {
currentStep: 1, currentStep: 1,
eventId: '', eventId: '',
selectedProjects: [], selectedProjects: [],
isTeamProject: false,
eventInfo: { eventInfo: {
title: '', title: '',
location: '', location: '',
@@ -188,8 +262,13 @@ export default {
participants: '' participants: ''
}, },
playerList: [], playerList: [],
teamList: [],
selectedPlayers: [], selectedPlayers: [],
selectedTeams: [],
showPlayerModal: false, showPlayerModal: false,
showContactPicker: false,
contactList: [],
selectedContact: null,
totalPrice: 0, totalPrice: 0,
registrationId: '' registrationId: ''
}; };
@@ -198,11 +277,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 +289,78 @@ 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() {
// Refresh contact list when returning from add-contact page
this.loadContactList()
if (this.currentStep === 1) {
if (this.isTeamProject) {
this.loadTeamList()
} else {
this.loadPlayerList()
}
}
},
methods: { methods: {
/** // Contact methods
* 加载赛事详情 async loadContactList() {
*/ try {
const res = await athleteAPI.getContactList({ current: 1, size: 100 })
this.contactList = (res.records || []).map(item => ({
id: item.id,
name: item.name,
phone: item.phone,
idCard: item.idCard
}))
// Auto select default contact if exists
if (!this.selectedContact && this.contactList.length > 0) {
const defaultContact = this.contactList.find(c => c.isDefault) || this.contactList[0]
this.selectedContact = defaultContact
}
} catch (err) {
console.error('加载联系人列表失败:', err)
}
},
selectContact(contact) {
this.selectedContact = contact
this.showContactPicker = false
},
goToAddContact() {
this.showContactPicker = false
uni.navigateTo({
url: '/pages/add-contact/add-contact'
})
},
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 +377,6 @@ export default {
} }
} catch (err) { } catch (err) {
console.error('加载赛事详情失败:', err) console.error('加载赛事详情失败:', err)
// 设置默认值,防止页面显示空白
this.eventInfo = { this.eventInfo = {
title: '未命名赛事', title: '未命名赛事',
location: '待定', location: '待定',
@@ -282,111 +388,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 +499,147 @@ 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.loadContactList()
// 延迟切换步骤,确保数据更新完成 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: parseInt(this.eventId), if (selected.length === 0) {
projectIds: this.selectedProjects.map(p => parseInt(p.id)), uni.showToast({ title: '请选择参赛集体', icon: 'none' })
athleteIds: selected.map(p => parseInt(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.selectedContact ? this.selectedContact.phone : '',
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.selectedContact ? this.selectedContact.phone : '',
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;
@@ -998,4 +1078,92 @@ export default {
color: #C93639; color: #C93639;
margin-top: 10rpx; margin-top: 10rpx;
} }
/* Contact Modal Styles */
.contact-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: flex-end;
z-index: 1000;
}
.contact-modal .modal-content {
background-color: #fff;
border-radius: 24rpx 24rpx 0 0;
width: 100%;
max-height: 70vh;
}
.contact-modal .add-contact-btn {
display: flex;
align-items: center;
justify-content: center;
padding: 24rpx;
border-bottom: 1rpx solid #eee;
color: #C93639;
font-size: 28rpx;
}
.contact-modal .add-contact-btn .add-icon {
margin-right: 10rpx;
font-size: 32rpx;
}
.contact-modal .contact-list {
max-height: 50vh;
}
.contact-modal .contact-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 30rpx;
border-bottom: 1rpx solid #f5f5f5;
}
.contact-modal .contact-info {
flex: 1;
}
.contact-modal .contact-name {
font-size: 30rpx;
color: #333;
margin-bottom: 8rpx;
}
.contact-modal .contact-phone {
font-size: 26rpx;
color: #999;
}
.contact-modal .contact-check {
color: #C93639;
font-size: 36rpx;
font-weight: bold;
}
.contact-item.clickable,
.info-item.contact-item {
cursor: pointer;
}
.info-item .placeholder {
color: #999;
}
</style> </style>
.empty-state {
padding: 100rpx 0;
text-align: center;
}
.empty-text {
font-size: 28rpx;
color: #999999;
}

View File

@@ -71,40 +71,60 @@ export default {
data() { data() {
return { return {
eventId: '', eventId: '',
// 附件列表
attachments: [], attachments: [],
// 规程章节列表
rulesList: [] rulesList: []
}; };
}, },
onLoad(options) { onLoad(options) {
if (options.eventId) { if (options.eventId) {
this.eventId = options.eventId this.eventId = options.eventId
this.loadRulesData() this.loadAttachments(options.eventId)
this.loadRulesData(options.eventId)
} }
}, },
methods: { methods: {
/** /**
* 加载规程数据 * 加载附件列表
*/ */
async loadRulesData() { async loadAttachments(eventId) {
try { try {
// 调用API获取规程数据 const res = await competitionAPI.getAttachments({
const res = await competitionAPI.getCompetitionRules(this.eventId) competitionId: eventId,
type: 'rules'
})
// 处理附件数据 let list = []
if (res.attachments && res.attachments.length > 0) { if (res && Array.isArray(res)) {
this.attachments = res.attachments.map(file => ({ list = res
id: file.id, } else if (res && res.records) {
fileName: file.name || file.fileName, list = res.records
fileUrl: file.url || file.fileUrl, } else if (res && res.data && Array.isArray(res.data)) {
fileSize: this.formatFileSize(file.size || file.fileSize), list = res.data
fileType: this.getFileType(file.name || file.fileName)
}))
} }
if (list.length > 0) {
this.attachments = list.map(file => ({
id: file.id,
fileName: file.fileName || file.name,
fileUrl: file.fileUrl || file.url,
fileSize: this.formatFileSize(file.fileSize || file.size),
fileType: file.fileType || this.getFileType(file.fileName || file.name)
}))
}
} catch (err) {
console.error('加载附件失败:', err)
}
},
/**
* 加载规程数据
*/
async loadRulesData(eventId) {
try {
const res = await competitionAPI.getCompetitionRules(eventId)
// 处理规程内容数据 // 处理规程内容数据
if (res.chapters && res.chapters.length > 0) { if (res && res.chapters && res.chapters.length > 0) {
this.rulesList = res.chapters.map(chapter => ({ this.rulesList = res.chapters.map(chapter => ({
chapter: chapter.chapterNumber || chapter.number, chapter: chapter.chapterNumber || chapter.number,
title: chapter.title || chapter.name, title: chapter.title || chapter.name,
@@ -114,76 +134,9 @@ export default {
} }
} catch (err) { } catch (err) {
console.error('加载规程数据失败:', 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: '总则',
expanded: false,
contents: [
'1.1 本次比赛遵循国际武术联合会竞赛规则。',
'1.2 所有参赛选手必须持有效证件参赛。',
'1.3 参赛选手须服从裁判判决,不得有违规行为。'
]
},
{
chapter: '第二章',
title: '参赛资格',
expanded: false,
contents: [
'2.1 参赛选手年龄须在18-45周岁之间。',
'2.2 参赛选手须持有武术等级证书或相关证明。',
'2.3 参赛选手须通过健康检查,身体状况良好。'
]
},
{
chapter: '第三章',
title: '比赛规则',
expanded: false,
contents: [
'3.1 比赛采用单败淘汰制。',
'3.2 每场比赛时间为3分钟分3局进行。',
'3.3 得分规则按照国际标准执行。'
]
},
{
chapter: '第四章',
title: '奖项设置',
expanded: false,
contents: [
'4.1 各组别设金、银、铜牌各一枚。',
'4.2 设最佳表现奖、体育道德风尚奖等特别奖项。',
'4.3 所有参赛选手均可获得参赛证书。'
]
}
]
},
/** /**
* 切换章节展开/收起 * 切换章节展开/收起
*/ */
@@ -195,14 +148,12 @@ export default {
* 下载文件 * 下载文件
*/ */
downloadFile(file) { downloadFile(file) {
// 获取文件后缀
const fileExt = file.fileType || this.getFileType(file.fileName) || 'pdf' const fileExt = file.fileType || this.getFileType(file.fileName) || 'pdf'
// #ifdef H5 // #ifdef H5
// H5环境直接使用a标签下载确保文件名带后缀
const link = document.createElement('a') const link = document.createElement('a')
link.href = file.fileUrl link.href = file.fileUrl
link.download = file.fileName // 设置下载文件名(带后缀) link.download = file.fileName
link.target = '_blank' link.target = '_blank'
link.style.display = 'none' link.style.display = 'none'
document.body.appendChild(link) document.body.appendChild(link)
@@ -216,37 +167,22 @@ export default {
// #endif // #endif
// #ifndef H5 // #ifndef H5
// 非H5环境 uni.showLoading({ title: '准备下载' })
uni.showLoading({
title: '准备下载'
})
// 下载文件
uni.downloadFile({ uni.downloadFile({
url: file.fileUrl, url: file.fileUrl,
success: (res) => { success: (res) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
// 保存文件到本地
const filePath = res.tempFilePath
// 打开文档
uni.openDocument({ uni.openDocument({
filePath: filePath, filePath: res.tempFilePath,
fileType: fileExt, fileType: fileExt,
success: () => { success: () => {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({ title: '打开成功', icon: 'success' })
title: '打开成功',
icon: 'success'
})
}, },
fail: (err) => { fail: (err) => {
uni.hideLoading() uni.hideLoading()
console.error('打开文件失败:', err) console.error('打开文件失败:', err)
uni.showToast({ uni.showToast({ title: '打开失败', icon: 'none' })
title: '打开失败',
icon: 'none'
})
} }
}) })
} }
@@ -254,10 +190,7 @@ export default {
fail: (err) => { fail: (err) => {
uni.hideLoading() uni.hideLoading()
console.error('下载失败:', err) console.error('下载失败:', err)
uni.showToast({ uni.showToast({ title: '下载失败', icon: 'none' })
title: '下载失败',
icon: 'none'
})
} }
}) })
// #endif // #endif
@@ -267,6 +200,7 @@ export default {
* 获取文件类型 * 获取文件类型
*/ */
getFileType(fileName) { getFileType(fileName) {
if (!fileName) return 'pdf'
const ext = fileName.split('.').pop().toLowerCase() const ext = fileName.split('.').pop().toLowerCase()
return ext return ext
}, },

View File

@@ -1,7 +1,29 @@
<template> <template>
<view class="event-schedule-page"> <view class="event-schedule-page">
<!-- 附件下载区 -->
<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="date-tabs"> <view class="date-tabs" v-if="dates.length > 0">
<view <view
class="date-tab" class="date-tab"
v-for="(date, index) in dates" v-for="(date, index) in dates"
@@ -15,7 +37,7 @@
</view> </view>
<!-- 日程时间线 --> <!-- 日程时间线 -->
<view class="schedule-timeline"> <view class="schedule-timeline" v-if="currentSchedule.length > 0">
<view class="timeline-item" v-for="(item, index) in currentSchedule" :key="index"> <view class="timeline-item" v-for="(item, index) in currentSchedule" :key="index">
<view class="time-dot"></view> <view class="time-dot"></view>
<view class="time-line" v-if="index < currentSchedule.length - 1"></view> <view class="time-line" v-if="index < currentSchedule.length - 1"></view>
@@ -29,11 +51,18 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 空状态 -->
<view class="empty-state" v-if="attachments.length === 0 && dates.length === 0">
<text class="empty-icon">📅</text>
<text class="empty-text">暂无日程安排</text>
</view>
</view> </view>
</template> </template>
<script> <script>
import infoAPI from '@/api/info.js' import infoAPI from '@/api/info.js'
import competitionAPI from '@/api/competition.js'
export default { export default {
data() { data() {
@@ -41,7 +70,8 @@ export default {
eventId: '', eventId: '',
currentDate: 0, currentDate: 0,
dates: [], dates: [],
schedules: {} schedules: {},
attachments: []
}; };
}, },
computed: { computed: {
@@ -52,6 +82,7 @@ export default {
onLoad(options) { onLoad(options) {
if (options.eventId) { if (options.eventId) {
this.eventId = options.eventId this.eventId = options.eventId
this.loadAttachments(options.eventId)
this.loadScheduleDates(options.eventId) this.loadScheduleDates(options.eventId)
} }
}, },
@@ -63,6 +94,132 @@ export default {
} }
}, },
methods: { methods: {
/**
* 加载附件列表
*/
async loadAttachments(eventId) {
try {
const res = await competitionAPI.getAttachments({
competitionId: eventId,
type: 'schedule'
})
let list = []
if (res && Array.isArray(res)) {
list = res
} else if (res && res.records) {
list = res.records
} else if (res && res.data && Array.isArray(res.data)) {
list = res.data
}
if (list.length > 0) {
this.attachments = list.map(file => ({
id: file.id,
fileName: file.fileName || file.name,
fileUrl: file.fileUrl || file.url,
fileSize: this.formatFileSize(file.fileSize || file.size),
fileType: file.fileType || this.getFileType(file.fileName || file.name)
}))
}
} catch (err) {
console.error('加载附件失败:', err)
}
},
/**
* 下载文件
*/
downloadFile(file) {
const fileExt = file.fileType || this.getFileType(file.fileName) || 'pdf'
// #ifdef H5
const link = document.createElement('a')
link.href = file.fileUrl
link.download = file.fileName
link.target = '_blank'
link.style.display = 'none'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
uni.showToast({
title: '开始下载',
icon: 'success'
})
return
// #endif
// #ifndef H5
uni.showLoading({ title: '准备下载' })
uni.downloadFile({
url: file.fileUrl,
success: (res) => {
if (res.statusCode === 200) {
uni.openDocument({
filePath: res.tempFilePath,
fileType: fileExt,
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' })
}
})
// #endif
},
/**
* 获取文件类型
*/
getFileType(fileName) {
if (!fileName) return 'pdf'
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]
},
/** /**
* 加载日程日期列表 * 加载日程日期列表
*/ */
@@ -77,9 +234,8 @@ export default {
list = res list = res
} }
// 如果后端没有数据,使用模拟数据
if (list.length === 0) { if (list.length === 0) {
list = this.getMockScheduleData() return
} }
// 提取唯一日期 // 提取唯一日期
@@ -93,7 +249,7 @@ export default {
// 格式化日期选项卡并排序 // 格式化日期选项卡并排序
this.dates = Array.from(dateSet) this.dates = Array.from(dateSet)
.sort((a, b) => new Date(a) - new Date(b)) // 按日期升序排序 .sort((a, b) => new Date(a) - new Date(b))
.map(date => { .map(date => {
const d = new Date(date) const d = new Date(date)
const month = d.getMonth() + 1 const month = d.getMonth() + 1
@@ -119,7 +275,7 @@ export default {
this.schedules[dateIndex].push({ this.schedules[dateIndex].push({
time: this.formatTime(item.scheduleTime || item.schedule_time || item.time), time: this.formatTime(item.scheduleTime || item.schedule_time || item.time),
timeRaw: 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, title: item.eventName || item.event_name || item.title || item.activityName || item.scheduleName,
location: item.venue || item.location || '' location: item.venue || item.location || ''
}) })
@@ -141,59 +297,6 @@ export default {
} }
} catch (err) { } catch (err) {
console.error('加载日程日期失败:', 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)
})
})
} }
}, },
@@ -226,7 +329,6 @@ export default {
return timeA.localeCompare(timeB) return timeA.localeCompare(timeB)
}) })
// 触发视图更新
this.$forceUpdate() this.$forceUpdate()
} }
} catch (err) { } catch (err) {
@@ -240,17 +342,14 @@ export default {
formatTime(timeStr) { formatTime(timeStr) {
if (!timeStr) return '' if (!timeStr) return ''
// 如果已经是 HH:MM 格式
if (/^\d{2}:\d{2}$/.test(timeStr)) { if (/^\d{2}:\d{2}$/.test(timeStr)) {
return timeStr return timeStr
} }
// 如果是 HH:MM:SS 格式直接截取前5位
if (/^\d{2}:\d{2}:\d{2}$/.test(timeStr)) { if (/^\d{2}:\d{2}:\d{2}$/.test(timeStr)) {
return timeStr.substring(0, 5) return timeStr.substring(0, 5)
} }
// 尝试解析完整的日期时间字符串
const date = new Date(timeStr) const date = new Date(timeStr)
if (!isNaN(date.getTime())) { if (!isNaN(date.getTime())) {
const hours = String(date.getHours()).padStart(2, '0') const hours = String(date.getHours()).padStart(2, '0')
@@ -258,235 +357,7 @@ export default {
return `${hours}:${minutes}` return `${hours}:${minutes}`
} }
// 如果无法解析,返回原字符串
return timeStr 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
}
]
} }
} }
}; };
@@ -498,6 +369,104 @@ export default {
background-color: #f5f5f5; background-color: #f5f5f5;
} }
// 区块标题
.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 {
padding: 20rpx 30rpx;
margin-bottom: 10rpx;
}
.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;
}
.date-tabs { .date-tabs {
background-color: #fff; background-color: #fff;
display: flex; display: flex;
@@ -594,4 +563,24 @@ export default {
.location-icon { .location-icon {
font-size: 22rpx; font-size: 22rpx;
} }
// 空状态
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 200rpx 0;
gap: 20rpx;
}
.empty-icon {
font-size: 120rpx;
opacity: 0.3;
}
.empty-text {
font-size: 28rpx;
color: #999999;
}
</style> </style>

View File

@@ -138,7 +138,7 @@ export default {
matchTime: this.formatTimeRange(startTime, endTime) || matchTime: this.formatTimeRange(startTime, endTime) ||
item.matchTime || item.competitionTime || '待定', item.matchTime || item.competitionTime || '待定',
registerCount: item.registrationCount || item.registerCount || item.signUpCount || item.totalParticipants || '0', registerCount: item.registrationCount || item.registerCount || item.signUpCount || item.totalParticipants || '0',
status: this.getStatus(item.status) status: this.getStatus(item.status, regEndTime, endTime)
} }
}) })
@@ -174,12 +174,28 @@ export default {
* @param {Number|String} status 状态码 * @param {Number|String} status 状态码
* @returns {String} * @returns {String}
*/ */
getStatus(status) { getStatus(status, regEndTime, competitionEndTime) {
// 根据后端状态码映射为前端需要的状态 // 根据后端状态码映射为前端需要的状态
// 1: 报名中, 2: 进行中, 3: 已结束 // 1: 报名中, 2: 进行中, 3: 已结束
if (status === 3 || status === '3' || status === 'finished') { if (status === 3 || status === '3' || status === 'finished') {
return 'finished' return 'finished'
} }
// 根据比赛结束时间判断是否已结束
if (competitionEndTime) {
const compEndDate = new Date(competitionEndTime)
const now = new Date()
if (now > compEndDate) {
return 'finished'
}
}
// 根据报名结束时间判断是否已结束
if (regEndTime) {
const endDate = new Date(regEndTime)
const now = new Date()
if (now > endDate) {
return 'finished'
}
}
return 'open' return 'open'
}, },

View File

@@ -19,22 +19,22 @@
<view class="event-info"> <view class="event-info">
<text class="label">地点</text> <text class="label">地点</text>
<text class="value">{{ item.location }}</text> <text class="value location-text">{{ item.location || "暂无" }}</text>
</view> </view>
<view class="event-info"> <view class="event-info">
<text class="label">比赛时间</text> <text class="label">比赛时间</text>
<text class="value">{{ item.matchTime }}</text> <text class="value">{{ item.matchTime || "暂无" }}</text>
</view> </view>
<view class="event-info"> <view class="event-info">
<text class="label">报名项目</text> <text class="label">报名项目</text>
<text class="value">{{ item.projects }}</text> <text class="value">{{ item.projects || "暂无" }}</text>
</view> </view>
<view class="event-info"> <view class="event-info">
<text class="label">联系人</text> <text class="label">联系人</text>
<text class="value">{{ item.contact }}</text> <text class="value">{{ item.contact || "暂无" }}</text>
</view> </view>
<view class="event-info"> <view class="event-info">
@@ -42,8 +42,8 @@
<text class="value participants">{{ item.participants }}</text> <text class="value participants">{{ item.participants }}</text>
</view> </view>
<view class="event-footer" v-if="item.status === 'ongoing'"> <view class="event-footer">
<view class="register-note"> <view class="register-note" v-if="item.status === 'ongoing'">
<text>点击后进入赛事详情页面</text> <text>点击后进入赛事详情页面</text>
</view> </view>
<view class="view-cert-btn" @click.stop="handleViewCert(item)"> <view class="view-cert-btn" @click.stop="handleViewCert(item)">
@@ -58,6 +58,26 @@
<view class="empty-state" v-if="filteredList.length === 0"> <view class="empty-state" v-if="filteredList.length === 0">
<text class="empty-text">暂无报名记录</text> <text class="empty-text">暂无报名记录</text>
</view> </view>
<!-- 证件弹窗 -->
<view class="cert-modal" v-if="showCertModal" @click="closeCertModal">
<view class="cert-modal-content" @click.stop>
<view class="cert-modal-header">
<text class="cert-modal-title">参赛选手证件</text>
<text class="cert-close-icon" @click="closeCertModal"></text>
</view>
<scroll-view class="cert-modal-body" scroll-y>
<view class="cert-athlete-item" v-for="(athlete, index) in certAthleteList" :key="index">
<view class="cert-athlete-name">{{ athlete.playerName }}</view>
<view class="cert-athlete-info">性别{{ athlete.gender === 1 ? '男' : '女' }}</view>
<view class="cert-athlete-info">身份证{{ athlete.idCard || '暂无' }}</view>
</view>
<view class="cert-empty" v-if="certAthleteList.length === 0">
<text>暂无选手信息</text>
</view>
</scroll-view>
</view>
</view>
</view> </view>
</template> </template>
@@ -80,7 +100,9 @@ export default {
current: 1, current: 1,
size: 20 size: 20
}, },
hasMore: true hasMore: true,
showCertModal: false,
certAthleteList: []
}; };
}, },
onLoad() { onLoad() {
@@ -235,7 +257,8 @@ export default {
) || '', ) || '',
projects: item.projectNames || this.formatProjects(item.projects) || '', projects: item.projectNames || this.formatProjects(item.projects) || '',
contact: item.contactPhone || item.contactPerson || '', contact: item.contactPhone || item.contactPerson || '',
participants: item.athleteNames || `${item.totalParticipants || 0}` participants: item.athleteNames || `${item.totalParticipants || 0}`,
athleteList: item.athleteList || []
} }
}, },
@@ -318,14 +341,24 @@ export default {
}, },
goToEventDetail(item) { goToEventDetail(item) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/event-detail/event-detail?id=' + item.id url: '/pages/event-detail/event-detail?id=' + item.competitionId
}); });
}, },
handleViewCert(item) { handleViewCert(item) {
uni.showToast({ // Get athlete list from the item
title: '查看证件', if (item.athleteList && item.athleteList.length > 0) {
icon: 'none' this.certAthleteList = item.athleteList;
}); this.showCertModal = true;
} else {
uni.showToast({
title: '暂无选手证件信息',
icon: 'none'
});
}
},
closeCertModal() {
this.showCertModal = false;
this.certAthleteList = [];
} }
} }
}; };
@@ -396,6 +429,14 @@ export default {
flex: 1; flex: 1;
} }
.location-text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: block;
max-width: 480rpx;
}
.participants { .participants {
word-break: break-all; word-break: break-all;
} }
@@ -438,4 +479,77 @@ export default {
font-size: 28rpx; font-size: 28rpx;
color: #999999; color: #999999;
} }
/* Cert Modal Styles */
.cert-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.cert-modal-content {
background-color: #fff;
border-radius: 16rpx;
width: 85%;
max-height: 70vh;
overflow: hidden;
}
.cert-modal-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #eee;
}
.cert-modal-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
}
.cert-close-icon {
font-size: 36rpx;
color: #999;
cursor: pointer;
}
.cert-modal-body {
max-height: 50vh;
padding: 20rpx 30rpx;
}
.cert-athlete-item {
padding: 20rpx;
background-color: #f9f9f9;
border-radius: 12rpx;
margin-bottom: 20rpx;
}
.cert-athlete-name {
font-size: 30rpx;
font-weight: bold;
color: #333;
margin-bottom: 10rpx;
}
.cert-athlete-info {
font-size: 26rpx;
color: #666;
margin-bottom: 6rpx;
}
.cert-empty {
text-align: center;
padding: 40rpx;
color: #999;
}
</style> </style>

View File

@@ -39,19 +39,27 @@ export default {
onLoad(options) { onLoad(options) {
if (options.eventId) { if (options.eventId) {
this.eventId = options.eventId; this.eventId = options.eventId;
this.loadProjectList(options.eventId)
} }
if (options.type) { if (options.type) {
this.type = options.type; this.type = options.type;
} }
if (this.eventId) {
this.loadProjectList(this.eventId)
}
}, },
methods: { methods: {
/**
* 加载报名项目列表
*/
async loadProjectList(eventId) { async loadProjectList(eventId) {
try { try {
const res = await competitionAPI.getProjectList({ competitionId: eventId }) const params = { competitionId: eventId }
// Filter by participation type: single=1, team=2
if (this.type === 'single') {
params.type = 1
} else if (this.type === 'team') {
params.type = 2
}
const res = await competitionAPI.getProjectList(params)
let list = [] let list = []
if (res.records) { if (res.records) {
@@ -60,11 +68,11 @@ export default {
list = res list = res
} }
// 数据映射
this.projectList = list.map(item => ({ this.projectList = list.map(item => ({
id: item.id, id: item.id,
name: item.name || item.projectName, name: item.name || item.projectName,
price: item.price || item.registrationFee || 0, price: item.price || item.registrationFee || 0,
type: item.type || (this.type === 'team' ? 2 : 1),
selected: false selected: false
})) }))
} catch (err) { } catch (err) {
@@ -80,6 +88,7 @@ export default {
item.selected = !item.selected; item.selected = !item.selected;
this.$forceUpdate(); this.$forceUpdate();
}, },
handleRegister() { handleRegister() {
const selectedProjects = this.projectList.filter(item => item.selected); const selectedProjects = this.projectList.filter(item => item.selected);
if (selectedProjects.length === 0) { if (selectedProjects.length === 0) {
@@ -90,8 +99,16 @@ export default {
return; return;
} }
// Include type in selected projects data
const projectsData = selectedProjects.map(p => ({
id: p.id,
name: p.name,
price: p.price,
type: p.type
}))
uni.navigateTo({ uni.navigateTo({
url: `/pages/event-register/event-register?eventId=${this.eventId}&projects=${encodeURIComponent(JSON.stringify(selectedProjects))}` url: `/pages/event-register/event-register?eventId=${this.eventId}&projects=${encodeURIComponent(JSON.stringify(projectsData))}`
}); });
} }
} }