From 58d9f460b2f8c34430285115e2557d18333c5cab Mon Sep 17 00:00:00 2001
From: Codex Assistant <codex@example.com>
Date: 星期三, 08 十月 2025 14:16:55 +0800
Subject: [PATCH] feat: 修复Player实体phone字段数据冗余问题并优化小程序报名逻辑

---
 wx/pages/registration/registration.js |  456 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 414 insertions(+), 42 deletions(-)

diff --git a/wx/pages/registration/registration.js b/wx/pages/registration/registration.js
index 6de900a..e1613f8 100644
--- a/wx/pages/registration/registration.js
+++ b/wx/pages/registration/registration.js
@@ -9,6 +9,10 @@
     activityId: '',
     activity: null,
     loading: false,
+    userInfo: null, // 褰撳墠鐢ㄦ埛淇℃伅
+    // 鎶ュ悕鐘舵�佹帶鍒�
+    submitDisabled: false,
+    submitText: '鎻愪氦鎶ュ悕',
     
     // 琛ㄥ崟鏁版嵁
     formData: {
@@ -97,16 +101,30 @@
       this.setData({
         activityId: activityId
       })
+      // 浼樺厛妫�鏌ユ姤鍚嶇姸鎬�
+      this.checkRegistrationStatus(activityId)
+      // 鍔犺浇娲诲姩淇℃伅
       this.loadActivityInfo()
     } else {
       console.log('鉂� 娌℃湁鎺ユ敹鍒癮ctivityId鍙傛暟')
     }
+    
+    // 鍔犺浇鐢ㄦ埛淇℃伅
+    this.loadUserInfo()
     
     // 浠庡叏灞�鏁版嵁鑾峰彇鐢ㄦ埛淇℃伅棰勫~鍏�
     this.prefillUserInfo()
     
     // 鍔犺浇鍖哄煙鏁版嵁
     this.loadRegions()
+  },
+
+  onShow() {
+    // 杩斿洖鏈〉鏃跺埛鏂版姤鍚嶇姸鎬�
+    const { activityId } = this.data
+    if (activityId) {
+      this.checkRegistrationStatus(activityId)
+    }
   },
 
   // 鍔犺浇娲诲姩淇℃伅
@@ -210,15 +228,121 @@
     }
   },
 
