新好友提醒优化
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -29,9 +29,6 @@
|
||||
this.getPendingList()
|
||||
uni.$on('onContactNotification', this.getPendingList)
|
||||
},
|
||||
onUnload() {
|
||||
uni.$off('onContactNotification')
|
||||
},
|
||||
methods: {
|
||||
getPendingList() {
|
||||
im.getPendingList((pendings) => {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user