From 8d4a66c31aa0f6418403ade8a780f27c9fa9d921 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期二, 10 二月 2026 17:43:30 +0800
Subject: [PATCH] 消息列表
---
src/pages/login.vue | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 50 insertions(+), 9 deletions(-)
diff --git a/src/pages/login.vue b/src/pages/login.vue
index f717c26..d7e5953 100644
--- a/src/pages/login.vue
+++ b/src/pages/login.vue
@@ -48,7 +48,11 @@
icon: "none",
});
};
- import { userLoginFacotryList, updateClientId } from "@/api/login";
+ import {
+ userLoginFacotryList,
+ updateClientId,
+ getNoticeCount,
+ } from "@/api/login";
import { ref, onMounted } from "vue";
import useUserStore from "@/store/modules/user";
import { getWxCode } from "@/utils/geek";
@@ -160,20 +164,57 @@
function loginSuccess(result) {
// 璁剧疆鐢ㄦ埛淇℃伅
userStore.getInfo().then(res => {
+ const userId = res.user.userId;
// 鑾峰彇璺敱鏉冮檺
- userStore.getRouters().then(() => {
- console.log("璺敱鏉冮檺鑾峰彇鎴愬姛");
- }).catch(error => {
- console.error("鑾峰彇璺敱鏉冮檺澶辫触:", error);
- });
+ userStore
+ .getRouters()
+ .then(() => {
+ console.log("璺敱鏉冮檺鑾峰彇鎴愬姛");
+ })
+ .catch(error => {
+ console.error("鑾峰彇璺敱鏉冮檺澶辫触:", error);
+ });
// 鐧诲綍鎴愬姛鍚庯紝灏嗗鎴风鎺ㄩ�佹爣璇嗗彂閫佸埌鏈嶅姟鍣�
sendClientIdToServer();
- uni.switchTab({
- url: "/pages/index",
- });
+ // 鍚姩瀹氭椂鑾峰彇鏈娑堟伅鏁伴噺鐨勫畾鏃跺櫒
+ startNoticeCountTimer(userId);
+ uni.switchTab({ url: "/pages/index" });
});
}
+ // 鍚姩瀹氭椂鑾峰彇鏈娑堟伅鏁伴噺鐨勫畾鏃跺櫒
+ function startNoticeCountTimer(userId) {
+ // 绔嬪嵆鑾峰彇涓�娆℃湭璇绘秷鎭暟閲�
+ updateNoticeCount(userId);
+ // 璁剧疆瀹氭椂鍣紝姣�30绉掕幏鍙栦竴娆�
+ setInterval(() => {
+ updateNoticeCount(userId);
+ }, 30000);
+ }
+
+ // 鏇存柊鏈娑堟伅鏁伴噺
+ function updateNoticeCount(userId) {
+ getNoticeCount(userId)
+ .then(res => {
+ const count = res.data || 0;
+ console.log("鏈娑堟伅鏁伴噺:", count);
+ // 鏇存柊tabbar鐨勮鏍�
+ if (count > 0) {
+ uni.setTabBarBadge({
+ index: 1, // 娑堟伅鏍囩椤电殑绱㈠紩
+ text: count.toString(),
+ });
+ } else {
+ uni.removeTabBarBadge({
+ index: 1,
+ });
+ }
+ })
+ .catch(error => {
+ console.error("鑾峰彇鏈娑堟伅鏁伴噺澶辫触:", error);
+ });
+ }
+
// 灏嗗鎴风鎺ㄩ�佹爣璇嗗彂閫佸埌鏈嶅姟鍣�
function sendClientIdToServer() {
// 鑾峰彇鏈湴瀛樺偍鐨勫鎴风鏍囪瘑
--
Gitblit v1.9.3