From afeeed281e60466b576fbe74d339634cc5d07b82 Mon Sep 17 00:00:00 2001 From: Codex Assistant <codex@example.com> Date: 星期三, 08 十月 2025 08:56:42 +0800 Subject: [PATCH] 修复评审功能和用户认证问题 --- wx/pages/review/index.js | 124 ++++++++++++++++++----------------------- 1 files changed, 55 insertions(+), 69 deletions(-) diff --git a/wx/pages/review/index.js b/wx/pages/review/index.js index 3a9dd0e..cc40350 100644 --- a/wx/pages/review/index.js +++ b/wx/pages/review/index.js @@ -2,14 +2,6 @@ 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, @@ -63,7 +55,7 @@ // 鍒囨崲閫夐」鍗� switchTab(e) { - const index = parseInt(e.currentTarget.dataset.index) || 0 + const index = parseInt(e.currentTarget.dataset.index) // 灏嗗瓧绗︿覆杞崲涓烘暟瀛� if (index === this.data.currentTab) return this.setData({ @@ -118,29 +110,10 @@ ]) } catch (error) { console.error('鍔犺浇鏁版嵁澶辫触:', error) - - // 妫�鏌ユ槸鍚︽槸璁よ瘉鐩稿叧閿欒 - 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' - }) - } + wx.showToast({ + title: '鍔犺浇澶辫触', + icon: 'none' + }) } finally { this.setData({ loading: false }) wx.stopPullDownRefresh() @@ -174,7 +147,7 @@ } // 鏍规嵁褰撳墠閫夐」鍗℃瀯寤轰笉鍚岀殑鏌ヨ - switch (currentTab) { + switch (parseInt(currentTab)) { // 纭繚currentTab鏄暟瀛� case 0: // 鎴戞湭璇勫 query = ` query GetUnReviewedProjects($page: Int!, $pageSize: Int!, $searchKeyword: String) { @@ -234,13 +207,39 @@ } ` break + default: + console.error('鏃犳晥鐨勯�夐」鍗$储寮�:', currentTab) + query = ` + query GetUnReviewedProjects($page: Int!, $pageSize: Int!, $searchKeyword: String) { + unReviewedProjects(page: $page, pageSize: $pageSize, searchKeyword: $searchKeyword) { + items { + id + projectName + activityName + stageName + studentName + submitTime + status + } + total + hasMore + } + } + ` + break + } + + // 妫�鏌uery鏄惁涓虹┖ + if (!query || query.trim() === '') { + console.error('GraphQL鏌ヨ涓虹┖锛屾棤娉曟墽琛岃姹�') + return } const result = await graphqlRequest(query, variables) if (result) { - const dataKey = currentTab === 0 ? 'unReviewedProjects' : - currentTab === 1 ? 'reviewedProjects' : + const dataKey = parseInt(currentTab) === 0 ? 'unReviewedProjects' : + parseInt(currentTab) === 1 ? 'reviewedProjects' : 'studentUnReviewedProjects' const data = result[dataKey] @@ -250,13 +249,13 @@ const projects = data.items.map(item => ({ ...item, submitTime: item.submitTime ? formatDate(item.submitTime) : '', - reviewTime: item.reviewTime ? formatDate(item.reviewTime) : '' + reviewTime: item.reviewTime ? formatDate(item.reviewTime) : '', + statusText: this.getStatusText(item.status), + statusType: this.getStatusType(item.status) })) - const projectsWithRatingCount = await this.enrichProjectsWithRatingCounts(projects) - this.setData({ - projectList: isLoadMore ? [...this.data.projectList, ...projectsWithRatingCount] : projectsWithRatingCount, + projectList: isLoadMore ? [...this.data.projectList, ...projects] : projects, hasMore: data.hasMore || false, currentPage: variables.page }) @@ -301,39 +300,26 @@ } }, - async enrichProjectsWithRatingCounts(projects) { - if (!Array.isArray(projects) || projects.length === 0) { - return projects || [] + // 鑾峰彇鐘舵�佹枃鏈� + getStatusText(status) { + const statusMap = { + 'SUBMITTED': '宸叉彁浜�', + 'UNDER_REVIEW': '璇勫涓�', + 'REVIEWED': '宸茶瘎瀹�', + 'REJECTED': '宸叉嫆缁�' } - - 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 - })) - } + return statusMap[status] || status }, - async getProjectRatingCount(activityPlayerId) { - if (!activityPlayerId) { - return 0 + // 鑾峰彇鐘舵�佺被鍨� + getStatusType(status) { + const typeMap = { + 'SUBMITTED': 'info', + 'UNDER_REVIEW': 'warning', + 'REVIEWED': 'success', + 'REJECTED': 'danger' } - - 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 - } + return typeMap[status] || 'info' }, // 鑾峰彇绌虹姸鎬佹枃鏈� @@ -363,4 +349,4 @@ ] return emptyDescs[currentTab] || '' } -}) +}) \ No newline at end of file -- Gitblit v1.8.0