From 3714621173c606c4c58439ed8941100ce9ddea14 Mon Sep 17 00:00:00 2001
From: Codex Assistant <codex@example.com>
Date: 星期三, 05 十一月 2025 15:10:49 +0800
Subject: [PATCH] bug

---
 wx/pages/judge/review.js |  420 ++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 268 insertions(+), 152 deletions(-)

diff --git a/wx/pages/judge/review.js b/wx/pages/judge/review.js
index babef8a..112e080 100644
--- a/wx/pages/judge/review.js
+++ b/wx/pages/judge/review.js
@@ -9,7 +9,7 @@
     
     // 鎻愪氦浣滃搧淇℃伅
     submission: null,
-    submissionId: '',
+    activityPlayerId: '',
     
     // 娲诲姩淇℃伅
     activity: null,
@@ -53,7 +53,7 @@
 
   onLoad(options) {
     if (options.id) {
-      this.setData({ submissionId: options.id })
+      this.setData({ activityPlayerId: options.id })
       this.loadSubmissionDetail()
     }
   },
@@ -71,99 +71,148 @@
       this.setData({ loading: true })
       
       const query = `
-        query GetSubmissionDetail($id: ID!) {
-          submission(id: $id) {
+        query GetActivityPlayerDetail($id: ID!) {
+          activityPlayerDetail(id: $id) {
             id
-            title
+            projectName
             description
-            files {
+            activityName
+            stageId
+            state
+            playerInfo {
+              id
+              name
+              phone
+              gender
+              birthday
+              education
+              introduction
+              userInfo {
+                userId
+                name
+                phone
+                avatarUrl
+              }
+            }
+            regionInfo {
+              id
+              name
+              fullPath
+            }
+            submissionFiles {
               id
               name
               url
-              type
-              size
+              fullUrl
+              fileExt
+              fileSize
+              mediaType
+              thumbUrl
+              fullThumbUrl
             }
-            images
-            videos
-            submittedAt
-            status
-            participant {
-              id
-              name
-              school
-              major
-              avatar
-            }
-            team {
-              id
-              name
-              members {
+            ratingForm {
+              schemeId
+              schemeName
+              totalMaxScore
+              items {
                 id
                 name
-                role
-              }
-            }
-            activity {
-              id
-              title
-              description
-              judgeCriteria {
-                id
-                name
-                description
                 maxScore
-                weight
+                orderNo
               }
-            }
-            myReview {
-              id
-              scores
-              comment
-              totalScore
-              status
-              reviewedAt
             }
           }
         }
       `
       
-      const result = await graphqlRequest(query, { id: this.data.submissionId })
+      const result = await graphqlRequest(query, { id: this.data.activityPlayerId })
       