+  // 鍔犺浇鐢ㄦ埛淇℃伅
+  async loadUserInfo() {
+    console.log('馃攧 寮�濮嬪姞杞界敤鎴蜂俊鎭�')
+    const app = getApp()
+    let userInfo = app.globalData.userInfo
+    console.log('馃攳 鏈湴鐢ㄦ埛鏁版嵁:', JSON.stringify(userInfo, null, 2))
+    
+    // 灏濊瘯浠庡悗绔幏鍙栧畬鏁寸殑鐢ㄦ埛淇℃伅
+    try {
+      const query = `
+        query GetUserProfile {
+          userProfile {
+            id
+            name
+            avatar
+            phone
+            gender
+            birthday
+          }
+        }
+      `
+      
+      const result = await graphqlRequest(query)
+      if (result && result.userProfile) {
+        console.log('馃攳 浠庡悗绔幏鍙栫殑瀹屾暣鐢ㄦ埛鏁版嵁:', JSON.stringify(result.userProfile, null, 2))
+        userInfo = result.userProfile
+        // 鏇存柊鍏ㄥ眬鏁版嵁
+        app.globalData.userInfo = { ...app.globalData.userInfo, ...userInfo }
+      }
+    } catch (error) {
+      console.log('鈿狅笍 浠庡悗绔幏鍙栫敤鎴蜂俊鎭け璐ワ紝浣跨敤鏈湴鏁版嵁:', error)
+    }
+    
+    if (userInfo) {
+      let displayUserInfo = {
+        name: userInfo.name || '',
+        phone: userInfo.phone || '',
+        avatarUrl: userInfo.avatar || userInfo.avatarUrl || '',
+        gender: null,
+        education: '',
+        birthDate: ''
+      }
+      
+      // 澶勭悊鎬у埆淇℃伅
+      if (userInfo.gender !== undefined && userInfo.gender !== null) {
+        console.log('馃懁 鍙戠幇鎬у埆瀛楁:', userInfo.gender, '绫诲瀷:', typeof userInfo.gender)
+        // 濡傛灉鏄瓧绗︿覆鏍煎紡锛岃浆鎹负鏁板瓧
+        if (typeof userInfo.gender === 'string') {
+          displayUserInfo.gender = userInfo.gender === 'MALE' ? 1 : 0  // 淇锛歁ALE=1(鐢�), FEMALE=0(濂�)
+          console.log('馃懁 澶勭悊鍚庣殑鎬у埆:', displayUserInfo.gender)
+        } else {
+          displayUserInfo.gender = parseInt(userInfo.gender)
+        }
+      }
+      
+      // 澶勭悊鐢熸棩淇℃伅
+      if (userInfo.birthday || userInfo.birthDate) {
+        displayUserInfo.birthDate = userInfo.birthday || userInfo.birthDate
+        console.log('馃巶 鍙戠幇鐢熸棩瀛楁:', displayUserInfo.birthDate)
+      }
+      
+      this.setData({
+        displayUserInfo: displayUserInfo
+      })
+      
+      console.log('鉁� 鏈�缁� displayUserInfo:', JSON.stringify(displayUserInfo, null, 2))
+    } else {
+      console.log('鈿狅笍 鏈壘鍒扮敤鎴蜂俊鎭�')
+    }
+  },
+
   // 棰勫~鍏呯敤鎴蜂俊鎭�
   prefillUserInfo() {
+    const app = getApp()
     const userInfo = app.globalData.userInfo
+    console.log('馃攳 棰勫~鍏呯敤鎴蜂俊鎭�:', userInfo)
+    
     if (userInfo) {
-      this.setData({
+      const updateData = {
         'formData.name': userInfo.name || '',
         'formData.phone': userInfo.phone || '',
-        'formData.email': userInfo.email || ''
-      })
+        'formData.email': userInfo.email || '',
+        'formData.avatarUrl': userInfo.avatar || userInfo.avatarUrl || ''
+      }
+      
+      // 澶勭悊鎬у埆淇℃伅 - 鐩存帴浠巙serInfo鑾峰彇
+      if (userInfo.gender !== undefined && userInfo.gender !== null) {
+        let genderValue, genderIndex
+        // 濡傛灉鏄瓧绗︿覆鏍煎紡锛岃浆鎹负鏁板瓧
+        if (typeof userInfo.gender === 'string') {
+          genderValue = userInfo.gender === 'MALE' ? 1 : 0  // 淇锛歁ALE=1(鐢�), FEMALE=0(濂�)
+          genderIndex = userInfo.gender === 'MALE' ? 0 : 1  // 鐣岄潰绱㈠紩锛�0=鐢凤紝1=濂�
+        } else {
+          genderValue = parseInt(userInfo.gender)
+          genderIndex = genderValue === 1 ? 0 : 1  // 鏁版嵁搴撳��1(鐢�)->鐣岄潰绱㈠紩0锛屾暟鎹簱鍊�0(濂�)->鐣岄潰绱㈠紩1
+        }
+        updateData['formData.gender'] = genderValue
+        updateData['genderIndex'] = genderIndex
+        console.log('馃懁 璁剧疆鎬у埆:', genderValue === 1 ? '鐢�' : '濂�', '鐣岄潰绱㈠紩:', genderIndex)
+      }
+      
+      // 澶勭悊鐢熸棩淇℃伅 - 鐩存帴浠巙serInfo鑾峰彇
+      if (userInfo.birthday || userInfo.birthDate) {
+        const birthDate = userInfo.birthday || userInfo.birthDate
+        updateData['formData.birthDate'] = birthDate
+        console.log('馃巶 璁剧疆鐢熸棩:', birthDate)
+      }
+      
+      console.log('鉁� 棰勫~鍏呮暟鎹�:', updateData)
+      console.log('馃柤锔� 璁剧疆澶村儚URL:', updateData['formData.avatarUrl'])
+      
+      this.setData(updateData)
+      console.log('鉁� 鐢ㄦ埛淇℃伅棰勫~鍏呭畬鎴�')
+    } else {
+      console.log('鈿狅笍 鏈壘鍒扮敤鎴蜂俊鎭紝璺宠繃棰勫~鍏�')
     }
   },
 
@@ -255,9 +379,11 @@
   // 鎬у埆閫夋嫨
   onGenderChange(e) {
     const index = e.detail.value
+    // 淇鎬у埆鏄犲皠锛歡enderOptions[0]='鐢�' 搴旇瀵瑰簲鏁版嵁搴撳��1锛実enderOptions[1]='濂�' 搴旇瀵瑰簲鏁版嵁搴撳��0
+    const genderValue = index === 0 ? 1 : 0  // 0(鐢�) -> 1, 1(濂�) -> 0
     this.setData({
       genderIndex: index,
-      'formData.gender': index
+      'formData.gender': genderValue
     })
   },
 
