From 7cf8871cef3ababda6101f78e1277dbc4625f80a Mon Sep 17 00:00:00 2001 From: lld <15027638633@163.com> Date: Sat, 4 Apr 2026 00:15:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=B8=AD=E5=BF=83=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E6=96=B0=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 11 ++++++++++- pages/news/index.vue | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) 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); }