新好友提醒优化

This commit is contained in:
2022-02-16 18:00:23 +08:00
parent ff334c1cb0
commit 3eb7b80496
4 changed files with 20 additions and 22 deletions

View File

@@ -57,13 +57,7 @@
onLoad() {
this.getFriendList()
this.checkNewFriendPending()
uni.$on('onContactNotification', () => {
this.checkNewFriendPending()
this.getFriendList()
})
},
onUnload() {
uni.$off('onContactNotification')
uni.$on('onContactNotification', this.checkNewFriendPending)
},
methods: {
getFriendList() {
@@ -83,11 +77,11 @@
})
},
toGroup() {
uni.navigateTo({
url: '/pages/im/group/index',
fail(err) {
console.log(err);
}
uni.navigateTo({
url: '/pages/im/group/index',
fail(err) {
console.log(err);
}
})
},
toFriend(targetId) {

View File

@@ -29,9 +29,6 @@
this.getPendingList()
uni.$on('onContactNotification', this.getPendingList)
},
onUnload() {
uni.$off('onContactNotification')
},
methods: {
getPendingList() {
im.getPendingList((pendings) => {

View File

@@ -53,16 +53,20 @@
},
onLoad() {
// 好友申请数量
this.checkNewFriendPending()
uni.$on('onConnectionStatusChange', (status) => {
this.connection = status
this.checkNewFriendPending()
// 监听新的好友申请
uni.$on('onContactNotification', () => {
console.log('监听申请');
this.checkNewFriendPending()
})
uni.$on('onContactNotification', this.checkNewFriendPending)
},
onShow() {
if (this.$store.state.token !== '') {
this.getConversationList()
}
uni.$on('onConnectionStatusChange', (status) => {
this.connection = status
})
// 监听新消息
uni.$on('onReceiveMessage', (msg) => {
this.getConversationList()
@@ -73,7 +77,9 @@
},
methods: {
checkNewFriendPending() {
im.getPendingList((pendings) => {
console.log('触发新申请好友事件');
im.getPendingList((pendings) => {
console.log(pendings);
this.hasNewFriends = pendings.length
})
},
@@ -91,7 +97,7 @@
const count = 1000
const timestamp = 0
RongIMLib.getConversationList([1, 3], count, timestamp, (res) => {
if (res.code === 0) {
if (res.code === 0) {
this.conversations = res.conversations
}
})