gaoluyang
2026-09-18 c9cfcbda7fb7c8b62b27d623feb0418790396740
src/pages/message.vue
@@ -60,6 +60,8 @@
        <text class="loading-more-text">加载更多...</text>
      </view>
    </scroll-view>
    <DownloadProgressMask />
  </view>
</template>
@@ -68,6 +70,7 @@
  import { onShow } from "@dcloudio/uni-app";
  import { listNotice, confirmMessage, getNoticeCount } from "@/api/login.js";
  import useUserStore from "@/store/modules/user";
  import DownloadProgressMask from "@/components/DownloadProgressMask.vue";
  // 标签页数据
  const tabList = [
@@ -230,6 +233,16 @@
    return null;
  };
  // tabbar 角标:异步返回时可能已切到非 tabBar 页面,失败静默忽略
  const callTabBarApi = (api, options) => {
    try {
      const ret = uni[api](options);
      if (ret && typeof ret.catch === "function") ret.catch(() => {});
    } catch (e) {
      /* 非 tabBar 页面,忽略 */
    }
  };
  // 更新 tab 栏角标
  const updateTabBarBadge = () => {
    if (userId.value) {
@@ -238,12 +251,12 @@
          const count = res.data || 0;
          // 更新tabbar的角标
          if (count > 0) {
            uni.setTabBarBadge({
            callTabBarApi("setTabBarBadge", {
              index: 2, // 消息标签页的索引
              text: count.toString(),
            });
          } else {
            uni.removeTabBarBadge({
            callTabBarApi("removeTabBarBadge", {
              index: 2,
            });
          }
@@ -362,7 +375,7 @@
  const onRefresh = () => {
    triggered.value = true;
    // 重置页码
    page.current = 1;
    page.current = 2;
    // 重新加载消息
    loadMessages(false).finally(() => {
      // 关闭刷新状态