diff --git a/App.vue b/App.vue index 1917fd8..0bbb0d1 100644 --- a/App.vue +++ b/App.vue @@ -3,6 +3,7 @@ import config from './config' import { getToken } from '@/utils/auth' import mqttUtil from '@/utils/mqtt' import {startMqttOnlinePing, stopMqttOnlinePing} from "./utils/mqtt"; +import {unReadCount} from "@/api/warn/message"; export default { subscribeList:[], globalData: { @@ -71,6 +72,7 @@ export default { // 防止 mqtt client 还没连上:可以等 connected 后再 start(见下面提示) startMqttOnlinePing( 20000); + this.unReadCount() } }, onHide() { @@ -212,7 +214,14 @@ export default { icon: 'none' }); }); - } + }, + unReadCount() { + unReadCount().then(response => { + if (response.code === 200 && response.data > 0) { + uni.showTabBarRedDot({index: 2}) + } + }) + }, } } diff --git a/pages/news/index.vue b/pages/news/index.vue index ebd8354..4d29c4f 100644 --- a/pages/news/index.vue +++ b/pages/news/index.vue @@ -330,7 +330,6 @@ export default { item.numBadge+=1; item.content = msg.content; item.createTime = msg.createTime; - uni.showTabBarRedDot({index: 2}) } catch (e) { console.error("MQTT消息解析失败:", e, payload); }