From 0a48616045ddce1562584543a0e89e5144051fde Mon Sep 17 00:00:00 2001
From: Codex Assistant <codex@example.com>
Date: 星期日, 05 十月 2025 14:52:44 +0800
Subject: [PATCH] 报名审核

---
 wx/pages/review/index.js |   92 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 66 insertions(+), 26 deletions(-)

diff --git a/wx/pages/review/index.js b/wx/pages/review/index.js
index b30b1cd..3a9dd0e 100644
--- a/wx/pages/review/index.js
+++ b/wx/pages/review/index.js
@@ -2,6 +2,14 @@
 const app = getApp()
 const { graphqlRequest, formatDate } = require('../../lib/utils')
 
+const GET_RATING_STATS_QUERY = `
+  query GetRatingStats($activityPlayerId: ID!) {
+    judgeRatingsForPlayer(activityPlayerId: $activityPlayerId) {
+      hasRated
+    }
+  }
+`
+
 Page({
   data: {
     loading: false,
@@ -55,7 +63,7 @@
 
   // 鍒囨崲閫夐」鍗�
   switchTab(e) {
-    const index = e.currentTarget.dataset.index
+    const index = parseInt(e.currentTarget.dataset.index) || 0
     if (index === this.data.currentTab) return
     
     this.setData({
@@ -110,10 +118,29 @@
       ])
     } catch (error) {
       console.error('鍔犺浇鏁版嵁澶辫触:', error)
-      wx.showToast({
-        title: '鍔犺浇澶辫触',
-        icon: 'none'
-      })
+      
+      // 妫�鏌ユ槸鍚︽槸璁よ瘉鐩稿叧閿欒
+      if (error.message && (
+        error.message.includes('娌℃湁鏉冮檺璁块棶') ||
+        error.message.includes('璇峰厛鐧诲綍') ||
+        error.message.includes('閲嶆柊鐧诲綍')
+      )) {
+        wx.showToast({
+          title: '姝e湪閲嶆柊鐧诲綍...',
+          icon: 'loading',
+          duration: 2000
+        })
+        
+        // 绛夊緟涓�娈垫椂闂村悗閲嶈瘯
+        setTimeout(() => {
+          this.loadData()
+        }, 2000)
+      } else {
+        wx.showToast({
+          title: '鍔犺浇澶辫触锛岃閲嶈瘯',
+          icon: 'none'
+        })
+      }
     } finally {
       this.setData({ loading: false })
       wx.stopPullDownRefresh()
@@ -223,13 +250,13 @@
         const projects = data.items.map(item => ({
           ...item,
           submitTime: item.submitTime ? formatDate(item.submitTime) : '',
-          reviewTime: item.reviewTime ? formatDate(item.reviewTime) : '',
-          statusText: this.getStatusText(item.status),
-          statusType: this.getStatusType(item.status)
+          reviewTime: item.reviewTime ? formatDate(item.reviewTime) : ''
         }))
 
+        const projectsWithRatingCount = await this.enrichProjectsWithRatingCounts(projects)
+
         this.setData({
-          projectList: isLoadMore ? [...this.data.projectList, ...projects] : projects,
+          projectList: isLoadMore ? [...this.data.projectList, ...projectsWithRatingCount] : projectsWithRatingCount,
           hasMore: data.hasMore || false,
           currentPage: variables.page
         })
@@ -274,26 +301,39 @@
     }
   },
 
-  // 鑾峰彇鐘舵�佹枃鏈�
-  getStatusText(status) {
-    const statusMap = {
-      'SUBMITTED': '宸叉彁浜�',
-      'UNDER_REVIEW': '璇勫涓�',
-      'REVIEWED': '宸茶瘎瀹�',
-      'REJECTED': '宸叉嫆缁�'
+  async enrichProjectsWithRatingCounts(projects) {
+    if (!Array.isArray(projects) || projects.length === 0) {
+      return projects || []
     }
-    return statusMap[status] || status
+
+    try {
+      const counts = await Promise.all(projects.map(project => this.getProjectRatingCount(project.id)))
+      return projects.map((project, index) => ({
+        ...project,
+        ratingCount: counts[index]
+      }))
+    } catch (error) {
+      console.error('鎵归噺鑾峰彇璇勫娆℃暟澶辫触:', error)
+      return projects.map(project => ({
+        ...project,
+        ratingCount: typeof project.ratingCount === 'number' ? project.ratingCount : 0
+      }))
+    }
   },
 
-  // 鑾峰彇鐘舵�佺被鍨�
-  getStatusType(status) {
-    const typeMap = {
-      'SUBMITTED': 'info',
-      'UNDER_REVIEW': 'warning',
-      'REVIEWED': 'success',
-      'REJECTED': 'danger'
+  async getProjectRatingCount(activityPlayerId) {
+    if (!activityPlayerId) {
+      return 0
     }
-    return typeMap[status] || 'info'
+
+    try {
+      const result = await graphqlRequest(GET_RATING_STATS_QUERY, { activityPlayerId })
+      const ratings = result?.judgeRatingsForPlayer || []
+      return ratings.filter(item => item?.hasRated).length
+    } catch (error) {
+      console.error(`鑾峰彇椤圭洰 ${activityPlayerId} 鐨勮瘎瀹℃鏁板け璐�:`, error)
+      return 0
+    }
   },
 
   // 鑾峰彇绌虹姸鎬佹枃鏈�
@@ -323,4 +363,4 @@
     ]
     return emptyDescs[currentTab] || ''
   }
-})
\ No newline at end of file
+})

--
Gitblit v1.8.0