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:
2025-12-11 14:48:51 +08:00
parent a4d457b730
commit dc9743e6db
5 changed files with 791 additions and 198 deletions

View File

@@ -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'
})