@@ -649,18 +775,21 @@
         this.setData({ attachments: updatedAttachments })
         
         try {
-          const uploadResult = await cosUtil.uploadFile(attachment.path, {
-            onProgress: (progress) => {
+          const uploadResult = await cosUtil.uploadFile(
+            attachment.path,
+            'attachment',
+            attachment.name || 'attachment',
+            (percent) => {
               // 鏇存柊涓婁紶杩涘害
               const progressAttachments = this.data.attachments.map(item => {
                 if (item.id === attachment.id) {
-                  return { ...item, progress: Math.round(progress.percent) }
+                  return { ...item, progress: Math.round(percent) }
                 }
                 return item
               })
               this.setData({ attachments: progressAttachments })
             }
-          })
+          )
           
           // 涓婁紶鎴愬姛
           const successAttachments = this.data.attachments.map(item => {
@@ -749,6 +878,149 @@
       wx.hideLoading()
       wx.showToast({
         title: '鍒犻櫎澶辫触',
+        icon: 'error'
+      })
+    }
+  },
+
+  // 棰勮闄勪欢
+  async onPreviewAttachment(e) {
+    try {
+      const index = e.currentTarget.dataset.index
+      const attachment = this.data.attachments[index]
+
+      if (!attachment.uploaded || !attachment.url) {
+        wx.showToast({
+          title: '鏂囦欢鏈笂浼犲畬鎴�',
+          icon: 'none'
+        })
+        return
+      }
+
+      const fileType = attachment.type
+
+      if (fileType === 'image') {
+        // 棰勮鍥剧墖 (media_type = 1)
+        wx.previewImage({
+          current: attachment.url,
+          urls: [attachment.url]
+        })
+      } else if (fileType === 'video') {
+        // 鎾斁瑙嗛 (media_type = 2) - 璺宠浆鍒拌棰戞挱鏀鹃〉闈�
+        wx.navigateTo({
+          url: `/pages/video/video?url=${encodeURIComponent(attachment.url)}&title=${encodeURIComponent(attachment.name)}`
+        })
+      } else if (fileType === 'pdf') {
+        // PDF鏂囦欢 (media_type = 4) - 浣跨敤灏忕▼搴忓唴缃殑鏂囨。棰勮
+        wx.showLoading({
+          title: '姝e湪鎵撳紑...',
+          mask: true
+        })
+        
+        wx.downloadFile({
+          url: attachment.url,
+          success: (res) => {
+            wx.hideLoading()
+            if (res.statusCode === 200) {
+              wx.openDocument({
+                filePath: res.tempFilePath,
+                fileType: 'pdf',
+                success: () => {
+                  console.log('PDF鎵撳紑鎴愬姛')
+                },
+                fail: (err) => {
+                  console.error('PDF鎵撳紑澶辫触:', err)
+                  wx.showToast({
+                    title: 'PDF鎵撳紑澶辫触',
+                    icon: 'none'
+                  })
+                }
+              })
+            } else {
+              wx.showToast({
+                title: '鏂囦欢涓嬭浇澶辫触',
+                icon: 'none'
+              })
+            }
+          },
+          fail: (err) => {
+            wx.hideLoading()
+            console.error('PDF涓嬭浇澶辫触:', err)
+            wx.showToast({
+              title: '鏂囦欢涓嬭浇澶辫触',
+              icon: 'none'
+            })
+          }
+        })
+      } else if (fileType === 'word' || fileType === 'excel' || fileType === 'ppt') {
+        // Office鏂囨。 (media_type = 4) - 浣跨敤灏忕▼搴忓唴缃殑鏂囨。棰勮
+        wx.showLoading({
+          title: '姝e湪鎵撳紑...',
+          mask: true
+        })
+        
+        wx.downloadFile({
+          url: attachment.url,
+          success: (res) => {
+            wx.hideLoading()
+            if (res.statusCode === 200) {
+              // 鏍规嵁瀹為檯鏂囦欢鎵╁睍鍚嶇‘瀹氭枃浠剁被鍨�
+              const fileName = attachment.name || ''
+              const fileExt = fileName.split('.').pop().toLowerCase()
+              const fileTypeMap = {
+                'doc': 'doc',
+                'docx': 'docx',
+                'xls': 'xls',
+                'xlsx': 'xlsx',
+                'ppt': 'ppt',
+                'pptx': 'pptx'
+              }
+              
+              wx.openDocument({
+                filePath: res.tempFilePath,
+                fileType: fileTypeMap[fileExt] || 'doc',
+                success: () => {
+                  console.log('鏂囨。鎵撳紑鎴愬姛')
+                },
+                fail: (err) => {
+                  console.error('鏂囨。鎵撳紑澶辫触:', err)
+                  wx.showModal({
+                    title: '鎵撳紑澶辫触',
+                    content: '鏂囨。鎵撳紑澶辫触锛屽彲鑳芥槸鏂囦欢鏍煎紡涓嶆敮鎸佹垨鏂囦欢鎹熷潖',
+                    showCancel: false,
+                    confirmText: '纭畾'
+                  })
+                }
+              })
+            } else {
+              wx.showToast({
+                title: '鏂囦欢涓嬭浇澶辫触',
+                icon: 'none'
+              })
+            }
+          },
+          fail: (err) => {
+            wx.hideLoading()
+            console.error('鏂囨。涓嬭浇澶辫触:', err)
+            wx.showToast({
+              title: '鏂囦欢涓嬭浇澶辫触',
+              icon: 'none'
+            })
+          }
+        })
+      } else {
+        // 鍏朵粬鏂囦欢绫诲瀷 (media_type = 5) - 鎻愮ず鐢ㄦ埛
+        wx.showModal({
+          title: '鏂囦欢棰勮',
+          content: `鏆備笉鏀寔棰勮${fileType}绫诲瀷鐨勬枃浠讹紝璇蜂笅杞藉悗鏌ョ湅`,
+          showCancel: false,
+          confirmText: '鐭ラ亾浜�'
+        })
+      }
+    } catch (error) {
+      console.error('棰勮闄勪欢澶辫触:', error)
+      wx.showToast({
+        title: '棰勮澶辫触',
         icon: 'error'
       })
     }
@@ -862,8 +1134,8 @@
       errors.name = '璇疯緭鍏ュ鍚�';
     }
 
-    if (!formData.phone.trim()) {
-      errors.phone = '璇疯緭鍏ユ墜鏈哄彿';
+    if (!formData.phone || !formData.phone.trim()) {
+      errors.phone = '璇峰厛鎺堟潈鑾峰彇鎵嬫満鍙�';
     } else if (!/^1[3-9]\d{9}$/.test(formData.phone)) {
       errors.phone = '璇疯緭鍏ユ纭殑鎵嬫満鍙�';
     }
@@ -904,13 +1176,15 @@
       })
 
       // 涓婁紶鍒癈OS
-      const uploadResult = await cosUtil.uploadAvatar(this.data.localAvatarPath, {
-        onProgress: (progress) => {
-          this.setData({
-            avatarUploadProgress: Math.round(progress.percent)
-          })
-        }
-      })
+      const uploadResult = await cosUtil.uploadAvatar(
+         this.data.localAvatarPath,
+         'avatar.jpg',
+         (percent) => {
+           this.setData({
+             avatarUploadProgress: Math.round(percent)
+           })
+         }
+       )
 
       // 涓婁紶鎴愬姛锛屾洿鏂拌〃鍗曟暟鎹�
       this.setData({
@@ -949,12 +1223,31 @@
 
   async onSubmit() {
     if (this.data.isSubmitting) return
+    if (this.data.submitDisabled) {
+      // 绂佺敤鎬佺洿鎺ユ嫤鎴偣鍑�
+      wx.showToast({
+        title: this.data.submitText,
+        icon: 'none'
+      })
+      return
+    }
     
     // 琛ㄥ崟楠岃瘉
     if (!this.validateForm()) {
       wx.showToast({
         title: '璇锋鏌ヨ〃鍗曚俊鎭�',
         icon: 'none'
+      })
+      return
+    }
+
+    // 棰濆妫�鏌ワ細纭繚蹇呴』鎺堟潈鐢佃瘽鍙风爜
+    if (!this.data.formData.phone || !this.data.formData.phone.trim()) {
+      wx.showModal({
+        title: '闇�瑕佹巿鏉冩墜鏈哄彿',
+        content: '鏍规嵁骞冲彴瑙勫畾锛屽繀椤绘巿鏉冩墜鏈哄彿鐮佹墠鑳芥姤鍚嶅弬璧涖�傝鍏堣幏鍙栨墜鏈哄彿鐮佹巿鏉冦��',
+        showCancel: false,
+        confirmText: '鎴戠煡閬撲簡'
       })
       return
     }
@@ -995,6 +1288,16 @@
           userId: result.userId,
           activityPlayerId: result.activityPlayerId
         })
+        
+        // 绗笁姝ワ細鎶ュ悕鎴愬姛鍚庡己鍒惰皟鐢╳xlogin鑾峰彇鏂扮殑JWT token
+        console.log('馃摫 鎶ュ悕鎴愬姛锛屽紑濮嬪己鍒惰皟鐢╳xlogin鑾峰彇鏂扮殑JWT token')
+        try {
+          await app.wxLogin()
+          console.log('鉁� 鎶ュ悕鎴愬姛鍚巜xlogin璋冪敤鎴愬姛锛屽凡鑾峰彇鏂扮殑JWT token')
+        } catch (wxLoginError) {
+          console.error('鉂� 鎶ュ悕鎴愬姛鍚巜xlogin璋冪敤澶辫触:', wxLoginError)
+          // wxlogin澶辫触涓嶅奖鍝嶆姤鍚嶆垚鍔熺殑鎻愮ず锛屽彧璁板綍閿欒
+        }
         
         wx.showToast({
           title: '鎶ュ悕鎴愬姛',
@@ -1092,18 +1395,23 @@
       })
 
       // 绗竴姝ワ細涓婁紶鍒癈OS
-      const uploadResult = await cosUtil.uploadAvatar(this.data.localAvatarPath, 'avatar.jpg', (progress) => {
-        this.setData({
-          avatarUploadProgress: Math.round(progress.percent)
-        })
-      })
+      const uploadResult = await cosUtil.uploadAvatar(
+         this.data.localAvatarPath,
+         'avatar.jpg',
+         (percent) => {
+           this.setData({
+             avatarUploadProgress: Math.round(percent)
+           })
+         }
+       )
 
       // 绗簩姝ワ細淇濆瓨濯掍綋璁板綍鍒版暟鎹簱
       await this.saveMediaRecord({
-        targetType: 7, // USER_AVATAR
+        targetType: 'player', // V2 浣跨敤瀛楃涓诧細player 琛ㄧず鐢ㄦ埛澶村儚锛屽搴� DB 鐨� 7 (USER_AVATAR)
         targetId: idInfo.userId,
-        url: uploadResult.url,
+        path: uploadResult.key,
         fileName: uploadResult.fileName || 'avatar.jpg',
+        fileExt: this.getFileExtension(uploadResult.fileName || 'avatar.jpg'),
         fileSize: uploadResult.fileSize,
         mediaType: 1 // 鍥剧墖
       })
@@ -1128,21 +1436,27 @@
   async uploadAttachmentsWithRegistrationId(idInfo) {
     for (let i = 0; i < this.data.attachments.length; i++) {
       const attachment = this.data.attachments[i]
-      if (!attachment.uploaded && attachment.localPath) {
+      if (!attachment.uploaded && attachment.path) {
         try {
           // 绗竴姝ワ細涓婁紶鍒癈OS
-          const uploadResult = await cosUtil.uploadFile(attachment.localPath, 'attachment', attachment.name || 'attachment', (progress) => {
-            this.setData({
-              [`attachments[${i}].uploadProgress`]: Math.round(progress.percent)
-            })
-          })
+          const uploadResult = await cosUtil.uploadFile(
+            attachment.path,
+            'attachment',
+            attachment.name || 'attachment',
+            (percent) => {
+              this.setData({
+                [`attachments[${i}].uploadProgress`]: Math.round(percent)
+              })
+            }
+          )
 
           // 绗簩姝ワ細淇濆瓨濯掍綋璁板綍鍒版暟鎹簱
           await this.saveMediaRecord({
-            targetType: 5, // ACTIVITY_PLAYER_SUBMISSION
+            targetType: 'activity_player', // V2 浣跨敤瀛楃涓诧細activity_player 琛ㄧず鎶ュ悕闄勪欢锛屽搴� DB 鐨� 5
             targetId: idInfo.activityPlayerId,
-            url: uploadResult.url,
+            path: uploadResult.key,
             fileName: uploadResult.fileName || attachment.name,
+            fileExt: this.getFileExtension(uploadResult.fileName || attachment.name),
             fileSize: uploadResult.fileSize,
             mediaType: this.getMediaType(attachment.name) // 鏍规嵁鏂囦欢鎵╁睍鍚嶅垽鏂被鍨�
           })
@@ -1167,11 +1481,11 @@
   // 淇濆瓨濯掍綋璁板綍鍒版暟鎹簱
   async saveMediaRecord(mediaData) {
     const mutation = `
-      mutation SaveMedia($input: MediaInput!) {
-        saveMedia(input: $input) {
-          id
-          url
-          fileName
+      mutation SaveMediaV2($input: MediaSaveInput!) {
+        saveMediaV2(input: $input) {
+          success
+          message
+          mediaId
         }
       }
     `
@@ -1180,8 +1494,9 @@
       input: {
         targetType: mediaData.targetType,
         targetId: mediaData.targetId,
-        url: mediaData.url,
-        fileName: mediaData.fileName,
+        path: mediaData.path,
+        fileName: mediaData.fileName || mediaData.name, // V2 瀛楁涓� fileName锛屽吋瀹规棫瀛楁 name
+        fileExt: mediaData.fileExt,
         fileSize: mediaData.fileSize,
         mediaType: mediaData.mediaType
       }
@@ -1189,14 +1504,71 @@
     
     try {
       const result = await app.graphqlRequest(mutation, variables)
-      console.log('濯掍綋璁板綍淇濆瓨鎴愬姛:', result.saveMedia)
-      return result.saveMedia
+      console.log('濯掍綋璁板綍淇濆瓨鎴愬姛(V2):', result.saveMediaV2)
+      return result.saveMediaV2
     } catch (error) {
-      console.error('濯掍綋璁板綍淇濆瓨澶辫触:', error)
+      console.error('濯掍綋璁板綍淇濆瓨澶辫触(V2):', error)
       throw error
     }
   },
 
+  // 妫�鏌ュ綋鍓嶆椿鍔ㄧ殑鎶ュ悕鐘舵�侊紝杩涘叆椤甸潰鏃惰皟鐢�
+  async checkRegistrationStatus(activityId) {
+    try {
+      // GraphQL 鏌ヨ鏈�鏂版姤鍚嶇姸鎬侊紙鍚庣杩斿洖鏈�鏂颁竴鏉¤褰曪級
+      const query = `
+        query GetPlayerRegistrationState($activityId: ID!) {
+          getPlayerRegistrationState(activityId: $activityId) {
+            id
+            status
+            registrationTime
+            reviewStatus
+            reviewComment
+          }
+        }
+      `
+      const res = await app.graphqlRequest(query, { activityId: parseInt(activityId) })
+      console.log('馃煢 鎶ュ悕鐘舵�佹煡璇㈢粨鏋滃師濮�:', res)
+
+      // 鍏煎澶氱杩斿洖缁撴瀯
+      const dataRoot = res?.getPlayerRegistrationState
+        || res?.playerRegistration
+        || res?.data?.getPlayerRegistrationState
+        || res?.data?.playerRegistration
+
+      let submitDisabled = false
+      let submitText = '鎻愪氦鎶ュ悕'
+
+      if (dataRoot && dataRoot.status !== undefined && dataRoot.status !== null) {
+        const statusNum = Number(dataRoot.status)
+        console.log('馃煢 瑙f瀽鍒版姤鍚嶇姸鎬�:', statusNum)
+        if (statusNum === 1) {
+          submitDisabled = true
+          submitText = '宸茬粡鎶ュ悕'
+        } else if (statusNum === 0) {
+          submitDisabled = true
+          submitText = '绛夊緟瀹℃牳'
+        } else {
+          submitDisabled = false
+          submitText = '鎻愪氦鎶ュ悕'
+        }
+      } else {
+        console.log('馃煢 鏈壘鍒版姤鍚嶈褰曟垨鐘舵�侊紝鍏佽鎻愪氦')
+      }
+
+      this.setData({ submitDisabled, submitText })
+    } catch (err) {
+      console.warn('鈿狅笍 鎶ュ悕鐘舵�佹煡璇㈠け璐ワ紝鍏佽鐢ㄦ埛鎻愪氦:', err)
+      this.setData({ submitDisabled: false, submitText: '鎻愪氦鎶ュ悕' })
+    }
+  },
+
+  // 鑾峰彇鏂囦欢鎵╁睍鍚�
+  getFileExtension(fileName) {
+    if (!fileName) return ''
+    return fileName.split('.').pop().toLowerCase()
+  },
+
   // 鏍规嵁鏂囦欢鍚嶈幏鍙栧獟浣撶被鍨�
   getMediaType(fileName) {
     if (!fileName) return 1 // 榛樿鍥剧墖

--
Gitblit v1.8.0