feat: 完成5个页面接入dataAdapter - Mock模式功能完成
改造页面列表: - login.vue: 登录验证使用dataAdapter - score-list.vue: 普通评委选手列表加载 - score-detail.vue: 评分提交和扣分项加载 - score-list-multi.vue: 裁判长多场地列表(含场地/项目切换) - modify-score.vue: 裁判长修改评分 关键特性: - ✅ 所有页面使用dataAdapter统一数据接口 - ✅ UI模板和样式完全保持不变(零UI修改) - ✅ 支持Mock/API模式一键切换 - ✅ 完整的错误处理和加载提示 - ✅ 调试模式下输出详细日志 Mock模式测试准备完成,可通过修改config/env.config.js中dataMode切换到API模式。 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import dataAdapter from '@/utils/dataAdapter.js'
|
||||
import config from '@/config/env.config.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -53,8 +56,19 @@ export default {
|
||||
inviteCode: ''
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// 开发环境显示当前数据模式
|
||||
if (config.debug) {
|
||||
console.log('='.repeat(50))
|
||||
console.log('当前数据模式:', config.dataMode)
|
||||
console.log('Mock模式:', dataAdapter.isMockMode() ? '是' : '否')
|
||||
console.log('API模式:', dataAdapter.isApiMode() ? '是' : '否')
|
||||
console.log('='.repeat(50))
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSubmit() {
|
||||
async handleSubmit() {
|
||||
// 表单验证
|
||||
if (!this.matchCode) {
|
||||
uni.showToast({
|
||||
title: '请输入比赛编码',
|
||||
@@ -70,26 +84,75 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
// 判断权限类型
|
||||
const role = this.inviteCode.toLowerCase()
|
||||
|
||||
if (role !== 'pub' && role !== 'admin') {
|
||||
uni.showToast({
|
||||
title: '邀请码错误,请输入pub或admin',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
try {
|
||||
// 显示加载
|
||||
uni.showLoading({
|
||||
title: '登录中...',
|
||||
mask: true
|
||||
})
|
||||
return
|
||||
|
||||
// 🔥 关键改动:使用 dataAdapter 进行登录
|
||||
// Mock模式:调用 mock/login.js 的 login 函数
|
||||
// API模式:调用 api/auth.js 的 login 函数(POST /api/mini/login)
|
||||
const response = await dataAdapter.getData('login', {
|
||||
matchCode: this.matchCode,
|
||||
inviteCode: this.inviteCode
|
||||
})
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 处理登录响应(Mock和API返回格式相同)
|
||||
const {
|
||||
token,
|
||||
userRole,
|
||||
matchId,
|
||||
matchName,
|
||||
matchTime,
|
||||
judgeId,
|
||||
judgeName,
|
||||
venueId,
|
||||
venueName,
|
||||
projects
|
||||
} = response.data
|
||||
|
||||
// 保存Token到本地存储
|
||||
uni.setStorageSync('token', token)
|
||||
|
||||
// 保存用户信息到全局数据
|
||||
getApp().globalData = {
|
||||
userRole, // 'pub' 或 'admin'
|
||||
matchCode: this.matchCode,
|
||||
matchId,
|
||||
matchName,
|
||||
matchTime,
|
||||
judgeId,
|
||||
judgeName,
|
||||
venueId, // 普通评委有场地,裁判长为null
|
||||
venueName,
|
||||
projects, // 分配的项目列表
|
||||
currentProjectIndex: 0 // 当前选中的项目索引
|
||||
}
|
||||
|
||||
// 保存用户角色到全局数据
|
||||
getApp().globalData = {
|
||||
userRole: role,
|
||||
matchCode: this.matchCode
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('登录成功:', {
|
||||
userRole,
|
||||
judgeName,
|
||||
venueId: venueId || '全部场地',
|
||||
projects: projects.length + '个项目'
|
||||
})
|
||||
}
|
||||
|
||||
// 显示登录成功提示
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
// 根据角色跳转到不同页面
|
||||
if (role === 'admin') {
|
||||
setTimeout(() => {
|
||||
if (userRole === 'admin') {
|
||||
// 裁判长跳转到多场地列表页(可以修改评分)
|
||||
uni.navigateTo({
|
||||
url: '/pages/score-list-multi/score-list-multi'
|
||||
@@ -100,6 +163,20 @@ export default {
|
||||
url: '/pages/score-list/score-list'
|
||||
})
|
||||
}
|
||||
}, 1500)
|
||||
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
|
||||
// 错误处理
|
||||
console.error('登录失败:', error)
|
||||
|
||||
uni.showToast({
|
||||
title: error.message || '登录失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,46 +15,30 @@
|
||||
<!-- 选手信息 -->
|
||||
<view class="player-info-section">
|
||||
<view class="player-header">
|
||||
<view class="player-name">张三</view>
|
||||
<view class="player-name">{{ athleteInfo.name }}</view>
|
||||
<view class="total-score-label">
|
||||
<text class="label-text">总分:</text>
|
||||
<text class="score-value">8.907</text>
|
||||
<text class="score-value">{{ athleteInfo.totalScore }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="player-details">
|
||||
<view class="detail-item">身份证:123456789000000000</view>
|
||||
<view class="detail-item">队伍:少林寺武术大学院</view>
|
||||
<view class="detail-item">编号:123-4567898275</view>
|
||||
<view class="detail-item">身份证:{{ athleteInfo.idCard }}</view>
|
||||
<view class="detail-item">队伍:{{ athleteInfo.team }}</view>
|
||||
<view class="detail-item">编号:{{ athleteInfo.number }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 评委评分统计 -->
|
||||
<view class="judges-section">
|
||||
<view class="section-title">共有6位评委完成评分</view>
|
||||
<view class="section-title">共有{{ judgeScores.length }}位评委完成评分</view>
|
||||
<view class="judges-scores">
|
||||
<view class="judge-score-item">
|
||||
<text class="judge-name">欧阳丽娜:</text>
|
||||
<text class="judge-score">8.907</text>
|
||||
</view>
|
||||
<view class="judge-score-item">
|
||||
<text class="judge-name">张三:</text>
|
||||
<text class="judge-score">8.901</text>
|
||||
</view>
|
||||
<view class="judge-score-item">
|
||||
<text class="judge-name">裁判姓名:</text>
|
||||
<text class="judge-score">8.902</text>
|
||||
</view>
|
||||
<view class="judge-score-item">
|
||||
<text class="judge-name">裁判姓名:</text>
|
||||
<text class="judge-score">8.907</text>
|
||||
</view>
|
||||
<view class="judge-score-item">
|
||||
<text class="judge-name">裁判姓名:</text>
|
||||
<text class="judge-score">8.905</text>
|
||||
</view>
|
||||
<view class="judge-score-item">
|
||||
<text class="judge-name">裁判姓名:</text>
|
||||
<text class="judge-score">8.904</text>
|
||||
<view
|
||||
class="judge-score-item"
|
||||
v-for="judge in judgeScores"
|
||||
:key="judge.judgeId"
|
||||
>
|
||||
<text class="judge-name">{{ judge.judgeName }}:</text>
|
||||
<text class="judge-score">{{ judge.score }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -109,37 +93,194 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import dataAdapter from '@/utils/dataAdapter.js'
|
||||
import config from '@/config/env.config.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
currentScore: 8.907,
|
||||
athleteInfo: {
|
||||
athleteId: '',
|
||||
name: '',
|
||||
idCard: '',
|
||||
team: '',
|
||||
number: '',
|
||||
totalScore: 0
|
||||
},
|
||||
judgeScores: [],
|
||||
modification: null,
|
||||
modifierId: '',
|
||||
currentScore: 8.000,
|
||||
originalScore: 8.000,
|
||||
note: '',
|
||||
minScore: 5.0,
|
||||
maxScore: 10.0
|
||||
}
|
||||
},
|
||||
|
||||
async onLoad() {
|
||||
// 获取全局数据
|
||||
const app = getApp()
|
||||
const globalData = app.globalData || {}
|
||||
|
||||
// 获取当前选手信息(从 score-list-multi 页面传递)
|
||||
const currentAthlete = globalData.currentAthlete || {}
|
||||
|
||||
// 获取裁判长ID
|
||||
this.modifierId = globalData.judgeId
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('修改评分页加载:', {
|
||||
athleteId: currentAthlete.athleteId,
|
||||
modifierId: this.modifierId
|
||||
})
|
||||
}
|
||||
|
||||
// 加载选手评分详情
|
||||
if (currentAthlete.athleteId) {
|
||||
await this.loadScoreDetail(currentAthlete.athleteId)
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async loadScoreDetail(athleteId) {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
// 🔥 关键改动:使用 dataAdapter 获取评分详情
|
||||
// Mock模式:调用 mock/score.js 的 getScoreDetail 函数
|
||||
// API模式:调用 api/score.js 的 getScoreDetail 函数(GET /api/mini/score/detail/{athleteId})
|
||||
const response = await dataAdapter.getData('getScoreDetail', {
|
||||
athleteId: athleteId
|
||||
})
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 保存选手信息和评分详情
|
||||
this.athleteInfo = response.data.athleteInfo || {}
|
||||
this.judgeScores = response.data.judgeScores || []
|
||||
this.modification = response.data.modification || null
|
||||
|
||||
// 设置初始分数
|
||||
this.originalScore = this.athleteInfo.totalScore || 8.000
|
||||
this.currentScore = this.originalScore
|
||||
|
||||
// 如果之前已修改过,加载修改后的分数
|
||||
if (this.modification && this.modification.modifiedScore) {
|
||||
this.currentScore = this.modification.modifiedScore
|
||||
}
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('评分详情加载成功:', {
|
||||
athlete: this.athleteInfo,
|
||||
judges: this.judgeScores.length,
|
||||
originalScore: this.originalScore,
|
||||
currentScore: this.currentScore,
|
||||
modification: this.modification
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('加载评分详情失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
},
|
||||
|
||||
decreaseScore() {
|
||||
if (this.currentScore > this.minScore) {
|
||||
this.currentScore = parseFloat((this.currentScore - 0.001).toFixed(3))
|
||||
}
|
||||
},
|
||||
|
||||
increaseScore() {
|
||||
if (this.currentScore < this.maxScore) {
|
||||
this.currentScore = parseFloat((this.currentScore + 0.001).toFixed(3))
|
||||
}
|
||||
},
|
||||
handleModify() {
|
||||
|
||||
async handleModify() {
|
||||
// 验证评分范围
|
||||
if (this.currentScore < this.minScore || this.currentScore > this.maxScore) {
|
||||
uni.showToast({
|
||||
title: `评分必须在${this.minScore}-${this.maxScore}分之间`,
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否有修改
|
||||
if (this.currentScore === this.originalScore && !this.note) {
|
||||
uni.showToast({
|
||||
title: '请修改分数或填写备注',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '提交中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
// 🔥 关键改动:使用 dataAdapter 修改评分
|
||||
// Mock模式:调用 mock/score.js 的 modifyScore 函数
|
||||
// API模式:调用 api/score.js 的 modifyScore 函数(PUT /api/mini/score/modify)
|
||||
const response = await dataAdapter.getData('modifyScore', {
|
||||
athleteId: this.athleteInfo.athleteId,
|
||||
modifierId: this.modifierId,
|
||||
modifiedScore: this.currentScore,
|
||||
note: this.note
|
||||
})
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('修改评分成功:', {
|
||||
athleteId: this.athleteInfo.athleteId,
|
||||
originalScore: this.originalScore,
|
||||
modifiedScore: this.currentScore,
|
||||
note: this.note,
|
||||
response: response
|
||||
})
|
||||
}
|
||||
|
||||
// 显示成功提示
|
||||
uni.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'success'
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
// 返回上一页
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('修改评分失败:', error)
|
||||
|
||||
uni.showToast({
|
||||
title: error.message || '修改失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
|
||||
<!-- 选手信息 -->
|
||||
<view class="player-info-section">
|
||||
<view class="player-name">张三</view>
|
||||
<view class="player-name">{{ player.name }}</view>
|
||||
<view class="player-details">
|
||||
<view class="detail-item">身份证:123456789000000000</view>
|
||||
<view class="detail-item">队伍:少林寺武术大学院</view>
|
||||
<view class="detail-item">编号:123-4567898275</view>
|
||||
<view class="detail-item">身份证:{{ player.idCard }}</view>
|
||||
<view class="detail-item">队伍:{{ player.team }}</view>
|
||||
<view class="detail-item">编号:{{ player.number }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -58,14 +58,14 @@
|
||||
<view class="deduction-list">
|
||||
<view
|
||||
v-for="(item, index) in deductions"
|
||||
:key="index"
|
||||
:key="item.deductionId"
|
||||
class="deduction-item"
|
||||
@click="toggleDeduction(index)"
|
||||
>
|
||||
<view :class="['checkbox', item.checked ? 'checked' : '']">
|
||||
<text v-if="item.checked" class="check-icon">✓</text>
|
||||
</view>
|
||||
<text class="deduction-text">{{ item.text }}</text>
|
||||
<text class="deduction-text">{{ item.deductionName }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -92,50 +92,190 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import dataAdapter from '@/utils/dataAdapter.js'
|
||||
import config from '@/config/env.config.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
currentScore: 8.907,
|
||||
player: {
|
||||
athleteId: '',
|
||||
name: '',
|
||||
idCard: '',
|
||||
team: '',
|
||||
number: ''
|
||||
},
|
||||
judgeId: '',
|
||||
projectId: '',
|
||||
currentScore: 8.000,
|
||||
note: '',
|
||||
minScore: 5.0,
|
||||
maxScore: 10.0,
|
||||
deductions: [
|
||||
{ text: '扣分项描述', checked: false },
|
||||
{ text: '扣分项描述', checked: false },
|
||||
{ text: '扣分项描述', checked: true },
|
||||
{ text: '扣分项描述', checked: false },
|
||||
{ text: '扣分项描述', checked: false },
|
||||
{ text: '扣分项描述', checked: true },
|
||||
{ text: '扣分项描述', checked: true },
|
||||
{ text: '扣分项描述', checked: false }
|
||||
]
|
||||
deductions: []
|
||||
}
|
||||
},
|
||||
|
||||
async onLoad() {
|
||||
// 获取全局数据
|
||||
const app = getApp()
|
||||
const globalData = app.globalData || {}
|
||||
|
||||
// 加载当前选手信息(从 score-list 页面传递)
|
||||
const currentAthlete = globalData.currentAthlete || {}
|
||||
this.player = {
|
||||
athleteId: currentAthlete.athleteId || '',
|
||||
name: currentAthlete.name || '选手姓名',
|
||||
idCard: currentAthlete.idCard || '',
|
||||
team: currentAthlete.team || '',
|
||||
number: currentAthlete.number || ''
|
||||
}
|
||||
|
||||
// 如果选手已评分,加载其原有评分
|
||||
if (currentAthlete.scored && currentAthlete.myScore) {
|
||||
this.currentScore = currentAthlete.myScore
|
||||
}
|
||||
|
||||
// 加载评委ID和项目ID
|
||||
this.judgeId = globalData.judgeId
|
||||
const projects = globalData.projects || []
|
||||
const currentIndex = globalData.currentProjectIndex || 0
|
||||
const currentProject = projects[currentIndex] || {}
|
||||
this.projectId = currentProject.projectId
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('评分详情页加载:', {
|
||||
athlete: this.player,
|
||||
judgeId: this.judgeId,
|
||||
projectId: this.projectId,
|
||||
initialScore: this.currentScore
|
||||
})
|
||||
}
|
||||
|
||||
// 加载扣分项列表
|
||||
await this.loadDeductions()
|
||||
},
|
||||
|
||||
methods: {
|
||||
async loadDeductions() {
|
||||
try {
|
||||
// 🔥 关键改动:使用 dataAdapter 获取扣分项列表
|
||||
// Mock模式:调用 mock/score.js 的 getDeductions 函数
|
||||
// API模式:调用 api/score.js 的 getDeductions 函数(GET /martial/deductionItem/list)
|
||||
const response = await dataAdapter.getData('getDeductions', {
|
||||
projectId: this.projectId
|
||||
})
|
||||
|
||||
// 为每个扣分项添加 checked 状态
|
||||
this.deductions = (response.data || []).map(item => ({
|
||||
...item,
|
||||
checked: false
|
||||
}))
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('扣分项加载成功:', this.deductions)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('加载扣分项失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载扣分项失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
},
|
||||
|
||||
decreaseScore() {
|
||||
if (this.currentScore > this.minScore) {
|
||||
this.currentScore = parseFloat((this.currentScore - 0.001).toFixed(3))
|
||||
}
|
||||
},
|
||||
|
||||
increaseScore() {
|
||||
if (this.currentScore < this.maxScore) {
|
||||
this.currentScore = parseFloat((this.currentScore + 0.001).toFixed(3))
|
||||
}
|
||||
},
|
||||
|
||||
toggleDeduction(index) {
|
||||
this.deductions[index].checked = !this.deductions[index].checked
|
||||
},
|
||||
handleSubmit() {
|
||||
|
||||
async handleSubmit() {
|
||||
// 验证评分范围
|
||||
if (this.currentScore < this.minScore || this.currentScore > this.maxScore) {
|
||||
uni.showToast({
|
||||
title: `评分必须在${this.minScore}-${this.maxScore}分之间`,
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 收集选中的扣分项
|
||||
const selectedDeductions = this.deductions
|
||||
.filter(item => item.checked)
|
||||
.map(item => ({
|
||||
deductionId: item.deductionId,
|
||||
deductionName: item.deductionName,
|
||||
deductionScore: item.deductionScore
|
||||
}))
|
||||
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '提交中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
// 🔥 关键改动:使用 dataAdapter 提交评分
|
||||
// Mock模式:调用 mock/score.js 的 submitScore 函数
|
||||
// API模式:调用 api/score.js 的 submitScore 函数(POST /martial/score/submit)
|
||||
const response = await dataAdapter.getData('submitScore', {
|
||||
athleteId: this.player.athleteId,
|
||||
judgeId: this.judgeId,
|
||||
score: this.currentScore,
|
||||
deductions: selectedDeductions,
|
||||
note: this.note
|
||||
})
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('评分提交成功:', {
|
||||
athleteId: this.player.athleteId,
|
||||
score: this.currentScore,
|
||||
deductions: selectedDeductions,
|
||||
response: response
|
||||
})
|
||||
}
|
||||
|
||||
// 显示成功提示
|
||||
uni.showToast({
|
||||
title: '提交成功',
|
||||
icon: 'success'
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
// 返回上一页
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('提交评分失败:', error)
|
||||
|
||||
uni.showToast({
|
||||
title: error.message || '提交失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
|
||||
<!-- 比赛信息 -->
|
||||
<view class="match-info">
|
||||
<view class="match-title">
|
||||
2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛
|
||||
</view>
|
||||
<view class="match-time">比赛时间:2025年6月25日 9:00</view>
|
||||
<view class="match-title">{{ matchInfo.name }}</view>
|
||||
<view class="match-time">比赛时间:{{ matchInfo.time }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 场地和项目选择 -->
|
||||
@@ -24,11 +22,11 @@
|
||||
<view class="venue-tabs">
|
||||
<view
|
||||
v-for="venue in venues"
|
||||
:key="venue.id"
|
||||
:class="['venue-tab', currentVenue === venue.id ? 'active' : '']"
|
||||
@click="switchVenue(venue.id)"
|
||||
:key="venue.venueId"
|
||||
:class="['venue-tab', currentVenue === venue.venueId ? 'active' : '']"
|
||||
@click="switchVenue(venue.venueId)"
|
||||
>
|
||||
{{ venue.name }}
|
||||
{{ venue.venueName }}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -43,11 +41,11 @@
|
||||
<view class="project-list">
|
||||
<view
|
||||
v-for="(project, index) in projects"
|
||||
:key="index"
|
||||
:class="['project-btn', currentProject === index ? 'active' : '']"
|
||||
@click="switchProject(index)"
|
||||
:key="project.projectId"
|
||||
:class="['project-btn', currentProject === project.projectId ? 'active' : '']"
|
||||
@click="switchProject(project.projectId)"
|
||||
>
|
||||
{{ project }}
|
||||
{{ project.projectName }}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -56,49 +54,34 @@
|
||||
<!-- 已评分统计 -->
|
||||
<view class="score-stats">
|
||||
<text class="stats-text">已评分:</text>
|
||||
<text class="stats-number">2/30</text>
|
||||
<text class="stats-number">{{ scoredCount }}/{{ totalCount }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 选手列表 -->
|
||||
<view class="player-list">
|
||||
<!-- 第一个选手 - 裁判长功能 -->
|
||||
<view class="player-card">
|
||||
<!-- 遍历选手列表 -->
|
||||
<view
|
||||
class="player-card"
|
||||
v-for="player in players"
|
||||
:key="player.athleteId"
|
||||
>
|
||||
<view class="player-header">
|
||||
<view class="player-name">张三</view>
|
||||
<view class="action-area">
|
||||
<text class="total-score">总分:8.907</text>
|
||||
<view class="player-name">{{ player.name }}</view>
|
||||
|
||||
<!-- 已评分:显示总分和修改按钮 -->
|
||||
<view class="action-area" v-if="player.totalScore">
|
||||
<text class="total-score">总分:{{ player.totalScore }}</text>
|
||||
<view class="chief-actions">
|
||||
<!-- <text class="chief-hint">裁判长功能:修改评分、修改按钮需等总分出来才出现</text> -->
|
||||
<button class="modify-btn" @click="goToModify">修改</button>
|
||||
<button class="modify-btn" @click="goToModify(player)">修改</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="player-info">
|
||||
<view class="info-item">身份证:123456789000000000</view>
|
||||
<view class="info-item">队伍:少林寺武术大学院</view>
|
||||
<view class="info-item">编号:123-4567898275</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 第二个选手 - 简单样式 -->
|
||||
<view class="player-card">
|
||||
<view class="player-header">
|
||||
<view class="player-name">张三</view>
|
||||
</view>
|
||||
<view class="player-info">
|
||||
<view class="info-item">身份证:123456789000000000</view>
|
||||
<view class="info-item">队伍:少林寺武术大学院</view>
|
||||
<view class="info-item">编号:123-4567898275</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 第三个选手 - 简单样式 -->
|
||||
<view class="player-card">
|
||||
<view class="player-header">
|
||||
<view class="player-name">张三</view>
|
||||
</view>
|
||||
<view class="player-info">
|
||||
<view class="info-item">身份证:123456789000000000</view>
|
||||
<view class="info-item">身份证:{{ player.idCard }}</view>
|
||||
<view class="info-item">队伍:{{ player.team }}</view>
|
||||
<view class="info-item">编号:{{ player.number }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -106,38 +89,194 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import dataAdapter from '@/utils/dataAdapter.js'
|
||||
import config from '@/config/env.config.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
currentVenue: 1,
|
||||
currentProject: 0,
|
||||
venues: [
|
||||
{ id: 1, name: '第一场地' },
|
||||
{ id: 2, name: '第二场地' },
|
||||
{ id: 3, name: '第三场地' },
|
||||
{ id: 4, name: '第四场地' },
|
||||
{ id: 5, name: '第五场地' }
|
||||
],
|
||||
projects: [
|
||||
'女子组长拳',
|
||||
'男子组陈氏太极拳',
|
||||
'女子组双剑(含长穗双剑)',
|
||||
'男子组杨氏太极拳',
|
||||
'女子组刀术',
|
||||
'男子组棍术',
|
||||
'女子组枪术',
|
||||
'男子组剑术'
|
||||
]
|
||||
matchInfo: {
|
||||
id: '',
|
||||
name: '',
|
||||
time: ''
|
||||
},
|
||||
competitionId: '',
|
||||
currentVenue: '',
|
||||
currentProject: '',
|
||||
venues: [],
|
||||
projects: [],
|
||||
players: [],
|
||||
scoredCount: 0,
|
||||
totalCount: 0
|
||||
}
|
||||
},
|
||||
|
||||
async onLoad() {
|
||||
// 获取全局数据
|
||||
const app = getApp()
|
||||
const globalData = app.globalData || {}
|
||||
|
||||
// 加载比赛信息
|
||||
this.matchInfo = {
|
||||
id: globalData.matchId,
|
||||
name: globalData.matchName || '比赛名称',
|
||||
time: globalData.matchTime || '比赛时间'
|
||||
}
|
||||
|
||||
// 注意:裁判长没有固定场地和项目,需要查看所有
|
||||
this.competitionId = globalData.matchId
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('裁判长列表页加载:', {
|
||||
userRole: globalData.userRole,
|
||||
competitionId: this.competitionId
|
||||
})
|
||||
}
|
||||
|
||||
// 加载场地和项目列表
|
||||
await this.loadVenuesAndProjects()
|
||||
},
|
||||
|
||||
methods: {
|
||||
switchVenue(venue) {
|
||||
this.currentVenue = venue
|
||||
async loadVenuesAndProjects() {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
// 🔥 关键改动:使用 dataAdapter 获取场地列表
|
||||
// Mock模式:调用 mock/athlete.js 的 getVenues 函数
|
||||
// API模式:调用 api/athlete.js 的 getVenues 函数(GET /martial/venue/list)
|
||||
const venuesRes = await dataAdapter.getData('getVenues', {
|
||||
competitionId: this.competitionId
|
||||
})
|
||||
|
||||
// 🔥 关键改动:使用 dataAdapter 获取项目列表
|
||||
// Mock模式:调用 mock/athlete.js 的 getProjects 函数
|
||||
// API模式:调用 api/athlete.js 的 getProjects 函数(GET /martial/project/list)
|
||||
const projectsRes = await dataAdapter.getData('getProjects', {
|
||||
competitionId: this.competitionId
|
||||
})
|
||||
|
||||
this.venues = venuesRes.data || []
|
||||
this.projects = projectsRes.data || []
|
||||
|
||||
// 默认选中第一个场地和项目
|
||||
if (this.venues.length > 0) {
|
||||
this.currentVenue = this.venues[0].venueId
|
||||
}
|
||||
if (this.projects.length > 0) {
|
||||
this.currentProject = this.projects[0].projectId
|
||||
}
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('场地和项目加载成功:', {
|
||||
venues: this.venues.length,
|
||||
projects: this.projects.length,
|
||||
currentVenue: this.currentVenue,
|
||||
currentProject: this.currentProject
|
||||
})
|
||||
}
|
||||
|
||||
// 加载选手列表
|
||||
if (this.currentVenue && this.currentProject) {
|
||||
await this.loadPlayers()
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('加载场地和项目失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
switchProject(index) {
|
||||
this.currentProject = index
|
||||
|
||||
async loadPlayers() {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
// 🔥 关键改动:使用 dataAdapter 获取选手列表(裁判长视图)
|
||||
// Mock模式:调用 mock/athlete.js 的 getAthletesForAdmin 函数
|
||||
// API模式:调用 api/athlete.js 的 getAthletesForAdmin 函数(GET /api/mini/athletes/admin)
|
||||
const response = await dataAdapter.getData('getAthletesForAdmin', {
|
||||
competitionId: this.competitionId,
|
||||
venueId: this.currentVenue,
|
||||
projectId: this.currentProject
|
||||
})
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 保存选手列表
|
||||
this.players = response.data || []
|
||||
|
||||
// 计算评分统计(裁判长视图:统计有总分的选手)
|
||||
this.totalCount = this.players.length
|
||||
this.scoredCount = this.players.filter(p => p.totalScore).length
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('选手列表加载成功:', {
|
||||
venueId: this.currentVenue,
|
||||
projectId: this.currentProject,
|
||||
total: this.totalCount,
|
||||
scored: this.scoredCount,
|
||||
players: this.players
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('加载选手列表失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
goToModify() {
|
||||
|
||||
async switchVenue(venueId) {
|
||||
if (this.currentVenue === venueId) return
|
||||
|
||||
this.currentVenue = venueId
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('切换场地:', venueId)
|
||||
}
|
||||
|
||||
// 重新加载选手列表
|
||||
await this.loadPlayers()
|
||||
},
|
||||
|
||||
async switchProject(projectId) {
|
||||
if (this.currentProject === projectId) return
|
||||
|
||||
this.currentProject = projectId
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('切换项目:', projectId)
|
||||
}
|
||||
|
||||
// 重新加载选手列表
|
||||
await this.loadPlayers()
|
||||
},
|
||||
|
||||
goToModify(player) {
|
||||
// 保存当前选手信息到全局数据
|
||||
const app = getApp()
|
||||
app.globalData.currentAthlete = player
|
||||
|
||||
uni.navigateTo({
|
||||
url: '/pages/modify-score/modify-score'
|
||||
})
|
||||
|
||||
@@ -11,71 +11,58 @@
|
||||
|
||||
<!-- 比赛信息 -->
|
||||
<view class="match-info">
|
||||
<view class="match-title">
|
||||
2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛
|
||||
</view>
|
||||
<view class="match-time">比赛时间:2025年6月25日 9:00</view>
|
||||
<view class="match-title">{{ matchInfo.name }}</view>
|
||||
<view class="match-time">比赛时间:{{ matchInfo.time }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 场地和项目选择 -->
|
||||
<view class="venue-section">
|
||||
<view class="venue-header">
|
||||
<view class="venue-tab active">第一场地</view>
|
||||
<view class="venue-tab active">{{ venueInfo.name }}</view>
|
||||
</view>
|
||||
|
||||
<view class="project-section">
|
||||
<view class="project-btn active">男子组陈氏太极拳</view>
|
||||
<view class="project-btn active">{{ projectInfo.name }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 已评分统计 -->
|
||||
<view class="score-stats">
|
||||
<text class="stats-text">已评分:</text>
|
||||
<text class="stats-number">2/30</text>
|
||||
<text class="stats-number">{{ scoredCount }}/{{ totalCount }}</text>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 选手列表 -->
|
||||
<view class="player-list">
|
||||
<!-- 第一个选手 - 显示我的评分和总分 -->
|
||||
<view class="player-card">
|
||||
<!-- 遍历选手列表 -->
|
||||
<view
|
||||
class="player-card"
|
||||
v-for="player in players"
|
||||
:key="player.athleteId"
|
||||
>
|
||||
<view class="player-header">
|
||||
<view class="player-name">张三</view>
|
||||
<view class="player-scores">
|
||||
<text class="my-score">我的评分:8.906</text>
|
||||
<text class="total-score">总分:8.907</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="player-info">
|
||||
<view class="info-item">身份证:123456789000000000</view>
|
||||
<view class="info-item">队伍:少林寺武术大学院</view>
|
||||
<view class="info-item">编号:123-4567898275</view>
|
||||
</view>
|
||||
<view class="player-name">{{ player.name }}</view>
|
||||
|
||||
<!-- 已评分:显示我的评分和总分 -->
|
||||
<view class="player-scores" v-if="player.scored">
|
||||
<text class="my-score">我的评分:{{ player.myScore }}</text>
|
||||
<text class="total-score">总分:{{ player.totalScore }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 第二个选手 - 裁判长功能 -->
|
||||
<view class="player-card">
|
||||
<view class="player-header">
|
||||
<view class="player-name">张三</view>
|
||||
<view class="action-area">
|
||||
<button class="score-btn" @click="goToScoreDetail">评分</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="player-info">
|
||||
<view class="info-item">身份证:123456789000000000</view>
|
||||
<view class="info-item">队伍:少林寺武术大学院</view>
|
||||
<view class="info-item">编号:123-4567898275</view>
|
||||
</view>
|
||||
<!-- 未评分:显示评分按钮 -->
|
||||
<button
|
||||
class="score-btn"
|
||||
v-else
|
||||
@click="goToScoreDetail(player)"
|
||||
>
|
||||
评分
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- 第三个选手 - 简单样式 -->
|
||||
<view class="player-card">
|
||||
<view class="player-header">
|
||||
<view class="player-name">张三</view>
|
||||
<button class="score-btn" @click="goToScoreDetail">评分</button>
|
||||
</view>
|
||||
<view class="player-info">
|
||||
<view class="info-item">身份证:123456789000000000</view>
|
||||
<view class="info-item">身份证:{{ player.idCard }}</view>
|
||||
<view class="info-item">队伍:{{ player.team }}</view>
|
||||
<view class="info-item">编号:{{ player.number }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -83,14 +70,123 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import dataAdapter from '@/utils/dataAdapter.js'
|
||||
import config from '@/config/env.config.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
matchInfo: {
|
||||
name: '',
|
||||
time: ''
|
||||
},
|
||||
venueInfo: {
|
||||
id: '',
|
||||
name: ''
|
||||
},
|
||||
projectInfo: {
|
||||
id: '',
|
||||
name: ''
|
||||
},
|
||||
judgeId: '',
|
||||
players: [],
|
||||
scoredCount: 0,
|
||||
totalCount: 0
|
||||
}
|
||||
},
|
||||
|
||||
async onLoad() {
|
||||
// 获取全局数据
|
||||
const app = getApp()
|
||||
const globalData = app.globalData || {}
|
||||
|
||||
// 加载比赛信息
|
||||
this.matchInfo = {
|
||||
name: globalData.matchName || '比赛名称',
|
||||
time: globalData.matchTime || '比赛时间'
|
||||
}
|
||||
|
||||
// 加载场地信息
|
||||
this.venueInfo = {
|
||||
id: globalData.venueId,
|
||||
name: globalData.venueName || '场地'
|
||||
}
|
||||
|
||||
// 加载项目信息
|
||||
const projects = globalData.projects || []
|
||||
const currentIndex = globalData.currentProjectIndex || 0
|
||||
const currentProject = projects[currentIndex] || {}
|
||||
this.projectInfo = {
|
||||
id: currentProject.projectId,
|
||||
name: currentProject.projectName || '项目'
|
||||
}
|
||||
|
||||
this.judgeId = globalData.judgeId
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('评分列表页加载:', {
|
||||
judgeId: this.judgeId,
|
||||
venueId: this.venueInfo.id,
|
||||
projectId: this.projectInfo.id
|
||||
})
|
||||
}
|
||||
|
||||
// 加载选手列表
|
||||
await this.loadPlayers()
|
||||
},
|
||||
|
||||
methods: {
|
||||
goToScoreDetail() {
|
||||
async loadPlayers() {
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
// 🔥 关键改动:使用 dataAdapter 获取选手列表
|
||||
// Mock模式:调用 mock/athlete.js 的 getMyAthletes 函数
|
||||
// API模式:调用 api/athlete.js 的 getMyAthletes 函数(GET /api/mini/athletes)
|
||||
const response = await dataAdapter.getData('getMyAthletes', {
|
||||
judgeId: this.judgeId,
|
||||
venueId: this.venueInfo.id,
|
||||
projectId: this.projectInfo.id
|
||||
})
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
// 保存选手列表
|
||||
this.players = response.data || []
|
||||
|
||||
// 计算评分统计
|
||||
this.totalCount = this.players.length
|
||||
this.scoredCount = this.players.filter(p => p.scored).length
|
||||
|
||||
// 调试信息
|
||||
if (config.debug) {
|
||||
console.log('选手列表加载成功:', {
|
||||
total: this.totalCount,
|
||||
scored: this.scoredCount,
|
||||
players: this.players
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('加载选手列表失败:', error)
|
||||
|
||||
uni.showToast({
|
||||
title: error.message || '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
goToScoreDetail(player) {
|
||||
// 保存当前选手信息到全局数据
|
||||
const app = getApp()
|
||||
app.globalData.currentAthlete = player
|
||||
|
||||
uni.navigateTo({
|
||||
url: '/pages/score-detail/score-detail'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user