新消息提醒机制,调整为uni.$emit全局事件,网络状态变化亦然

This commit is contained in:
2022-01-28 11:39:26 +08:00
parent f9e2819cc7
commit a97a5fd0ca
4 changed files with 32 additions and 48 deletions

View File

@@ -41,7 +41,6 @@ const setNotifyBadge = () => {
}
}
})
}
/**
@@ -63,12 +62,16 @@ const connect = (token, userInfo, callback) => {
const model = uni.model.friendModel
model.find((err, results) => {
console.log('好友列表', results);
results.map(item => {
store.dispatch('updateFriends', item)
})
})
}
/**
* 断开链接
*/
const disconnect = () => {
RongIMLib.disconnect()
// 移除提醒数量
@@ -108,7 +111,7 @@ const addListeners = () => {
// 添加连接状态监听函数
RongIMLib.addConnectionStatusListener((res) => {
console.log('连接状态监听', res.data.status);
store.dispatch('updateConnectionStatus', res.data.status)
uni.$emit('onConnectionStatusChange', res.data.status)
})
// 添加消息监听函数
RongIMLib.addReceiveMessageListener((res) => {
@@ -173,7 +176,8 @@ const newMessage = (msg) => {
syncUserInfo(msg.targetId)
}
store.dispatch('newMessage', msg)
uni.$emit('onReceiveMessage', msg);
// store.dispatch('newMessage', msg)
}
function syncUserInfo(targetId) {