From 356a9f7a6e789ff152b80f917233b8736dfb0d7f Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期五, 07 十一月 2025 11:17:10 +0800
Subject: [PATCH] 页面显示字段调整
---
wx/pages/project/detail.js | 192 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 166 insertions(+), 26 deletions(-)
diff --git a/wx/pages/project/detail.js b/wx/pages/project/detail.js
index 5e56ab7..779d642 100644
--- a/wx/pages/project/detail.js
+++ b/wx/pages/project/detail.js
@@ -10,7 +10,13 @@
error: '',
statusText: '',
genderText: '',
- educationText: ''
+ educationText: '',
+ // 鏃堕棿杞寸浉鍏虫暟鎹�
+ timeline: [],
+ timelineLoading: false,
+ timelineError: '',
+ showRatingDetail: false,
+ ratingDetail: null
},
onLoad(options) {
@@ -43,8 +49,6 @@
if (projectDetail.submissionFiles) {
projectDetail.submissionFiles.forEach(file => {
file.fileSizeText = this.formatFileSize(file.fileSize)
- // 瀛楁宸茬粡鏄纭殑鍚嶇О锛屾棤闇�鏄犲皠
- // fullUrl, fullThumbUrl, fileSize, fileExt 閮芥槸姝g‘鐨勫瓧娈靛悕
})
}
@@ -68,6 +72,9 @@
educationText: this.getEducationText(projectDetail.playerInfo?.education),
loading: false
})
+
+ // 鍔犺浇鏃堕棿杞存暟鎹�
+ this.loadProjectTimeline()
} else {
throw new Error('椤圭洰璇︽儏鑾峰彇澶辫触')
}
@@ -82,11 +89,17 @@
// 浠嶢PI鑾峰彇椤圭洰璇︽儏
async getProjectDetailFromAPI(projectId) {
- // 鏋勫缓GraphQL鏌ヨ
+ // 鏋勫缓GraphQL鏌ヨ - 涓庡悗绔痵chema鍖归厤
const query = `
query GetProjectDetail($id: ID!) {
activityPlayerDetail(id: $id) {
id
+ activityName
+ projectName
+ description
+ feedback
+ state
+ stageId
playerInfo {
id
name
@@ -99,17 +112,19 @@
avatarUrl
avatar {
id
- fullUrl
- fullThumbUrl
name
- fileSize
- fileExt
+ path
}
userInfo {
userId
name
phone
avatarUrl
+ avatar {
+ id
+ name
+ path
+ }
}
}
regionInfo {
@@ -117,31 +132,27 @@
name
fullPath
}
- activityName
- projectName
- description
- feedback
- state
- stageId
submissionFiles {
id
+ name
+ path
+ url
fullUrl
fullThumbUrl
- name
- fileSize
fileExt
- mediaType
+ fileSize
+ thumbUrl
}
ratingForm {
schemeId
schemeName
+ totalMaxScore
items {
id
name
maxScore
- orderNo
+ weight
}
- totalMaxScore
}
}
}
@@ -157,13 +168,31 @@
// 鑾峰彇璇勫垎缁熻
async getRatingStatsFromAPI(projectId) {
- // 鏆傛椂杩斿洖绌虹殑璇勫垎鏁版嵁锛岄伩鍏岹raphQL鏌ヨ閿欒
- // TODO: 闇�瑕佸悗绔彁渚涘悎閫傜殑璇勫垎缁熻鏌ヨ鎺ュ彛
+ const query = `
+ query GetRatingStats($activityPlayerId: ID!) {
+ judgeRatingsForPlayer(activityPlayerId: $activityPlayerId) {
+ judgeId
+ judgeName
+ hasRated
+ totalScore
+ ratingTime
+ }
+ averageScoreForPlayer(activityPlayerId: $activityPlayerId)
+ }
+ `
+
try {
+ const result = await app.graphqlRequest(query, { activityPlayerId: projectId })
+ const ratings = result.judgeRatingsForPlayer || []
+ const averageScore = result.averageScoreForPlayer || 0
+
+ // 鍙绠楀凡璇勫垎鐨勮瘎濮�
+ const ratedJudges = ratings.filter(rating => rating.hasRated)
+
return {
- averageScore: null,
- ratingCount: 0,
- judgeRatings: []
+ averageScore: averageScore,
+ totalRatings: ratedJudges.length,
+ ratings: ratings
}
} catch (error) {
throw error
@@ -186,6 +215,110 @@
} catch (error) {
throw error
}
+ },
+
+ // 鍔犺浇椤圭洰鏃堕棿杞�
+ async loadProjectTimeline() {
+ try {
+ this.setData({
+ timelineLoading: true,
+ timelineError: ''
+ })
+
+ const timeline = await this.getProjectTimelineFromAPI(this.data.projectId)
+
+ if (timeline && timeline.stages) {
+ // 澶勭悊鏃堕棿杞存暟鎹�
+ const processedTimeline = timeline.stages.map(stage => {
+ return {
+ stageId: stage.stageId,
+ stageName: stage.stageName,
+ matchTime: stage.matchTime,
+ matchTimeText: stage.matchTime ? this.formatDateTime(stage.matchTime) : '鏃堕棿寰呭畾',
+ participated: stage.participated,
+ activityPlayerId: stage.activityPlayerId,
+ averageScore: stage.averageScore,
+ ratingCount: stage.ratingCount,
+ hasRating: stage.hasRating,
+ scoreText: stage.averageScore ? `${stage.averageScore.toFixed(1)}鍒哷 : '',
+ isClickable: stage.hasRating && stage.activityPlayerId
+ }
+ })
+
+ this.setData({
+ timeline: processedTimeline,
+ timelineLoading: false
+ })
+ } else {
+ this.setData({
+ timeline: [],
+ timelineLoading: false
+ })
+ }
+ } catch (error) {
+ console.error('鍔犺浇鏃堕棿杞村け璐�:', error)
+ this.setData({
+ timelineError: error.message || '鏃堕棿杞村姞杞藉け璐�',
+ timelineLoading: false
+ })
+ }
+ },
+
+ // 浠嶢PI鑾峰彇椤圭洰鏃堕棿杞�
+ async getProjectTimelineFromAPI(activityPlayerId) {
+ const query = `
+ query GetProjectTimeline($activityPlayerId: ID!) {
+ projectStageTimeline(activityPlayerId: $activityPlayerId) {
+ activityId
+ activityName
+ stages {
+ stageId
+ stageName
+ matchTime
+ sortOrder
+ participated
+ activityPlayerId
+ averageScore
+ ratingCount
+ hasRating
+ latestRatingTime
+ }
+ }
+ }
+ `
+
+ try {
+ const result = await app.graphqlRequest(query, { activityPlayerId })
+ return result.projectStageTimeline
+ } catch (error) {
+ throw error
+ }
+ },
+
+ // 鎵撳紑闃舵璇︽儏
+ openStageDetail(e) {
+ const { playerId, clickable, participated } = e.currentTarget.dataset
+
+ if (!clickable || !participated || !playerId) {
+ wx.showToast({
+ title: '鏆傛棤璇勫垎璇︽儏',
+ icon: 'none'
+ })
+ return
+ }
+
+ // 璺宠浆鍒拌瘎鍒嗚鎯呴〉闈㈡垨鏄剧ず璇︽儏寮圭獥
+ wx.navigateTo({
+ url: `/pages/review/stage-detail?playerId=${playerId}`
+ })
+ },
+
+ // 鍏抽棴闃舵璇︽儏
+ closeStageDetail() {
+ this.setData({
+ showRatingDetail: false,
+ ratingDetail: null
+ })
},
// 棰勮鏂囦欢
@@ -444,6 +577,8 @@
// 鑾峰彇鎬у埆鏂囨湰
getGenderText(gender) {
const genderMap = {
+ 1: '鐢�',
+ 2: '濂�',
'MALE': '鐢�',
'FEMALE': '濂�'
}
@@ -457,9 +592,14 @@
'COLLEGE': '澶т笓',
'BACHELOR': '鏈',
'MASTER': '纭曞+',
- 'DOCTOR': '鍗氬+'
+ 'DOCTOR': '鍗氬+',
+ '楂樹腑鍙婁互涓�': '楂樹腑鍙婁互涓�',
+ '澶т笓': '澶т笓',
+ '鏈': '鏈',
+ '纭曞+': '纭曞+',
+ '鍗氬+': '鍗氬+'
}
- return educationMap[education] || ''
+ return educationMap[education] || education || ''
},
// 鍒嗕韩鍔熻兘
--
Gitblit v1.8.0