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>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import dataAdapter from '@/utils/dataAdapter.js'
|
||||||
|
import config from '@/config/env.config.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -53,8 +56,19 @@ export default {
|
|||||||
inviteCode: ''
|
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: {
|
methods: {
|
||||||
handleSubmit() {
|
async handleSubmit() {
|
||||||
|
// 表单验证
|
||||||
if (!this.matchCode) {
|
if (!this.matchCode) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '请输入比赛编码',
|
title: '请输入比赛编码',
|
||||||
@@ -70,35 +84,98 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断权限类型
|
try {
|
||||||
const role = this.inviteCode.toLowerCase()
|
// 显示加载
|
||||||
|
uni.showLoading({
|
||||||
|
title: '登录中...',
|
||||||
|
mask: true
|
||||||
|
})
|
||||||
|
|
||||||
if (role !== 'pub' && role !== 'admin') {
|
// 🔥 关键改动:使用 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 // 当前选中的项目索引
|
||||||
|
}
|
||||||
|
|
||||||
|
// 调试信息
|
||||||
|
if (config.debug) {
|
||||||
|
console.log('登录成功:', {
|
||||||
|
userRole,
|
||||||
|
judgeName,
|
||||||
|
venueId: venueId || '全部场地',
|
||||||
|
projects: projects.length + '个项目'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示登录成功提示
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '邀请码错误,请输入pub或admin',
|
title: '登录成功',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 1500
|
||||||
|
})
|
||||||
|
|
||||||
|
// 根据角色跳转到不同页面
|
||||||
|
setTimeout(() => {
|
||||||
|
if (userRole === 'admin') {
|
||||||
|
// 裁判长跳转到多场地列表页(可以修改评分)
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/score-list-multi/score-list-multi'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// 普通裁判跳转到评分列表页(可以评分)
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/score-list/score-list'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, 1500)
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
uni.hideLoading()
|
||||||
|
|
||||||
|
// 错误处理
|
||||||
|
console.error('登录失败:', error)
|
||||||
|
|
||||||
|
uni.showToast({
|
||||||
|
title: error.message || '登录失败,请重试',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 保存用户角色到全局数据
|
|
||||||
getApp().globalData = {
|
|
||||||
userRole: role,
|
|
||||||
matchCode: this.matchCode
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据角色跳转到不同页面
|
|
||||||
if (role === 'admin') {
|
|
||||||
// 裁判长跳转到多场地列表页(可以修改评分)
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/score-list-multi/score-list-multi'
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// 普通裁判跳转到评分列表页(可以评分)
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/score-list/score-list'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,46 +15,30 @@
|
|||||||
<!-- 选手信息 -->
|
<!-- 选手信息 -->
|
||||||
<view class="player-info-section">
|
<view class="player-info-section">
|
||||||
<view class="player-header">
|
<view class="player-header">
|
||||||
<view class="player-name">张三</view>
|
<view class="player-name">{{ athleteInfo.name }}</view>
|
||||||
<view class="total-score-label">
|
<view class="total-score-label">
|
||||||
<text class="label-text">总分:</text>
|
<text class="label-text">总分:</text>
|
||||||
<text class="score-value">8.907</text>
|
<text class="score-value">{{ athleteInfo.totalScore }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="player-details">
|
<view class="player-details">
|
||||||
<view class="detail-item">身份证:123456789000000000</view>
|
<view class="detail-item">身份证:{{ athleteInfo.idCard }}</view>
|
||||||
<view class="detail-item">队伍:少林寺武术大学院</view>
|
<view class="detail-item">队伍:{{ athleteInfo.team }}</view>
|
||||||
<view class="detail-item">编号:123-4567898275</view>
|
<view class="detail-item">编号:{{ athleteInfo.number }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 评委评分统计 -->
|
<!-- 评委评分统计 -->
|
||||||
<view class="judges-section">
|
<view class="judges-section">
|
||||||
<view class="section-title">共有6位评委完成评分</view>
|
<view class="section-title">共有{{ judgeScores.length }}位评委完成评分</view>
|
||||||
<view class="judges-scores">
|
<view class="judges-scores">
|
||||||
<view class="judge-score-item">
|
<view
|
||||||
<text class="judge-name">欧阳丽娜:</text>
|
class="judge-score-item"
|
||||||
<text class="judge-score">8.907</text>
|
v-for="judge in judgeScores"
|
||||||
</view>
|
:key="judge.judgeId"
|
||||||
<view class="judge-score-item">
|
>
|
||||||
<text class="judge-name">张三:</text>
|
<text class="judge-name">{{ judge.judgeName }}:</text>
|
||||||
<text class="judge-score">8.901</text>
|
<text class="judge-score">{{ judge.score }}</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>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -109,37 +93,194 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import dataAdapter from '@/utils/dataAdapter.js'
|
||||||
|
import config from '@/config/env.config.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentScore: 8.907,
|
athleteInfo: {
|
||||||
|
athleteId: '',
|
||||||
|
name: '',
|
||||||
|
idCard: '',
|
||||||
|
team: '',
|
||||||
|
number: '',
|
||||||
|
totalScore: 0
|
||||||
|
},
|
||||||
|
judgeScores: [],
|
||||||
|
modification: null,
|
||||||
|
modifierId: '',
|
||||||
|
currentScore: 8.000,
|
||||||
|
originalScore: 8.000,
|
||||||
note: '',
|
note: '',
|
||||||
minScore: 5.0,
|
minScore: 5.0,
|
||||||
maxScore: 10.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: {
|
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() {
|
goBack() {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
},
|
},
|
||||||
|
|
||||||
decreaseScore() {
|
decreaseScore() {
|
||||||
if (this.currentScore > this.minScore) {
|
if (this.currentScore > this.minScore) {
|
||||||
this.currentScore = parseFloat((this.currentScore - 0.001).toFixed(3))
|
this.currentScore = parseFloat((this.currentScore - 0.001).toFixed(3))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
increaseScore() {
|
increaseScore() {
|
||||||
if (this.currentScore < this.maxScore) {
|
if (this.currentScore < this.maxScore) {
|
||||||
this.currentScore = parseFloat((this.currentScore + 0.001).toFixed(3))
|
this.currentScore = parseFloat((this.currentScore + 0.001).toFixed(3))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleModify() {
|
|
||||||
uni.showToast({
|
async handleModify() {
|
||||||
title: '修改成功',
|
// 验证评分范围
|
||||||
icon: 'success'
|
if (this.currentScore < this.minScore || this.currentScore > this.maxScore) {
|
||||||
})
|
uni.showToast({
|
||||||
setTimeout(() => {
|
title: `评分必须在${this.minScore}-${this.maxScore}分之间`,
|
||||||
uni.navigateBack()
|
icon: 'none'
|
||||||
}, 1500)
|
})
|
||||||
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
<!-- 选手信息 -->
|
<!-- 选手信息 -->
|
||||||
<view class="player-info-section">
|
<view class="player-info-section">
|
||||||
<view class="player-name">张三</view>
|
<view class="player-name">{{ player.name }}</view>
|
||||||
<view class="player-details">
|
<view class="player-details">
|
||||||
<view class="detail-item">身份证:123456789000000000</view>
|
<view class="detail-item">身份证:{{ player.idCard }}</view>
|
||||||
<view class="detail-item">队伍:少林寺武术大学院</view>
|
<view class="detail-item">队伍:{{ player.team }}</view>
|
||||||
<view class="detail-item">编号:123-4567898275</view>
|
<view class="detail-item">编号:{{ player.number }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -58,14 +58,14 @@
|
|||||||
<view class="deduction-list">
|
<view class="deduction-list">
|
||||||
<view
|
<view
|
||||||
v-for="(item, index) in deductions"
|
v-for="(item, index) in deductions"
|
||||||
:key="index"
|
:key="item.deductionId"
|
||||||
class="deduction-item"
|
class="deduction-item"
|
||||||
@click="toggleDeduction(index)"
|
@click="toggleDeduction(index)"
|
||||||
>
|
>
|
||||||
<view :class="['checkbox', item.checked ? 'checked' : '']">
|
<view :class="['checkbox', item.checked ? 'checked' : '']">
|
||||||
<text v-if="item.checked" class="check-icon">✓</text>
|
<text v-if="item.checked" class="check-icon">✓</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="deduction-text">{{ item.text }}</text>
|
<text class="deduction-text">{{ item.deductionName }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -92,50 +92,190 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import dataAdapter from '@/utils/dataAdapter.js'
|
||||||
|
import config from '@/config/env.config.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentScore: 8.907,
|
player: {
|
||||||
|
athleteId: '',
|
||||||
|
name: '',
|
||||||
|
idCard: '',
|
||||||
|
team: '',
|
||||||
|
number: ''
|
||||||
|
},
|
||||||
|
judgeId: '',
|
||||||
|
projectId: '',
|
||||||
|
currentScore: 8.000,
|
||||||
note: '',
|
note: '',
|
||||||
minScore: 5.0,
|
minScore: 5.0,
|
||||||
maxScore: 10.0,
|
maxScore: 10.0,
|
||||||
deductions: [
|
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 }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
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: {
|
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() {
|
goBack() {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
},
|
},
|
||||||
|
|
||||||
decreaseScore() {
|
decreaseScore() {
|
||||||
if (this.currentScore > this.minScore) {
|
if (this.currentScore > this.minScore) {
|
||||||
this.currentScore = parseFloat((this.currentScore - 0.001).toFixed(3))
|
this.currentScore = parseFloat((this.currentScore - 0.001).toFixed(3))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
increaseScore() {
|
increaseScore() {
|
||||||
if (this.currentScore < this.maxScore) {
|
if (this.currentScore < this.maxScore) {
|
||||||
this.currentScore = parseFloat((this.currentScore + 0.001).toFixed(3))
|
this.currentScore = parseFloat((this.currentScore + 0.001).toFixed(3))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleDeduction(index) {
|
toggleDeduction(index) {
|
||||||
this.deductions[index].checked = !this.deductions[index].checked
|
this.deductions[index].checked = !this.deductions[index].checked
|
||||||
},
|
},
|
||||||
handleSubmit() {
|
|
||||||
uni.showToast({
|
async handleSubmit() {
|
||||||
title: '提交成功',
|
// 验证评分范围
|
||||||
icon: 'success'
|
if (this.currentScore < this.minScore || this.currentScore > this.maxScore) {
|
||||||
})
|
uni.showToast({
|
||||||
setTimeout(() => {
|
title: `评分必须在${this.minScore}-${this.maxScore}分之间`,
|
||||||
uni.navigateBack()
|
icon: 'none'
|
||||||
}, 1500)
|
})
|
||||||
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,8 @@
|
|||||||
|
|
||||||
<!-- 比赛信息 -->
|
<!-- 比赛信息 -->
|
||||||
<view class="match-info">
|
<view class="match-info">
|
||||||
<view class="match-title">
|
<view class="match-title">{{ matchInfo.name }}</view>
|
||||||
2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛
|
<view class="match-time">比赛时间:{{ matchInfo.time }}</view>
|
||||||
</view>
|
|
||||||
<view class="match-time">比赛时间:2025年6月25日 9:00</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 场地和项目选择 -->
|
<!-- 场地和项目选择 -->
|
||||||
@@ -24,11 +22,11 @@
|
|||||||
<view class="venue-tabs">
|
<view class="venue-tabs">
|
||||||
<view
|
<view
|
||||||
v-for="venue in venues"
|
v-for="venue in venues"
|
||||||
:key="venue.id"
|
:key="venue.venueId"
|
||||||
:class="['venue-tab', currentVenue === venue.id ? 'active' : '']"
|
:class="['venue-tab', currentVenue === venue.venueId ? 'active' : '']"
|
||||||
@click="switchVenue(venue.id)"
|
@click="switchVenue(venue.venueId)"
|
||||||
>
|
>
|
||||||
{{ venue.name }}
|
{{ venue.venueName }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
@@ -43,11 +41,11 @@
|
|||||||
<view class="project-list">
|
<view class="project-list">
|
||||||
<view
|
<view
|
||||||
v-for="(project, index) in projects"
|
v-for="(project, index) in projects"
|
||||||
:key="index"
|
:key="project.projectId"
|
||||||
:class="['project-btn', currentProject === index ? 'active' : '']"
|
:class="['project-btn', currentProject === project.projectId ? 'active' : '']"
|
||||||
@click="switchProject(index)"
|
@click="switchProject(project.projectId)"
|
||||||
>
|
>
|
||||||
{{ project }}
|
{{ project.projectName }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
@@ -56,49 +54,34 @@
|
|||||||
<!-- 已评分统计 -->
|
<!-- 已评分统计 -->
|
||||||
<view class="score-stats">
|
<view class="score-stats">
|
||||||
<text class="stats-text">已评分:</text>
|
<text class="stats-text">已评分:</text>
|
||||||
<text class="stats-number">2/30</text>
|
<text class="stats-number">{{ scoredCount }}/{{ totalCount }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 选手列表 -->
|
<!-- 选手列表 -->
|
||||||
<view class="player-list">
|
<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-header">
|
||||||
<view class="player-name">张三</view>
|
<view class="player-name">{{ player.name }}</view>
|
||||||
<view class="action-area">
|
|
||||||
<text class="total-score">总分:8.907</text>
|
<!-- 已评分:显示总分和修改按钮 -->
|
||||||
|
<view class="action-area" v-if="player.totalScore">
|
||||||
|
<text class="total-score">总分:{{ player.totalScore }}</text>
|
||||||
<view class="chief-actions">
|
<view class="chief-actions">
|
||||||
<!-- <text class="chief-hint">裁判长功能:修改评分、修改按钮需等总分出来才出现</text> -->
|
<!-- <text class="chief-hint">裁判长功能:修改评分、修改按钮需等总分出来才出现</text> -->
|
||||||
<button class="modify-btn" @click="goToModify">修改</button>
|
<button class="modify-btn" @click="goToModify(player)">修改</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</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="player-info">
|
||||||
<view class="info-item">身份证:123456789000000000</view>
|
<view class="info-item">身份证:{{ player.idCard }}</view>
|
||||||
<view class="info-item">队伍:少林寺武术大学院</view>
|
<view class="info-item">队伍:{{ player.team }}</view>
|
||||||
<view class="info-item">编号:123-4567898275</view>
|
<view class="info-item">编号:{{ player.number }}</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>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -106,38 +89,194 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import dataAdapter from '@/utils/dataAdapter.js'
|
||||||
|
import config from '@/config/env.config.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentVenue: 1,
|
matchInfo: {
|
||||||
currentProject: 0,
|
id: '',
|
||||||
venues: [
|
name: '',
|
||||||
{ id: 1, name: '第一场地' },
|
time: ''
|
||||||
{ id: 2, name: '第二场地' },
|
},
|
||||||
{ id: 3, name: '第三场地' },
|
competitionId: '',
|
||||||
{ id: 4, name: '第四场地' },
|
currentVenue: '',
|
||||||
{ id: 5, name: '第五场地' }
|
currentProject: '',
|
||||||
],
|
venues: [],
|
||||||
projects: [
|
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: {
|
methods: {
|
||||||
switchVenue(venue) {
|
async loadVenuesAndProjects() {
|
||||||
this.currentVenue = venue
|
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({
|
uni.navigateTo({
|
||||||
url: '/pages/modify-score/modify-score'
|
url: '/pages/modify-score/modify-score'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,71 +11,58 @@
|
|||||||
|
|
||||||
<!-- 比赛信息 -->
|
<!-- 比赛信息 -->
|
||||||
<view class="match-info">
|
<view class="match-info">
|
||||||
<view class="match-title">
|
<view class="match-title">{{ matchInfo.name }}</view>
|
||||||
2025年全国武术散打锦标赛暨第十七届世界武术锦标赛选拔赛
|
<view class="match-time">比赛时间:{{ matchInfo.time }}</view>
|
||||||
</view>
|
|
||||||
<view class="match-time">比赛时间:2025年6月25日 9:00</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 场地和项目选择 -->
|
<!-- 场地和项目选择 -->
|
||||||
<view class="venue-section">
|
<view class="venue-section">
|
||||||
<view class="venue-header">
|
<view class="venue-header">
|
||||||
<view class="venue-tab active">第一场地</view>
|
<view class="venue-tab active">{{ venueInfo.name }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="project-section">
|
<view class="project-section">
|
||||||
<view class="project-btn active">男子组陈氏太极拳</view>
|
<view class="project-btn active">{{ projectInfo.name }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 已评分统计 -->
|
<!-- 已评分统计 -->
|
||||||
<view class="score-stats">
|
<view class="score-stats">
|
||||||
<text class="stats-text">已评分:</text>
|
<text class="stats-text">已评分:</text>
|
||||||
<text class="stats-number">2/30</text>
|
<text class="stats-number">{{ scoredCount }}/{{ totalCount }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
<!-- 选手列表 -->
|
<!-- 选手列表 -->
|
||||||
<view class="player-list">
|
<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-header">
|
||||||
<view class="player-name">张三</view>
|
<view class="player-name">{{ 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>
|
|
||||||
|
|
||||||
<!-- 第二个选手 - 裁判长功能 -->
|
<!-- 已评分:显示我的评分和总分 -->
|
||||||
<view class="player-card">
|
<view class="player-scores" v-if="player.scored">
|
||||||
<view class="player-header">
|
<text class="my-score">我的评分:{{ player.myScore }}</text>
|
||||||
<view class="player-name">张三</view>
|
<text class="total-score">总分:{{ player.totalScore }}</text>
|
||||||
<view class="action-area">
|
|
||||||
<button class="score-btn" @click="goToScoreDetail">评分</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">
|
<button
|
||||||
<view class="player-header">
|
class="score-btn"
|
||||||
<view class="player-name">张三</view>
|
v-else
|
||||||
<button class="score-btn" @click="goToScoreDetail">评分</button>
|
@click="goToScoreDetail(player)"
|
||||||
|
>
|
||||||
|
评分
|
||||||
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="player-info">
|
<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>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -83,14 +70,123 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import dataAdapter from '@/utils/dataAdapter.js'
|
||||||
|
import config from '@/config/env.config.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
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: {
|
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({
|
uni.navigateTo({
|
||||||
url: '/pages/score-detail/score-detail'
|
url: '/pages/score-detail/score-detail'
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user