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:
@@ -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() {
|
||||
uni.showToast({
|
||||
title: '提交成功',
|
||||
icon: 'success'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
|
||||
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',
|
||||
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