消息中心监听新消息
parent
9277036176
commit
7cf8871cef
9
App.vue
9
App.vue
|
|
@ -3,6 +3,7 @@ import config from './config'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
import mqttUtil from '@/utils/mqtt'
|
import mqttUtil from '@/utils/mqtt'
|
||||||
import {startMqttOnlinePing, stopMqttOnlinePing} from "./utils/mqtt";
|
import {startMqttOnlinePing, stopMqttOnlinePing} from "./utils/mqtt";
|
||||||
|
import {unReadCount} from "@/api/warn/message";
|
||||||
export default {
|
export default {
|
||||||
subscribeList:[],
|
subscribeList:[],
|
||||||
globalData: {
|
globalData: {
|
||||||
|
|
@ -71,6 +72,7 @@ export default {
|
||||||
|
|
||||||
// 防止 mqtt client 还没连上:可以等 connected 后再 start(见下面提示)
|
// 防止 mqtt client 还没连上:可以等 connected 后再 start(见下面提示)
|
||||||
startMqttOnlinePing( 20000);
|
startMqttOnlinePing( 20000);
|
||||||
|
this.unReadCount()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onHide() {
|
onHide() {
|
||||||
|
|
@ -212,7 +214,14 @@ export default {
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
unReadCount() {
|
||||||
|
unReadCount().then(response => {
|
||||||
|
if (response.code === 200 && response.data > 0) {
|
||||||
|
uni.showTabBarRedDot({index: 2})
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,6 @@ export default {
|
||||||
item.numBadge+=1;
|
item.numBadge+=1;
|
||||||
item.content = msg.content;
|
item.content = msg.content;
|
||||||
item.createTime = msg.createTime;
|
item.createTime = msg.createTime;
|
||||||
uni.showTabBarRedDot({index: 2})
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("MQTT消息解析失败:", e, payload);
|
console.error("MQTT消息解析失败:", e, payload);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue