| | |
| | | data: { |
| | | projectId: '', |
| | | projectDetail: null, |
| | | ratingStats: null, |
| | | timeline: [], |
| | | loading: true, |
| | | error: '', |
| | | statusText: '', |
| | | genderText: '', |
| | | educationText: '' |
| | | educationText: '', |
| | | timelineLoading: false, |
| | | timelineError: '', |
| | | showRatingDetail: false, |
| | | ratingDetail: null, |
| | | ratingDetailLoading: false, |
| | | ratingDetailError: '' |
| | | }, |
| | | |
| | | onLoad(options) { |
| | |
| | | error: '' |
| | | }) |
| | | |
| | | // 调用API获取项目详情 |
| | | const projectDetail = await this.getProjectDetailFromAPI(this.data.projectId) |
| | | |
| | | if (projectDetail) { |
| | | // 处理文件大小显示 |
| | | if (!projectDetail) { |
| | | throw new Error('项目详情获取失败') |
| | | } |
| | | |
| | | if (projectDetail.submissionFiles) { |
| | | projectDetail.submissionFiles.forEach(file => { |
| | | file.fileSizeText = this.formatFileSize(file.fileSize) |
| | | }) |
| | | } |
| | | |
| | | // 获取评分统计 |
| | | const ratingStats = await this.getRatingStatsFromAPI(this.data.projectId) |
| | | |
| | | // 处理评分时间显示 |
| | | if (ratingStats && ratingStats.judgeRatings) { |
| | | ratingStats.judgeRatings.forEach(rating => { |
| | | if (rating.ratingTime) { |
| | | rating.ratingTimeText = this.formatDateTime(rating.ratingTime) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.setData({ |
| | | projectDetail, |
| | | ratingStats, |
| | | statusText: this.getStatusText(projectDetail.state), |
| | | genderText: this.getGenderText(projectDetail.playerInfo?.gender), |
| | | educationText: this.getEducationText(projectDetail.playerInfo?.education), |
| | | loading: false |
| | | educationText: this.getEducationText(projectDetail.playerInfo?.education) |
| | | }) |
| | | } else { |
| | | throw new Error('项目详情获取失败') |
| | | } |
| | | |
| | | await this.loadProjectTimeline(this.data.projectId) |
| | | } catch (error) { |
| | | console.error('加载项目详情失败:', error) |
| | | this.setData({ |
| | | error: error.message || '加载失败,请重试', |
| | | loading: false |
| | | error: error.message || '加载失败,请重试' |
| | | }) |
| | | } finally { |
| | | this.setData({ loading: false }) |
| | | } |
| | | }, |
| | | |
| | |
| | | query GetProjectDetail($id: ID!) { |
| | | activityPlayerDetail(id: $id) { |
| | | id |
| | | activityId |
| | | playerId |
| | | playerName |
| | | playerGender |
| | | playerPhone |
| | | playerEducation |
| | | playerBirthDate |
| | | playerIdCard |
| | | playerAddress |
| | | projectName |
| | | projectDescription |
| | | projectCategory |
| | | projectTags |
| | | projectFiles { |
| | | playerInfo { |
| | | id |
| | | fileName |
| | | fileUrl |
| | | name |
| | | phone |
| | | gender |
| | | birthday |
| | | education |
| | | introduction |
| | | description |
| | | avatarUrl |
| | | avatar { |
| | | id |
| | | fullUrl |
| | | fullThumbUrl |
| | | name |
| | | fileSize |
| | | fileType |
| | | uploadTime |
| | | fileExt |
| | | } |
| | | submitTime |
| | | reviewTime |
| | | reviewerId |
| | | reviewerName |
| | | score |
| | | rating { |
| | | userInfo { |
| | | userId |
| | | name |
| | | phone |
| | | avatarUrl |
| | | } |
| | | } |
| | | regionInfo { |
| | | id |
| | | judgeId |
| | | judgeName |
| | | score |
| | | feedback |
| | | ratingTime |
| | | name |
| | | fullPath |
| | | } |
| | | state |
| | | activityName |
| | | projectName |
| | | description |
| | | feedback |
| | | state |
| | | stageId |
| | | submissionFiles { |
| | | id |
| | | fullUrl |
| | | fullThumbUrl |
| | | name |
| | | fileSize |
| | | fileExt |
| | | mediaType |
| | | } |
| | | ratingForm { |
| | | schemeId |
| | | schemeName |
| | | items { |
| | | id |
| | | name |
| | | maxScore |
| | | orderNo |
| | | } |
| | | totalMaxScore |
| | | } |
| | | } |
| | | } |
| | | ` |
| | |
| | | } |
| | | }, |
| | | |
| | | // 获取评分统计 |
| | | async getRatingStatsFromAPI(projectId) { |
| | | async loadProjectTimeline(activityPlayerId) { |
| | | if (!activityPlayerId) { |
| | | return |
| | | } |
| | | |
| | | const idNumber = Number(activityPlayerId) |
| | | const variables = { |
| | | activityPlayerId: Number.isNaN(idNumber) ? activityPlayerId : idNumber |
| | | } |
| | | |
| | | this.setData({ |
| | | timelineLoading: true, |
| | | timelineError: '' |
| | | }) |
| | | |
| | | const query = ` |
| | | query GetRatingStats($activityPlayerId: ID!) { |
| | | ratingStats(activityPlayerId: $activityPlayerId) { |
| | | query ProjectStageTimeline($activityPlayerId: ID!) { |
| | | projectStageTimeline(activityPlayerId: $activityPlayerId) { |
| | | activityId |
| | | activityName |
| | | stages { |
| | | stageId |
| | | stageName |
| | | matchTime |
| | | sortOrder |
| | | participated |
| | | activityPlayerId |
| | | averageScore |
| | | totalRatings |
| | | scoreDistribution { |
| | | score |
| | | count |
| | | ratingCount |
| | | hasRating |
| | | latestRatingTime |
| | | } |
| | | } |
| | | } |
| | | ` |
| | | |
| | | try { |
| | | const result = await app.graphqlRequest(query, { activityPlayerId: projectId }) |
| | | return result.ratingStats |
| | | const result = await app.graphqlRequest(query, variables) |
| | | const projectStageTimeline = result && result.projectStageTimeline ? result.projectStageTimeline : null |
| | | const stages = projectStageTimeline && projectStageTimeline.stages ? projectStageTimeline.stages : [] |
| | | |
| | | const timeline = stages.map(stage => { |
| | | const hasScore = stage.hasRating && stage.averageScore !== null && stage.averageScore !== undefined |
| | | let scoreText = '未参赛' |
| | | if (stage.participated) { |
| | | scoreText = hasScore ? `平均分:${Number(stage.averageScore).toFixed(2)}` : '未评分' |
| | | } |
| | | |
| | | return { |
| | | ...stage, |
| | | matchTimeText: stage.matchTime ? this.formatDateTime(stage.matchTime) : '', |
| | | scoreText, |
| | | displayAverageScore: hasScore ? Number(stage.averageScore).toFixed(2) : null, |
| | | isClickable: stage.participated && hasScore && !!stage.activityPlayerId |
| | | } |
| | | }) |
| | | |
| | | this.setData({ |
| | | timeline, |
| | | timelineLoading: false |
| | | }) |
| | | } catch (error) { |
| | | throw error |
| | | console.error('加载阶段时间轴失败:', error) |
| | | this.setData({ |
| | | timelineError: error.message || '时间轴加载失败', |
| | | timelineLoading: false |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | // 获取评委评分详情 |
| | | async getJudgeRatingDetail(activityPlayerId, judgeId) { |
| | | async fetchStageRatingDetail(activityPlayerId) { |
| | | const idNumber = Number(activityPlayerId) |
| | | const variables = { |
| | | activityPlayerId: Number.isNaN(idNumber) ? activityPlayerId : idNumber |
| | | } |
| | | |
| | | const query = ` |
| | | query GetJudgeRatingDetail($activityPlayerId: ID!, $judgeId: ID!) { |
| | | judgeRatingDetail(activityPlayerId: $activityPlayerId, judgeId: $judgeId) { |
| | | remark |
| | | query StageJudgeRatings($activityPlayerId: ID!) { |
| | | stageJudgeRatings(activityPlayerId: $activityPlayerId) { |
| | | activityPlayerId |
| | | stageId |
| | | stageName |
| | | matchTime |
| | | ratingCount |
| | | averageScore |
| | | judgeRatings { |
| | | judgeId |
| | | judgeName |
| | | totalScore |
| | | feedback |
| | | ratingTime |
| | | } |
| | | } |
| | | } |
| | | ` |
| | | |
| | | try { |
| | | const result = await app.graphqlRequest(query, { activityPlayerId, judgeId }) |
| | | return result.judgeRatingDetail |
| | | } catch (error) { |
| | | throw error |
| | | const result = await app.graphqlRequest(query, variables) |
| | | const detail = result && result.stageJudgeRatings ? result.stageJudgeRatings : null |
| | | |
| | | const sourceJudgeRatings = detail && detail.judgeRatings ? detail.judgeRatings : [] |
| | | const judgeRatings = sourceJudgeRatings.map(item => ({ |
| | | ...item, |
| | | totalScoreText: item.totalScore !== null && item.totalScore !== undefined ? `${Number(item.totalScore).toFixed(2)}分` : '未评分', |
| | | ratingTimeText: item.ratingTime ? this.formatDateTime(item.ratingTime) : '' |
| | | })) |
| | | |
| | | const averageScoreValue = detail && detail.averageScore !== undefined && detail.averageScore !== null |
| | | ? detail.averageScore |
| | | : null |
| | | |
| | | return { |
| | | activityPlayerId: detail && detail.activityPlayerId ? detail.activityPlayerId : variables.activityPlayerId, |
| | | stageId: detail && detail.stageId ? detail.stageId : null, |
| | | stageName: detail && detail.stageName ? detail.stageName : '阶段信息', |
| | | matchTime: detail && detail.matchTime ? detail.matchTime : null, |
| | | matchTimeText: detail && detail.matchTime ? this.formatDateTime(detail.matchTime) : '', |
| | | ratingCount: detail && detail.ratingCount ? detail.ratingCount : 0, |
| | | averageScore: averageScoreValue, |
| | | averageScoreText: averageScoreValue !== null ? Number(averageScoreValue).toFixed(2) : '暂无评分', |
| | | judgeRatings |
| | | } |
| | | }, |
| | | |
| | | async openStageDetail(e) { |
| | | const { playerId } = e.currentTarget.dataset |
| | | const clickable = e.currentTarget.dataset.clickable === true || e.currentTarget.dataset.clickable === 'true' |
| | | const participated = e.currentTarget.dataset.participated === true || e.currentTarget.dataset.participated === 'true' |
| | | |
| | | if (!playerId || !participated) { |
| | | return |
| | | } |
| | | |
| | | if (!clickable) { |
| | | wx.showToast({ |
| | | title: '暂无评分', |
| | | icon: 'none' |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setData({ |
| | | showRatingDetail: true, |
| | | ratingDetailLoading: true, |
| | | ratingDetailError: '', |
| | | ratingDetail: { judgeRatings: [] } |
| | | }) |
| | | |
| | | try { |
| | | const detail = await this.fetchStageRatingDetail(playerId) |
| | | this.setData({ |
| | | ratingDetail: detail, |
| | | ratingDetailLoading: false |
| | | }) |
| | | } catch (error) { |
| | | console.error('加载阶段评分详情失败:', error) |
| | | this.setData({ |
| | | ratingDetailError: error.message || '加载失败', |
| | | ratingDetailLoading: false |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | closeStageDetail() { |
| | | this.setData({ |
| | | showRatingDetail: false, |
| | | ratingDetail: null, |
| | | ratingDetailError: '' |
| | | }) |
| | | }, |
| | | |
| | | // 预览文件 |
| | | previewFile(e) { |
| | | const file = e.currentTarget.dataset.file |