From 1626d13ec8b1a63676e63cf95c5004c4118da3b3 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 26 十月 2025 14:59:48 +0800
Subject: [PATCH] feat:移除app 中我的栏目中不要的功能

---
 app/App.vue |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/app/App.vue b/app/App.vue
index 797f513..3610e7c 100644
--- a/app/App.vue
+++ b/app/App.vue
@@ -2,10 +2,17 @@
   import config from './config'
   import store from '@/store'
   import { getToken } from '@/utils/auth'
+  import { getUnreadCount } from '@/api/message'
 
   export default {
     onLaunch: function() {
       this.initApp()
+    },
+    onShow: function() {
+      // 搴旂敤鏄剧ず鏃跺埛鏂版湭璇绘秷鎭暟閲�
+      if (getToken()) {
+        this.updateUnreadMessageBadge()
+      }
     },
     methods: {
       // 鍒濆鍖栧簲鐢�
@@ -16,6 +23,13 @@
         //#ifdef H5
         this.checkLogin()
         //#endif
+        
+        // 濡傛灉宸茬櫥褰曪紝鍚姩鏈娑堟伅杞
+        if (getToken()) {
+          this.updateUnreadMessageBadge()
+          // 姣�30绉掕疆璇竴娆�
+          this.startMessagePolling()
+        }
       },
       initConfig() {
         this.globalData.config = config
@@ -24,6 +38,50 @@
         if (!getToken()) {
           this.$tab.reLaunch('/pages/login') 
         }
+      },
+      
+      // 鏇存柊鏈娑堟伅寰芥爣
+      updateUnreadMessageBadge() {
+        getUnreadCount().then(response => {
+          const count = response.data || 0
+          console.log('鏈娑堟伅鏁伴噺:', count)
+          
+          if (count > 0) {
+            // 璁剧疆寰芥爣
+            uni.setTabBarBadge({
+              index: 3, // 娑堟伅椤甸潰鍦╰abBar涓殑绱㈠紩浣嶇疆锛�0寮�濮嬶級
+              text: count > 99 ? '99+' : count.toString()
+            })
+          } else {
+            // 绉婚櫎寰芥爣
+            uni.removeTabBarBadge({
+              index: 3
+            })
+          }
+        }).catch(error => {
+          console.error('鑾峰彇鏈娑堟伅鏁伴噺澶辫触:', error)
+        })
+      },
+      
+      // 鍚姩娑堟伅杞
+      startMessagePolling() {
+        // 姣�30绉掕疆璇竴娆�
+        this.messagePollingTimer = setInterval(() => {
+          if (getToken()) {
+            this.updateUnreadMessageBadge()
+          } else {
+            // 濡傛灉鐢ㄦ埛宸茬櫥鍑猴紝鍋滄杞
+            this.stopMessagePolling()
+          }
+        }, 30000) // 30绉�
+      },
+      
+      // 鍋滄娑堟伅杞
+      stopMessagePolling() {
+        if (this.messagePollingTimer) {
+          clearInterval(this.messagePollingTimer)
+          this.messagePollingTimer = null
+        }
       }
     }
   }

--
Gitblit v1.9.1