From dc643ba44fd2a426263015491268a0f0d6b4671d Mon Sep 17 00:00:00 2001
From: lrj <owen.stl@gmail.com>
Date: 星期三, 01 十月 2025 08:39:29 +0800
Subject: [PATCH] 删除包含test、check、fix的文件名的文件

---
 wx/pages/message/message.js |  627 ++++++--------------------------------------------------
 1 files changed, 75 insertions(+), 552 deletions(-)

diff --git a/wx/pages/message/message.js b/wx/pages/message/message.js
index 9b36d57..62900ba 100644
--- a/wx/pages/message/message.js
+++ b/wx/pages/message/message.js
@@ -1,587 +1,110 @@
 // pages/message/message.js
 const app = getApp()
-const { graphqlRequest, formatDate, formatRelativeTime } = require('../../lib/utils')
 
 Page({
   data: {
-    loading: false,
-    refreshing: false,
-    loadingMore: false,
-    hasMore: true,
-    
-    // 娑堟伅鍒楄〃
     messages: [],
-    
-    // 鍒嗛〉鍙傛暟
-    pagination: {
-      page: 1,
-      limit: 20,
-      total: 0
-    },
-    
-    // 绛涢�夋潯浠�
-    filter: {
-      type: 'ALL', // ALL, SYSTEM, ACTIVITY, JUDGE, ORGANIZER
-      status: 'ALL' // ALL, READ, UNREAD
-    },
-    
-    // 绛涢�夐�夐」
-    typeOptions: [
-      { value: 'ALL', label: '鍏ㄩ儴娑堟伅' },
-      { value: 'SYSTEM', label: '绯荤粺閫氱煡' },
-      { value: 'ACTIVITY', label: '娲诲姩娑堟伅' },
-      { value: 'JUDGE', label: '璇勫娑堟伅' },
-      { value: 'ORGANIZER', label: '涓诲姙鏂规秷鎭�' }
-    ],
-    
-    statusOptions: [
-      { value: 'ALL', label: '鍏ㄩ儴鐘舵��' },
-      { value: 'UNREAD', label: '鏈' },
-      { value: 'READ', label: '宸茶' }
-    ],
-    
-    // 鏄剧ず绛涢�夐潰鏉�
-    showFilter: false,
-    
-    // 缁熻鏁版嵁
-    stats: {
-      total: 0,
-      unread: 0
-    },
-    
-    // 閫夋嫨妯″紡
-    selectMode: false,
-    selectedMessages: [],
-    
-    // 娑堟伅绫诲瀷鍥炬爣鏄犲皠
-    typeIcons: {
-      'SYSTEM': '馃敂',
-      'ACTIVITY': '馃幆',
-      'JUDGE': '鈿栵笍',
-      'ORGANIZER': '馃懃',
-      'REGISTRATION': '馃摑',
-      'RESULT': '馃弳',
-      'REMINDER': '鈴�'
-    }
+    loading: false
   },
 
   onLoad() {
     this.loadMessages()
-    this.loadMessageStats()
   },
 
   onShow() {
-    // 椤甸潰鏄剧ず鏃跺埛鏂版湭璇绘暟閲�
-    this.loadMessageStats()
-    // 鍒濆鍖栬嚜瀹氫箟 tabbar
-    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
-      this.getTabBar().init()
-    }
+    this.loadMessages()
   },
 
   onPullDownRefresh() {
-    this.refreshMessages()
-  },
-
-  onReachBottom() {
-    if (this.data.hasMore && !this.data.loadingMore) {
-      this.loadMoreMessages()
-    }
+    this.loadMessages()
   },
 
   // 鍔犺浇娑堟伅鍒楄〃
-  async loadMessages(reset = true) {
-    try {
-      if (reset) {
-        this.setData({ 
-          loading: true,
-          pagination: { ...this.data.pagination, page: 1 }
-        })
-      }
-      
-      const { filter, pagination } = this.data
-      
-      const query = `
-        query GetMessages($input: MessageQueryInput!) {
-          messages(input: $input) {
-            items {
-              id
-              type
-              title
-              content
-              isRead
-              createdAt
-              data
-              relatedActivity {
-                id
-                title
-              }
-            }
-            pagination {
-              total
-              page
-              limit
-              hasMore
-            }
-          }
-        }
-      `
-      
-      const input = {
-        type: filter.type === 'ALL' ? null : filter.type,
-        status: filter.status === 'ALL' ? null : filter.status,
-        page: pagination.page,
-        limit: pagination.limit
-      }
-      
-      const result = await graphqlRequest(query, { input })
-      
-      if (result && result.messages) {
-        const { items, pagination: newPagination } = result.messages
-        
-        // 涓烘瘡涓秷鎭坊鍔犻�変腑鐘舵��
-        const processedItems = items.map(item => ({
-          ...item,
-          isSelected: this.data.selectedMessages.indexOf(item.id) > -1
-        }))
-        
-        this.setData({
-          messages: reset ? processedItems : [...this.data.messages, ...processedItems],
-          pagination: newPagination,
-          hasMore: newPagination.hasMore
-        })
-      }
-    } catch (error) {
-      console.error('鍔犺浇娑堟伅澶辫触:', error)
+  loadMessages() {
+    // 妫�鏌ョ敤鎴锋槸鍚﹀凡鐧诲綍
+    const userInfo = app.globalData.userInfo
+    if (!userInfo || !userInfo.userId) {
+      console.error('鐢ㄦ埛鏈櫥褰曟垨userId涓嶅瓨鍦�')
       wx.showToast({
-        title: '鍔犺浇澶辫触',
-        icon: 'error'
-      })
-    } finally {
-      this.setData({ 
-        loading: false,
-        refreshing: false,
-        loadingMore: false
-      })
-      wx.stopPullDownRefresh()
-    }
-  },
-
-  // 鍒锋柊娑堟伅
-  async refreshMessages() {
-    this.setData({ refreshing: true })
-    await this.loadMessages(true)
-    await this.loadMessageStats()
-  },
-
-  // 鍔犺浇鏇村娑堟伅
-  async loadMoreMessages() {
-    if (!this.data.hasMore || this.data.loadingMore) return
-    
-    this.setData({ 
-      loadingMore: true,
-      pagination: {
-        ...this.data.pagination,
-        page: this.data.pagination.page + 1
-      }
-    })
-    
-    await this.loadMessages(false)
-  },
-
-  // 鍔犺浇娑堟伅缁熻
-  async loadMessageStats() {
-    try {
-      const query = `
-        query GetMessageStats {
-          messageStats {
-            total
-            unread
-          }
-        }
-      `
-      
-      const result = await graphqlRequest(query)
-      
-      if (result && result.messageStats) {
-        this.setData({
-          stats: result.messageStats
-        })
-        
-        // 鏇存柊搴曢儴瀵艰埅鏍忕殑鏈鏁伴噺
-        if (typeof this.getTabBar === 'function' && this.getTabBar()) {
-          this.getTabBar().setData({
-            unreadCount: result.messageStats.unread
-          })
-        }
-      }
-    } catch (error) {
-      console.error('鍔犺浇娑堟伅缁熻澶辫触:', error)
-    }
-  },
-
-  // 娑堟伅鐐瑰嚮
-  async onMessageTap(e) {
-    const { id, index } = e.currentTarget.dataset
-    const message = this.data.messages[index]
-    
-    // 濡傛灉鏄�夋嫨妯″紡锛屽垏鎹㈤�夋嫨鐘舵��
-    if (this.data.selectMode) {
-      this.toggleMessageSelection(id)
-      return
-    }
-    
-    // 鏍囪涓哄凡璇�
-    if (!message.isRead) {
-      await this.markAsRead(id, index)
-    }
-    
-    // 鏍规嵁娑堟伅绫诲瀷澶勭悊璺宠浆
-    this.handleMessageAction(message)
-  },
-
-  // 澶勭悊娑堟伅鍔ㄤ綔
-  handleMessageAction(message) {
-    const { type, data, relatedActivity } = message
-    
-    switch (type) {
-      case 'ACTIVITY':
-        if (relatedActivity && relatedActivity.id) {
-          wx.navigateTo({
-            url: `/pages/activity/detail?id=${relatedActivity.id}`
-          })
-        }
-        break
-      case 'REGISTRATION':
-        if (data && data.registrationId) {
-          wx.navigateTo({
-            url: `/pages/profile/registration-detail?id=${data.registrationId}`
-          })
-        }
-        break
-      case 'JUDGE':
-        if (data && data.submissionId) {
-          wx.navigateTo({
-            url: `/pages/judge/review?id=${data.submissionId}`
-          })
-        }
-        break
-      case 'ORGANIZER':
-        if (relatedActivity && relatedActivity.id) {
-          wx.navigateTo({
-            url: `/pages/organizer/activity-detail?id=${relatedActivity.id}`
-          })
-        }
-        break
-      default:
-        // 鏄剧ず娑堟伅璇︽儏
-        this.showMessageDetail(message)
-        break
-    }
-  },
-
-  // 鏄剧ず娑堟伅璇︽儏
-  showMessageDetail(message) {
-    wx.showModal({
-      title: message.title,
-      content: message.content,
-      showCancel: false,
-      confirmText: '鐭ラ亾浜�'
-    })
-  },
-
-  // 鏍囪涓哄凡璇�
-  async markAsRead(messageId, index) {
-    try {
-      const mutation = `
-        mutation MarkMessageAsRead($id: ID!) {
-          markMessageAsRead(id: $id) {
-            success
-          }
-        }
-      `
-      
-      const result = await graphqlRequest(mutation, { id: messageId })
-      
-      if (result && result.markMessageAsRead.success) {
-        // 鏇存柊鏈湴鏁版嵁
-        const messages = [...this.data.messages]
-        messages[index].isRead = true
-        
-        this.setData({ messages })
-        
-        // 鏇存柊缁熻鏁版嵁
-        this.setData({
-          'stats.unread': Math.max(0, this.data.stats.unread - 1)
-        })
-      }
-    } catch (error) {
-      console.error('鏍囪宸茶澶辫触:', error)
-    }
-  },
-
-  // 鎵归噺鏍囪涓哄凡璇�
-  async markAllAsRead() {
-    try {
-      wx.showLoading({ title: '澶勭悊涓�...' })
-      
-      const mutation = `
-        mutation MarkAllMessagesAsRead {
-          markAllMessagesAsRead {
-            success
-            count
-          }
-        }
-      `
-      
-      const result = await graphqlRequest(mutation)
-      
-      if (result && result.markAllMessagesAsRead.success) {
-        // 鍒锋柊娑堟伅鍒楄〃
-        await this.refreshMessages()
-        
-        wx.showToast({
-          title: '宸插叏閮ㄦ爣璁颁负宸茶',
-          icon: 'success'
-        })
-      }
-    } catch (error) {
-      console.error('鎵归噺鏍囪宸茶澶辫触:', error)
-      wx.showToast({
-        title: '鎿嶄綔澶辫触',
-        icon: 'error'
-      })
-    } finally {
-      wx.hideLoading()
-    }
-  },
-
-  // 鍒犻櫎娑堟伅
-  async deleteMessage(messageId) {
-    try {
-      const mutation = `
-        mutation DeleteMessage($id: ID!) {
-          deleteMessage(id: $id) {
-            success
-          }
-        }
-      `
-      
-      const result = await graphqlRequest(mutation, { id: messageId })
-      
-      if (result && result.deleteMessage.success) {
-        // 浠庡垪琛ㄤ腑绉婚櫎
-        const messages = this.data.messages.filter(msg => msg.id !== messageId)
-        this.setData({ messages })
-        
-        wx.showToast({
-          title: '鍒犻櫎鎴愬姛',
-          icon: 'success'
-        })
-      }
-    } catch (error) {
-      console.error('鍒犻櫎娑堟伅澶辫触:', error)
-      wx.showToast({
-        title: '鍒犻櫎澶辫触',
-        icon: 'error'
-      })
-    }
-  },
-
-  // 闀挎寜娑堟伅
-  onMessageLongPress(e) {
-    const { id } = e.currentTarget.dataset
-    
-    wx.showActionSheet({
-      itemList: ['鏍囪涓哄凡璇�', '鍒犻櫎娑堟伅'],
-      success: (res) => {
-        switch (res.tapIndex) {
-          case 0:
-            this.markAsRead(id)
-            break
-          case 1:
-            wx.showModal({
-              title: '纭鍒犻櫎',
-              content: '纭畾瑕佸垹闄よ繖鏉℃秷鎭悧锛�',
-              success: (modalRes) => {
-                if (modalRes.confirm) {
-                  this.deleteMessage(id)
-                }
-              }
-            })
-            break
-        }
-      }
-    })
-  },
-
-  // 鍒囨崲绛涢�夐潰鏉�
-  onToggleFilter() {
-    this.setData({
-      showFilter: !this.data.showFilter
-    })
-  },
-
-  // 绛涢�夋潯浠舵敼鍙�
-  onFilterChange(e) {
-    const { type, value } = e.currentTarget.dataset
-    
-    this.setData({
-      [`filter.${type}`]: value,
-      showFilter: false
-    })
-    
-    // 閲嶆柊鍔犺浇娑堟伅
-    this.loadMessages(true)
-  },
-
-  // 鍒囨崲閫夋嫨妯″紡
-  onToggleSelectMode() {
-    this.setData({
-      selectMode: !this.data.selectMode,
-      selectedMessages: []
-    })
-  },
-
-  // 鍒囨崲娑堟伅閫夋嫨鐘舵��
-  toggleMessageSelection(messageId) {
-    const selectedMessages = [...this.data.selectedMessages]
-    const index = selectedMessages.indexOf(messageId)
-    
-    if (index > -1) {
-      selectedMessages.splice(index, 1)
-    } else {
-      selectedMessages.push(messageId)
-    }
-    
-    // 鍚屾椂鏇存柊娑堟伅鐨刬sSelected瀛楁
-    const messages = this.data.messages.map(msg => ({
-      ...msg,
-      isSelected: selectedMessages.indexOf(msg.id) > -1
-    }))
-    
-    this.setData({ 
-      selectedMessages,
-      messages
-    })
-  },
-
-  // 鍏ㄩ��/鍙栨秷鍏ㄩ��
-  onToggleSelectAll() {
-    const { messages, selectedMessages } = this.data
-    const allSelected = selectedMessages.length === messages.length
-    const newSelectedMessages = allSelected ? [] : messages.map(msg => msg.id)
-    
-    // 鍚屾椂鏇存柊娑堟伅鐨刬sSelected瀛楁
-    const updatedMessages = messages.map(msg => ({
-      ...msg,
-      isSelected: !allSelected
-    }))
-    
-    this.setData({
-      selectedMessages: newSelectedMessages,
-      messages: updatedMessages
-    })
-  },
-
-  // 鎵归噺鍒犻櫎閫変腑娑堟伅
-  async onDeleteSelected() {
-    const { selectedMessages } = this.data
-    
-    if (selectedMessages.length === 0) {
-      wx.showToast({
-        title: '璇烽�夋嫨瑕佸垹闄ょ殑娑堟伅',
+        title: '璇峰厛鐧诲綍',
         icon: 'error'
       })
       return
     }
+
+    this.setData({ loading: true })
     
-    wx.showModal({
-      title: '纭鍒犻櫎',
-      content: `纭畾瑕佸垹闄ら�変腑鐨� ${selectedMessages.length} 鏉℃秷鎭悧锛焋,
-      success: async (res) => {
-        if (res.confirm) {
-          try {
-            wx.showLoading({ title: '鍒犻櫎涓�...' })
-            
-            const mutation = `
-              mutation DeleteMessages($ids: [ID!]!) {
-                deleteMessages(ids: $ids) {
-                  success
-                  count
-                }
-              }
-            `
-            
-            const result = await graphqlRequest(mutation, { ids: selectedMessages })
-            
-            if (result && result.deleteMessages.success) {
-              // 鍒锋柊娑堟伅鍒楄〃
-              await this.refreshMessages()
-              
-              this.setData({
-                selectMode: false,
-                selectedMessages: []
-              })
-              
-              wx.showToast({
-                title: `宸插垹闄� ${result.deleteMessages.count} 鏉℃秷鎭痐,
-                icon: 'success'
-              })
-            }
-          } catch (error) {
-            console.error('鎵归噺鍒犻櫎澶辫触:', error)
-            wx.showToast({
-              title: '鍒犻櫎澶辫触',
-              icon: 'error'
-            })
-          } finally {
-            wx.hideLoading()
-          }
+    const query = `
+      query GetMessagesByUserId($userId: Long!) {
+        getMessagesByUserId(userId: $userId) {
+          id
+          userId
+          content
+          wxMsgSuccess
+          wxMsgErrCount
+          state
+          createTime
+          updateTime
         }
       }
-    })
-  },
+    `
 
-  // 鑾峰彇娑堟伅绫诲瀷鍥炬爣
-  getTypeIcon(type) {
-    return this.data.typeIcons[type] || '馃摠'
-  },
-
-  // 鑾峰彇娑堟伅绫诲瀷鏂囨湰
-  getTypeText(type) {
-    const typeMap = {
-      'SYSTEM': '绯荤粺閫氱煡',
-      'ACTIVITY': '娲诲姩娑堟伅',
-      'JUDGE': '璇勫娑堟伅',
-      'ORGANIZER': '涓诲姙鏂规秷鎭�',
-      'REGISTRATION': '鎶ュ悕娑堟伅',
-      'RESULT': '缁撴灉閫氱煡',
-      'REMINDER': '鎻愰啋娑堟伅'
+    const variables = {
+      userId: userInfo.userId
     }
-    return typeMap[type] || '娑堟伅'
+
+    app.graphqlRequest(query, variables)
+      .then(data => {
+        console.log('娑堟伅鏁版嵁:', data)
+        this.setData({
+          messages: data.getMessagesByUserId || [],
+          loading: false
+        })
+        wx.stopPullDownRefresh()
+      })
+      .catch(error => {
+        console.error('鍔犺浇娑堟伅澶辫触:', error)
+        wx.showToast({
+          title: '鍔犺浇澶辫触',
+          icon: 'error'
+        })
+        this.setData({ loading: false })
+        wx.stopPullDownRefresh()
+      })
   },
 
-  // 鏍煎紡鍖栨椂闂�
-  formatTime(dateString) {
-    const now = new Date()
-    const date = new Date(dateString)
-    const diff = now.getTime() - date.getTime()
+  // 鏍煎紡鍖栨秷鎭椂闂�
+  formatMessageTime(timeStr) {
+    if (!timeStr) return ''
     
-    // 涓�澶╁唴鏄剧ず鐩稿鏃堕棿
-    if (diff < 24 * 60 * 60 * 1000) {
-      return formatRelativeTime(dateString)
-    }
-    
-    // 瓒呰繃涓�澶╂樉绀哄叿浣撴棩鏈�
-    return formatDate(dateString, 'MM-DD HH:mm')
-  },
-
-  // 鍒嗕韩椤甸潰
-  onShareAppMessage() {
-    return {
-      title: '钃夋槗鍒� - 娑堟伅涓績',
-      path: '/pages/index/index'
+    try {
+      const date = new Date(timeStr)
+      const now = new Date()
+      const diff = now.getTime() - date.getTime()
+      
+      // 濡傛灉鏄粖澶�
+      if (diff < 24 * 60 * 60 * 1000) {
+        const hours = date.getHours().toString().padStart(2, '0')
+        const minutes = date.getMinutes().toString().padStart(2, '0')
+        return `${hours}:${minutes}`
+      }
+      
+      // 濡傛灉鏄槰澶�
+      if (diff < 48 * 60 * 60 * 1000) {
+        const hours = date.getHours().toString().padStart(2, '0')
+        const minutes = date.getMinutes().toString().padStart(2, '0')
+        return `鏄ㄥぉ ${hours}:${minutes}`
+      }
+      
+      // 鍏朵粬鏃ユ湡
+      const month = (date.getMonth() + 1).toString().padStart(2, '0')
+      const day = date.getDate().toString().padStart(2, '0')
+      const hours = date.getHours().toString().padStart(2, '0')
+      const minutes = date.getMinutes().toString().padStart(2, '0')
+      return `${month}-${day} ${hours}:${minutes}`
+    } catch (error) {
+      console.error('鏃堕棿鏍煎紡鍖栧け璐�:', error)
+      return timeStr
     }
   }
 })
\ No newline at end of file

--
Gitblit v1.8.0