消息中心监听新消息
parent
9277036176
commit
7cf8871cef
11
App.vue
11
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})
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue