This commit is contained in:
2022-02-23 17:08:28 +08:00
parent 2ce4bb827f
commit 1d648f2dc1
2 changed files with 21 additions and 10 deletions

View File

@@ -5,7 +5,9 @@
<view class="custom-header">
<view class="header-flex">
<view class="tabs">
<view class="item active">聊聊</view>
<view class="item" @click="tabsClick('all')" :class="activeId === 'all'?'active':''">全部</view>
<view class="item" @click="tabsClick('self')" :class="activeId === 'self'?'active':''">私聊</view>
<view class="item" @click="tabsClick('group')" :class="activeId === 'group'?'active':''">群聊</view>
</view>
<view class="btns">
<view class="item" @click="scanQrCode">
@@ -46,7 +48,8 @@
return {
conversations: [], // 会话列表
connection: 0,
hasNewFriends: 0
hasNewFriends: 0,
activeId:'all',
}
},
components: {
@@ -54,12 +57,14 @@
connectionStatus
},
onLoad() {
// 好友申请数量
this.checkNewFriendPending()
// 监听新的好友申请
uni.$on('onNewContactConversation', this.checkNewFriendPending)
},
onShow() {
onShow() {
// 好友申请数量
this.checkNewFriendPending()
if (this.$store.state.token !== '') {
this.getConversationList()
}
@@ -76,11 +81,14 @@
})
},
onHide() {
// 页面隐藏的时候,不监听了,性能可能会好一点
uni.$off('onReceiveMessage')
uni.$off('onConnectionStatusChange')
},
methods: {
methods: {
// 切换聊天模式
tabsClick(type){
this.activeId = type
},
checkNewFriendPending() {
im.getPendingList((pendings) => {
this.hasNewFriends = pendings.length
@@ -103,7 +111,9 @@
code,
conversations
}) => {
if (code === 0) {
if (code === 0) {
console.log(conversations)
console.log("item.conversationType === 3............")
this.conversations = conversations
}
})