-      if (result && result.submission) {
-        const submission = result.submission
+      if (result && result.activityPlayerDetail) {
+        const detail = result.activityPlayerDetail
         
-        // 涓烘瘡涓枃浠舵坊鍔犱笅杞界姸鎬�
-        if (submission.files) {
-          submission.files = submission.files.map(file => ({
-            ...file,
+        // 鏋勫缓submission瀵硅薄浠ュ吋瀹圭幇鏈夌殑WXML妯℃澘
+        const submission = {
+          id: detail.id,
+          title: detail.projectName,
+          description: detail.description,
+          files: detail.submissionFiles ? detail.submissionFiles.map(file => ({
+            id: file.id,
+            name: file.name,
+            url: file.fullUrl || file.url,
+            type: file.fileExt,
+            size: file.fileSize,
             isDownloading: this.data.downloadingFiles.indexOf(file.id) > -1
-          }))
+          })) : [],
+          images: detail.submissionFiles ? detail.submissionFiles
+            .filter(file => file.mediaType === 1)
+            .map(file => file.fullUrl || file.url) : [],
+          videos: detail.submissionFiles ? detail.submissionFiles
+            .filter(file => file.mediaType === 2)
+            .map(file => file.fullUrl || file.url) : [],
+          mediaList: (detail.submissionFiles || []).map(file => {
+            const mt = file.mediaType
+            let typeStr = ''
+            if (mt === 1 || mt === 'image' || (typeof mt === 'string' && mt.startsWith('image'))) typeStr = 'image'
+            else if (mt === 2 || mt === 'video' || (typeof mt === 'string' && mt.startsWith('video'))) typeStr = 'video'
+            else if ((file.fileExt || '').toLowerCase().includes('pdf')) typeStr = 'pdf'
+            else if ((file.fileExt || '').toLowerCase().includes('doc')) typeStr = 'word'
+            else typeStr = 'file'
+            return {
+              id: file.id,
+              name: file.name,
+              size: file.fileSize,
+              mediaType: typeStr,
+              thumbUrl: file.fullThumbUrl || file.thumbUrl || file.fullUrl || file.url,
+              url: file.fullUrl || file.url
+            }
+          }),
+          participant: {
+            id: detail.playerInfo.id,
+            name: detail.playerInfo.name,
+            phone: detail.playerInfo.phone || '',
+            gender: this.getGenderText(detail.playerInfo.gender),
+            birthday: detail.playerInfo.birthday || '',
+            region: detail.regionInfo ? detail.regionInfo.name : '',
+            education: detail.playerInfo.education || '',
+            avatar: detail.playerInfo.userInfo?.avatarUrl || '/images/default-avatar.svg'
+          },
+          status: detail.state === 1 ? 'APPROVED' : detail.state === 2 ? 'REJECTED' : 'PENDING'
+        }
+        
+        // 鏋勫缓activity瀵硅薄
+        const activity = {
+          id: detail.stageId,
+          title: detail.activityName,
+          description: detail.description,
+          judgeCriteria: detail.ratingForm ? detail.ratingForm.items || [] : []
         }
         
         // 鍒濆鍖栬瘎鍒嗘暟鎹�
         const scores = {}
         let maxScore = 0
         
-        if (submission.activity.judgeCriteria) {
-          submission.activity.judgeCriteria.forEach(criterion => {
-            scores[criterion.id] = submission.myReview ? 
-              submission.myReview.scores[criterion.id] || 0 : 0
+        if (activity.judgeCriteria) {
+          activity.judgeCriteria.forEach(criterion => {
+            scores[criterion.id] = 0 // 鏆傛椂璁句负0锛屽悗缁渶瑕佹煡璇㈠凡鏈夎瘎鍒�
             maxScore += criterion.maxScore
           })
         }
         
         this.setData({
           submission,
-          activity: submission.activity,
-          criteria: submission.activity.judgeCriteria || [],
+          activity,
+          criteria: activity.judgeCriteria || [],
           scores,
           maxScore,
-          existingReview: submission.myReview,
-          reviewStatus: submission.myReview ? submission.myReview.status : 'PENDING',
-          comment: submission.myReview ? submission.myReview.comment : ''
+          existingReview: null, // 鏆傛椂璁句负null锛屽悗缁渶瑕佹煡璇㈠凡鏈夎瘎鍒�
+          reviewStatus: 'PENDING',
+          comment: ''
         })
         
         this.calculateTotalScore()
+        
+        // 妫�鏌ユ槸鍚﹀凡鏈夎瘎鍒�
+        this.checkReviewStatus()
       }
     } catch (error) {
       console.error('鍔犺浇浣滃搧璇︽儏澶辫触:', error)
@@ -180,30 +229,50 @@
   async checkReviewStatus() {
     try {
       const query = `
-        query CheckReviewStatus($submissionId: ID!) {
-          reviewStatus(submissionId: $submissionId) {
+        query GetCurrentJudgeRating($activityPlayerId: ID!) {
+          currentJudgeRating(activityPlayerId: $activityPlayerId) {
+            id
+            totalScore
+            remark
             status
-            canReview
-            deadline
+            ratedAt
+            items {
+              ratingItemId
+              ratingItemName
+              score
+              weightedScore
+            }
           }
         }
       `
       
-      const result = await graphqlRequest(query, { submissionId: this.data.submissionId })
+      const result = await graphqlRequest(query, { activityPlayerId: this.data.activityPlayerId })
       
-      if (result && result.reviewStatus) {
-        const { status, canReview, deadline } = result.reviewStatus
+      if (result && result.currentJudgeRating) {
+        const rating = result.currentJudgeRating
         
-        if (!canReview) {
-          wx.showModal({
-            title: '鏃犳硶璇勫',
-            content: deadline ? `璇勫宸叉埅姝紙鎴鏃堕棿锛�${formatDate(deadline)}锛塦 : '褰撳墠鏃犳硶杩涜璇勫',
-            showCancel: false,
-            success: () => {
-              wx.navigateBack()
-            }
+        // 濡傛灉宸叉湁璇勫垎锛屽~鍏呮暟鎹�
+        const scores = {}
+        let totalScore = 0
+        
+        if (rating.items) {
+          rating.items.forEach(item => {
+            scores[item.ratingItemId] = item.score
+            totalScore += item.score
           })
         }
+        
+        this.setData({
+          scores,
+          totalScore,
+          comment: rating.remark || '',
+          existingReview: rating,
+          reviewStatus: rating.status || 'COMPLETED'
+        })
+        
+        console.log('宸插姞杞界幇鏈夎瘎鍒�:', rating)
+      } else {
+        console.log('褰撳墠璇勫灏氭湭璇勫垎')
       }
     } catch (error) {
       console.error('妫�鏌ヨ瘎瀹$姸鎬佸け璐�:', error)
@@ -229,7 +298,7 @@
     
     criteria.forEach(criterion => {
       const score = scores[criterion.id] || 0
-      totalScore += score * (criterion.weight || 1)
+      totalScore += score
     })
     
     this.setData({ totalScore })
@@ -242,20 +311,39 @@
     })
   },
 
-  // 濯掍綋鐐瑰嚮
+  // 濯掍綋鐐瑰嚮锛堥�氳繃 index 瀹氫綅 mediaList 椤癸級
   onMediaTap(e) {
-    const { url, type } = e.currentTarget.dataset
-    
-    if (type === 'image') {
+    const { index } = e.currentTarget.dataset
+    const item = this.data.submission?.mediaList?.[index]
+    if (!item) return
+    if (item.mediaType === 'image') {
+      const imgs = (this.data.submission.mediaList || [])
+        .filter(it => it.mediaType === 'image')
+        .map(it => it.url)
       wx.previewImage({
-        current: url,
-        urls: this.data.submission.images || []
+        current: item.url,
+        urls: imgs.length ? imgs : [item.url]
       })
-    } else if (type === 'video') {
+    } else if (item.mediaType === 'video') {
       this.setData({
         showMediaPreview: true,
-        currentMedia: url,
+        currentMedia: item.url,
         mediaType: 'video'
+      })
+    } else {
+      wx.downloadFile({
+        url: item.url,
+        success: (res) => {
+          if (res.statusCode === 200) {
+            wx.openDocument({
+              filePath: res.tempFilePath,
+              showMenu: true
+            })
+          } else {
+            wx.showToast({ title: '棰勮澶辫触', icon: 'none' })
+          }
+        },
+        fail: () => wx.showToast({ title: '涓嬭浇澶辫触', icon: 'none' })
       })
     }
   },
@@ -266,6 +354,44 @@
       showMediaPreview: false,
       currentMedia: null
     })
+  },
+
+  // 鐐瑰嚮棰勮鎸夐挳锛氬浘鐗�/瑙嗛鐢� wx.previewMedia锛屾枃妗g敤 openDocument
+  onPreviewTap(e) {
+    const { index } = e.currentTarget.dataset
+    const list = this.data.submission?.mediaList || []
+    const item = list[index]
+    if (!item) return
+
+    if (item.mediaType === 'image' || item.mediaType === 'video') {
+      const mediaList = list
+        .filter(m => m.mediaType === 'image' || m.mediaType === 'video')
+        .map(m => ({
+          url: m.url,
+          type: m.mediaType === 'video' ? 'video' : 'image',
+          poster: m.thumbUrl || m.url
+        }))
+      const current = Math.max(0, mediaList.findIndex(m => m.url === item.url))
+      wx.previewMedia({
+        sources: mediaList,
+        current
+      })
+    } else {
+      wx.downloadFile({
+        url: item.url,
+        success: (res) => {
+          if (res.statusCode === 200) {
+            wx.openDocument({
+              filePath: res.tempFilePath,
+              showMenu: true
+            })
+          } else {
+            wx.showToast({ title: '棰勮澶辫触', icon: 'none' })
+          }
+        },
+        fail: () => wx.showToast({ title: '涓嬭浇澶辫触', icon: 'none' })
+      })
+    }
   },
 
   // 涓嬭浇鏂囦欢
@@ -371,15 +497,7 @@
       })
       return false
     }
-    
-    if (comment.trim().length < 10) {
-      wx.showToast({
-        title: '璇勫鎰忚鑷冲皯10涓瓧绗�',
-        icon: 'error'
-      })
-      return false
-    }
-    
+  
     return true
   },
 
@@ -388,34 +506,37 @@
     try {
       wx.showLoading({ title: '淇濆瓨涓�...' })
       
-      const { submissionId, scores, comment, totalScore } = this.data
+      const { activityPlayerId, scores, comment, criteria, activity } = this.data
+      
+      // 鏋勫缓璇勫垎椤规暟缁�
+      const ratings = criteria.map(criterion => ({
+        itemId: parseInt(criterion.id),
+        score: parseFloat(scores[criterion.id] || 0)
+      }))
       
       const mutation = `
-        mutation SaveReviewDraft($input: ReviewDraftInput!) {
-          saveReviewDraft(input: $input) {
-            success
-            review {
-              id
-              status
-            }
-          }
+        mutation SaveActivityPlayerRating($input: ActivityPlayerRatingInput!) {
+          saveActivityPlayerRating(input: $input)
         }
       `
       
       const input = {
-        submissionId,
-        scores,
-        comment: comment.trim(),
-        totalScore
+        activityPlayerId: parseInt(activityPlayerId),
+        stageId: parseInt(activity.id),
+        ratings,
+        comment: comment.trim()
       }
       
       const result = await graphqlRequest(mutation, { input })
       
-      if (result && result.saveReviewDraft.success) {
+      if (result && result.saveActivityPlayerRating) {
         wx.showToast({
           title: '鑽夌宸蹭繚瀛�',
           icon: 'success'
         })
+        
+        // 閲嶆柊鍔犺浇璇勫垎鐘舵��
+        await this.checkReviewStatus()
       }
     } catch (error) {
       console.error('淇濆瓨鑽夌澶辫触:', error)
@@ -451,41 +572,42 @@
       this.setData({ submitting: true })
       wx.showLoading({ title: '鎻愪氦涓�...' })
       
-      const { submissionId, scores, comment, totalScore } = this.data
+      const { activityPlayerId, scores, comment, criteria, activity } = this.data
+      
+      // 鏋勫缓璇勫垎椤规暟缁�
+      const ratings = criteria.map(criterion => ({
+        itemId: criterion.id,
+        score: scores[criterion.id] || 0
+      }))
       
       const mutation = `
-        mutation SubmitReview($input: ReviewSubmitInput!) {
-          submitReview(input: $input) {
-            success
-            review {
-              id
-              status
-              reviewedAt
-            }
-          }
+        mutation SaveActivityPlayerRating($input: ActivityPlayerRatingInput!) {
+          saveActivityPlayerRating(input: $input)
         }
       `
       
       const input = {
-        submissionId,
-        scores,
-        comment: comment.trim(),
-        totalScore
+        activityPlayerId,
+        stageId: activity.id,
+        ratings,
+        comment: comment.trim()
       }
       
       const result = await graphqlRequest(mutation, { input })
       
-      if (result && result.submitReview.success) {
+      if (result && result.saveActivityPlayerRating) {
         wx.showToast({
-          title: '璇勫鎻愪氦鎴愬姛',
+          title: '璇勫垎鎻愪氦鎴愬姛',
           icon: 'success'
         })
         
         // 鏇存柊鐘舵��
         this.setData({
-          reviewStatus: 'COMPLETED',
-          existingReview: result.submitReview.review
+          reviewStatus: 'COMPLETED'
         })
+        
+        // 閲嶆柊鍔犺浇璇勫垎鐘舵��
+        await this.checkReviewStatus()
         
         // 寤惰繜杩斿洖涓婁竴椤�
         setTimeout(() => {
@@ -493,7 +615,7 @@
         }, 1500)
       }
     } catch (error) {
-      console.error('鎻愪氦璇勫澶辫触:', error)
+      console.error('鎻愪氦璇勫垎澶辫触:', error)
       wx.showToast({
         title: '鎻愪氦澶辫触',
         icon: 'error'
@@ -504,37 +626,24 @@
     }
   },
 
-  // 鏌ョ湅鍏朵粬璇勫
+  // 鏌ョ湅鍏朵粬璇勫 - 宸查殣钘忓姛鑳�
+  /*
   onViewOtherReviews() {
     wx.navigateTo({
-      url: `/pages/judge/reviews?submissionId=${this.data.submissionId}`
+      url: `/pages/judge/reviews?activityPlayerId=${this.data.activityPlayerId}`
     })
   },
+  */
 
-  // 鑱旂郴鍙傝禌鑰�
+  // 鑱旂郴鍙傝禌鑰咃細鐩存帴鎷ㄦ墦鐢佃瘽
   onContactParticipant() {
-    const { submission } = this.data
-    
-    if (submission.participant) {
-      wx.showActionSheet({
-        itemList: ['鍙戦�佹秷鎭�', '鏌ョ湅璇︽儏'],
-        success: (res) => {
-          switch (res.tapIndex) {
-            case 0:
-              // 鍙戦�佹秷鎭姛鑳�
-              wx.navigateTo({
-                url: `/pages/chat/chat?userId=${submission.participant.id}`
-              })
-              break
-            case 1:
-              // 鏌ョ湅鐢ㄦ埛璇︽儏
-              wx.navigateTo({
-                url: `/pages/user/profile?userId=${submission.participant.id}`
-              })
-              break
-          }
-        }
-      })
+    const phone =
+      this.data.submission?.participant?.phone ||
+      this.data.submission?.participant?.userInfo?.phone
+    if (phone) {
+      wx.makePhoneCall({ phoneNumber: String(phone) })
+    } else {
+      wx.showToast({ title: '鏃犺仈绯荤數璇�', icon: 'none' })
     }
   },
 
@@ -555,6 +664,13 @@
     }
   },
 
+  // 鎬у埆杞崲鍑芥暟
+  getGenderText(gender) {
+    if (gender === 0) return '鐢�'
+    if (gender === 1) return '濂�'
+    return '鏈~鍐�'
+  },
+
   // 鏍煎紡鍖栨棩鏈�
   formatDate(dateString) {
     return formatDate(dateString, 'YYYY-MM-DD HH:mm')
@@ -563,7 +679,7 @@
   // 鍒嗕韩椤甸潰
   onShareAppMessage() {
     return {
-      title: '钃夋槗鍒� - 璇勫浣滃搧',
+      title: '钃塭鍒� - 璇勫浣滃搧',
       path: '/pages/index/index'
     }
   }

--
Gitblit v1.8.0