| | |
| | | <text class="loading-more-text">加载更多...</text> |
| | | </view> |
| | | </scroll-view> |
| | | |
| | | <DownloadProgressMask /> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | 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 = [ |
| | |
| | | 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) { |
| | |
| | | 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, |
| | | }); |
| | | } |
| | |
| | | const onRefresh = () => { |
| | | triggered.value = true; |
| | | // 重置页码 |
| | | page.current = 1; |
| | | page.current = 2; |
| | | // 重新加载消息 |
| | | loadMessages(false).finally(() => { |
| | | // 关闭刷新状态 |