im-MIXINS
This commit is contained in:
@@ -5,9 +5,7 @@
|
||||
<view class="custom-header">
|
||||
<view class="header-flex">
|
||||
<view class="tabs">
|
||||
<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 class="item active">聊聊</view>
|
||||
</view>
|
||||
<view class="btns">
|
||||
<view class="item" @click="scanQrCode">
|
||||
@@ -41,15 +39,14 @@
|
||||
import im from '@/utils/im/index.js'
|
||||
import userAuth from '@/public/userAuth'
|
||||
import conversationList from './components/conversationList'
|
||||
import connectionStatus from './components/connectionStatus'
|
||||
import connectionStatus from './components/connectionStatus'
|
||||
|
||||
export default {
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
conversations: [], // 会话列表
|
||||
connection: 0,
|
||||
hasNewFriends: 0,
|
||||
activeId:'all',
|
||||
hasNewFriends: 0
|
||||
}
|
||||
},
|
||||
components: {
|
||||
@@ -57,18 +54,17 @@
|
||||
connectionStatus
|
||||
},
|
||||
onLoad() {
|
||||
|
||||
// 监听新的好友申请
|
||||
uni.$on('onNewContactConversation', () => {
|
||||
uni.$on('onNewContactConversation', () => {
|
||||
console.log('更新好友申请数量');
|
||||
// 更新好友申请数量
|
||||
this.checkNewFriendPending()
|
||||
})
|
||||
},
|
||||
onShow() {
|
||||
// 好友申请数量
|
||||
this.checkNewFriendPending()
|
||||
|
||||
onShow() {
|
||||
// 好友申请数量
|
||||
this.checkNewFriendPending()
|
||||
|
||||
if (this.$store.state.token !== '') {
|
||||
this.getConversationList()
|
||||
}
|
||||
@@ -88,11 +84,7 @@
|
||||
uni.$off('onReceiveMessage')
|
||||
uni.$off('onConnectionStatusChange')
|
||||
},
|
||||
methods: {
|
||||
// 切换聊天模式
|
||||
tabsClick(type){
|
||||
this.activeId = type
|
||||
},
|
||||
methods: {
|
||||
checkNewFriendPending() {
|
||||
im.getPendingList((pendings) => {
|
||||
this.hasNewFriends = pendings.length
|
||||
@@ -107,17 +99,15 @@
|
||||
}
|
||||
return true
|
||||
},
|
||||
// 获取私聊的会话列表
|
||||
// 获取会话列表,最新的一千条
|
||||
getConversationList() {
|
||||
const count = 1000
|
||||
const count = 200
|
||||
const timestamp = 0
|
||||
RongIMLib.getConversationList([1, 3], count, timestamp, ({
|
||||
code,
|
||||
conversations
|
||||
}) => {
|
||||
if (code === 0) {
|
||||
console.log(conversations)
|
||||
console.log("item.conversationType === 3............")
|
||||
if (code === 0) {
|
||||
this.conversations = conversations
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user