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:
@@ -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() {
|
||||
uni.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'success'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
|
||||
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',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
// 返回上一页
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('修改评分失败:', error)
|
||||
|
||||
uni.showToast({
|
||||
title: error.message || '修改失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user