新好友提醒优化
This commit is contained in:
@@ -57,13 +57,7 @@
|
|||||||
onLoad() {
|
onLoad() {
|
||||||
this.getFriendList()
|
this.getFriendList()
|
||||||
this.checkNewFriendPending()
|
this.checkNewFriendPending()
|
||||||
uni.$on('onContactNotification', () => {
|
uni.$on('onContactNotification', this.checkNewFriendPending)
|
||||||
this.checkNewFriendPending()
|
|
||||||
this.getFriendList()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
onUnload() {
|
|
||||||
uni.$off('onContactNotification')
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getFriendList() {
|
getFriendList() {
|
||||||
|
|||||||
@@ -29,9 +29,6 @@
|
|||||||
this.getPendingList()
|
this.getPendingList()
|
||||||
uni.$on('onContactNotification', this.getPendingList)
|
uni.$on('onContactNotification', this.getPendingList)
|
||||||
},
|
},
|
||||||
onUnload() {
|
|
||||||
uni.$off('onContactNotification')
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
getPendingList() {
|
getPendingList() {
|
||||||
im.getPendingList((pendings) => {
|
im.getPendingList((pendings) => {
|
||||||
|
|||||||
@@ -54,15 +54,19 @@
|
|||||||
onLoad() {
|
onLoad() {
|
||||||
// 好友申请数量
|
// 好友申请数量
|
||||||
this.checkNewFriendPending()
|
this.checkNewFriendPending()
|
||||||
uni.$on('onConnectionStatusChange', (status) => {
|
// 监听新的好友申请
|
||||||
this.connection = status
|
uni.$on('onContactNotification', () => {
|
||||||
|
console.log('监听申请');
|
||||||
|
this.checkNewFriendPending()
|
||||||
})
|
})
|
||||||
uni.$on('onContactNotification', this.checkNewFriendPending)
|
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
if (this.$store.state.token !== '') {
|
if (this.$store.state.token !== '') {
|
||||||
this.getConversationList()
|
this.getConversationList()
|
||||||
}
|
}
|
||||||
|
uni.$on('onConnectionStatusChange', (status) => {
|
||||||
|
this.connection = status
|
||||||
|
})
|
||||||
// 监听新消息
|
// 监听新消息
|
||||||
uni.$on('onReceiveMessage', (msg) => {
|
uni.$on('onReceiveMessage', (msg) => {
|
||||||
this.getConversationList()
|
this.getConversationList()
|
||||||
@@ -73,7 +77,9 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
checkNewFriendPending() {
|
checkNewFriendPending() {
|
||||||
|
console.log('触发新申请好友事件');
|
||||||
im.getPendingList((pendings) => {
|
im.getPendingList((pendings) => {
|
||||||
|
console.log(pendings);
|
||||||
this.hasNewFriends = pendings.length
|
this.hasNewFriends = pendings.length
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ const addListeners = () => {
|
|||||||
console.log('消息删除结果', code)
|
console.log('消息删除结果', code)
|
||||||
})
|
})
|
||||||
} else if (message.objectName === RongIMLib.ObjectName.ContactNotification) {
|
} else if (message.objectName === RongIMLib.ObjectName.ContactNotification) {
|
||||||
|
console.log('onContactNotification');
|
||||||
// 触发一个新好友的通知事件
|
// 触发一个新好友的通知事件
|
||||||
uni.$emit('onContactNotification', message.content)
|
uni.$emit('onContactNotification', message.content)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user