zhangwencui
3 天以前 f670b79094c95d791fc43c8fc8b5858ebf8426dc
src/pages/login.vue
@@ -231,6 +231,16 @@
    }, 30000);
  }
  // tabbar 角标:登录后定时刷新时可能已不在 tabBar 页面,失败静默忽略
  function callTabBarApi(api, options) {
    try {
      const ret = uni[api](options);
      if (ret && typeof ret.catch === "function") ret.catch(() => {});
    } catch (e) {
      /* 非 tabBar 页面,忽略 */
    }
  }
  // 更新未读消息数量
  function updateNoticeCount(userId) {
    getNoticeCount(userId)
@@ -239,12 +249,12 @@
        console.log("未读消息数量:", count);
        // 更新tabbar的角标
        if (count > 0) {
          uni.setTabBarBadge({
          callTabBarApi("setTabBarBadge", {
            index: 2, // 消息标签页的索引
            text: count.toString(),
          });
        } else {
          uni.removeTabBarBadge({
          callTabBarApi("removeTabBarBadge", {
            index: 2,
          });
        }