根据事件广播,更新好友申请的数量提醒

This commit is contained in:
2022-02-09 12:01:36 +08:00
parent fbf9d7db31
commit 1678fd6e80
8 changed files with 200 additions and 92 deletions

View File

@@ -20,7 +20,7 @@
<uni-icons color="#555" type="scan" size="22" />
</view>
<view class="item" @click="onNav('imFriends', {})">
<u-badge absolute max="99" isDot :offset="[0, 0]" :show="hasNewFriends" />
<u-badge absolute max="99" :offset="[-5, -5]" :value="hasNewFriends" />
<uni-icons color="#555" custom-prefix="iconfont" type="icon-tuandui" size="22" />
</view>
</view>
@@ -72,7 +72,7 @@
</template>
<script>
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import im from '@/utils/im/index.js'
import userAuth from '@/public/userAuth'
import messagePreview from './components/messagePreview'
@@ -96,7 +96,7 @@
pickedItem: {},
privateUnread: 0,
groupUnread: 0,
hasNewFriends: true
hasNewFriends: 0
}
},
components: {
@@ -109,15 +109,19 @@
}
}
},
onLoad() {
onLoad() {
// 好友申请数量
this.checkNewFriendPending()
uni.$on('onConnectionStatusChange', (status) => {
this.connection = status
})
uni.$on('onContactNotification', this.checkNewFriendPending)
},
onShow() {
if (this.$store.state.token !== '') {
this.getConversationList()
}
}
// 监听新消息
uni.$on('onReceiveMessage', (msg) => {
console.log('收到消息,刷新列表');
this.getConversationList()
@@ -150,6 +154,16 @@
}
},
methods: {
checkNewFriendPending() {
// 获取是否有新的好友申请
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], 1000, 0, (res) => {
if (res.code === 0) {
this.hasNewFriends = res.conversations.filter((item) => {
return item.objectName == RongIMLib.ObjectName.ContactNotification
}).length
}
})
},
// 隐藏功能菜单
hidePop() {
this.showPop = false