群解散时,无论在群组中的哪个页面,都退回到会话列表页面

This commit is contained in:
2022-02-23 14:13:38 +08:00
parent 8b10fd95fe
commit 1407d677de
21 changed files with 197 additions and 136 deletions

View File

@@ -7,7 +7,7 @@
export default { export default {
onLaunch: function() { onLaunch: function() {
im.initIm('lmxuhwaglu76d') im.initIm('lmxuhwaglu76d')
return
//#ifdef APP-PLUS //#ifdef APP-PLUS
// 获取系统版本号 // 获取系统版本号
getVersions({ getVersions({

View File

@@ -69,8 +69,10 @@
// 不管是通过还是拒绝,都要把相关的信息清理 // 不管是通过还是拒绝,都要把相关的信息清理
clearMessages() { clearMessages() {
RongIMLib.deleteMessages(RongIMLib.ConversationType.SYSTEM, this.message.sourceUserId) RongIMLib.deleteMessages(RongIMLib.ConversationType.SYSTEM, this.message.sourceUserId)
this.$emit('success') this.$emit('success')
uni.$emit('onContactNotification') uni.$emit('onNewContactConversation', message)
uni.$emit('onNewContactFriends', message)
uni.$emit('onNewContactPendings', message)
} }
} }
} }

View File

@@ -54,8 +54,8 @@
return { return {
users: [], users: [],
isOwner: false, isOwner: false,
isAdmin: false, isAdmin: false,
canInvite:false,// 是否可以开启邀请 canInvite: false, // 是否可以开启邀请
adminUid: 0, adminUid: 0,
members: 0, members: 0,
actionShow: false, actionShow: false,
@@ -82,8 +82,7 @@
}, },
mounted() { mounted() {
this.initGroupInfo() this.initGroupInfo()
getGroupUsers(this.targetId, this.count).then(res => { getGroupUsers(this.targetId, this.count).then(res => {
console.log("res..",res)
this.users = res this.users = res
res.map(item => { res.map(item => {
this.$store.dispatch('updateContact', item) this.$store.dispatch('updateContact', item)
@@ -96,7 +95,7 @@
this.isOwner = res.is_owner this.isOwner = res.is_owner
this.isAdmin = res.is_admin this.isAdmin = res.is_admin
this.adminUid = res.user_id this.adminUid = res.user_id
this.members = res.members this.members = res.members
this.canInvite = res.can_invite this.canInvite = res.can_invite
}) })
}, },

View File

@@ -6,8 +6,10 @@
</view> </view>
<view class="content"> <view class="content">
<view class="header"> <view class="header">
<view class="name">{{ contact(item.targetId).name }} <text v-if="item.conversationType === 3" <view class="name">
class='qun'>[]</text></view> {{ contact(item.targetId).name }}
<text v-if="item.conversationType === 3" class='group'>[]</text>
</view>
<view class="time">{{ item.sentTime|timeCustomCN }}</view> <view class="time">{{ item.sentTime|timeCustomCN }}</view>
</view> </view>
<message-preview class="preview" :msg="item.latestMessage" :draft="item.draft" <message-preview class="preview" :msg="item.latestMessage" :draft="item.draft"
@@ -80,10 +82,8 @@
.name { .name {
font-size: $title-size + 2; font-size: $title-size + 2;
color: #454545; color: #454545;
display: flex;
align-items: center;
.qun { .group {
color: $main-color; color: $main-color;
font-size: $title-size-m - 4; font-size: $title-size-m - 4;
margin-left: 4px; margin-left: 4px;

View File

@@ -75,11 +75,6 @@
} }
}) })
}, },
created() {
console.log(this.message.messageId)
},
methods: { methods: {
// 播放语音消息 // 播放语音消息
startPlay() { startPlay() {

View File

@@ -57,7 +57,10 @@
onLoad() { onLoad() {
this.getFriendList() this.getFriendList()
this.checkNewFriendPending() this.checkNewFriendPending()
uni.$on('onContactNotification', this.checkNewFriendPending) uni.$on('onNewContactFriends', this.checkNewFriendPending)
},
onUnload() {
uni.$off('onNewContactFriends')
}, },
methods: { methods: {
getFriendList() { getFriendList() {

View File

@@ -113,7 +113,6 @@
onLoad(e) { onLoad(e) {
this.targetId = e.targetId this.targetId = e.targetId
getFriendInfo(e.targetId).then(res => { getFriendInfo(e.targetId).then(res => {
console.log(res, "获取朋友的信息")
this.userInfo = res this.userInfo = res
// 获取到用户信息之后,去检查一下要不要更新 // 获取到用户信息之后,去检查一下要不要更新
this.$store.dispatch('updateContact', res) this.$store.dispatch('updateContact', res)
@@ -148,7 +147,7 @@
}) })
}, },
toPrivate() { toPrivate() {
uni.redirectTo({ uni.navigateTo({
url: '/pages/im/private/chat?targetId=' + this.targetId url: '/pages/im/private/chat?targetId=' + this.targetId
}); });
}, },
@@ -228,8 +227,9 @@
}) })
}, },
singleCall(e) { singleCall(e) {
uni.redirectTo({ uni.navigateTo({
url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type + '&isCall=true' url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type +
'&isCall=true'
}) })
} }
} }

View File

@@ -35,10 +35,13 @@
}, },
onLoad() { onLoad() {
this.getPendingList() this.getPendingList()
uni.$on('onContactNotification', this.getPendingList) uni.$on('onNewContactPendings', this.getPendingList)
},
onUnload() {
uni.$off('onNewContactPendings')
}, },
methods: { methods: {
getPendingList() { getPendingList() {
im.getPendingList((pendings) => { im.getPendingList((pendings) => {
if (pendings.length > 0) { if (pendings.length > 0) {
this.bg = '#f9f9f9' this.bg = '#f9f9f9'

View File

@@ -16,8 +16,12 @@
createGroupAnnouncement, createGroupAnnouncement,
getGroupAnnouncement getGroupAnnouncement
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import onGroupDismiss from '@/utils/im/onGroupDismiss.js'
export default { export default {
mixins: [
onGroupDismiss
],
data() { data() {
return { return {
targetId: '', targetId: '',

View File

@@ -35,8 +35,12 @@
deleteGroupAnnouncement, deleteGroupAnnouncement,
topGroupAnnouncement topGroupAnnouncement
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import onGroupDismiss from '@/utils/im/onGroupDismiss.js'
export default { export default {
mixins: [
onGroupDismiss
],
data() { data() {
return { return {
targetId: '', targetId: '',
@@ -54,8 +58,8 @@
name: '置顶该公告', name: '置顶该公告',
disabled: false disabled: false
}], }],
actionTitle: '请选择操作', actionTitle: '请选择操作',
bg:'#fff' bg: '#fff'
} }
}, },
onLoad(e) { onLoad(e) {
@@ -84,11 +88,11 @@
methods: { methods: {
// 获取公告信息 // 获取公告信息
initData() { initData() {
getGroupAnnouncements(this.targetId).then(res => { getGroupAnnouncements(this.targetId).then(res => {
if(res.length>0){ if (res.length > 0) {
this.bg = '#f9f9f9' this.bg = '#f9f9f9'
}else{ } else {
this.bg = '#fff' this.bg = '#fff'
} }
this.announcements = res this.announcements = res
this.loading = false this.loading = false
@@ -183,8 +187,8 @@
.item { .item {
background-color: #fff; background-color: #fff;
padding: $padding $padding + 10 10rpx $padding + 10; padding: $padding $padding + 10 10rpx $padding + 10;
border-bottom: $padding solid #f9f9f9; border-bottom: $padding solid #f9f9f9;
.user { .user {
display: flex; display: flex;
@@ -193,7 +197,7 @@
align-items: center; align-items: center;
box-sizing: border-box; box-sizing: border-box;
font-size: $title-size-m; font-size: $title-size-m;
color: $text-gray-m; color: $text-gray-m;
padding: 10rpx; padding: 10rpx;
.name { .name {
@@ -214,8 +218,8 @@
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
-webkit-line-clamp: 3; -webkit-line-clamp: 3;
overflow: hidden; overflow: hidden;
line-height: 1.5; line-height: 1.5;
border-bottom: solid 1rpx #F9F9F9; border-bottom: solid 1rpx #F9F9F9;
padding-bottom: 20rpx; padding-bottom: 20rpx;
span { span {

View File

@@ -20,8 +20,12 @@
joinGroupPre, joinGroupPre,
joinGroup joinGroup
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import onGroupDismiss from '@/utils/im/onGroupDismiss.js'
export default {
export default {
mixins: [
onGroupDismiss
],
data() { data() {
return { return {
targetId: '', targetId: '',
@@ -45,7 +49,7 @@
mask: true, mask: true,
duration: 3000 duration: 3000
}) })
}) })
}, },
methods: { methods: {
toGroupChat() { toGroupChat() {

View File

@@ -21,8 +21,12 @@
import sentMessageBar from '../components/sentMessageBar' import sentMessageBar from '../components/sentMessageBar'
import showMessageCell from '../components/showMessageCell' import showMessageCell from '../components/showMessageCell'
import utils from '@/utils/index.js' import utils from '@/utils/index.js'
import onGroupDismiss from '@/utils/im/onGroupDismiss.js'
export default {
export default {
mixins: [
onGroupDismiss
],
components: { components: {
sentMessageBar, sentMessageBar,
showMessageCell showMessageCell
@@ -59,11 +63,9 @@
}) })
// 获取历史消息列表 // 获取历史消息列表
this.getMessageList() this.getMessageList()
// 监听收到本群的消息,追加消息 // 监听消息
uni.$on('onReceiveMessage', (msg) => { uni.$on('onReceiveMessage_' + this.targetId, (message) => {
if (msg.targetId == this.targetId) { this.getNewMessage()
this.getNewMessage()
}
}) })
uni.$on('onReceiptRequest', (msg) => { uni.$on('onReceiptRequest', (msg) => {
if (msg.targetId == this.targetId) { if (msg.targetId == this.targetId) {
@@ -101,6 +103,7 @@
}) })
}, },
onUnload() { onUnload() {
uni.$off('onReceiveMessage_' + this.targetId)
uni.$off('onRecallMessage') uni.$off('onRecallMessage')
uni.$off('onReceiptRequest') uni.$off('onReceiptRequest')
uni.$off('onReceiptResponse') uni.$off('onReceiptResponse')
@@ -164,7 +167,7 @@
}, },
onHide() { onHide() {
// console.log(JSON.stringify(this.$refs)) // console.log(JSON.stringify(this.$refs))
this.$refs.voice.stopPlay() // this.$refs.voice.stopPlay()
} }
} }
</script> </script>

View File

@@ -64,12 +64,16 @@
uploads uploads
} from '@/apis/interfaces/uploading' } from '@/apis/interfaces/uploading'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import groupUserList from '../components/groupUserList' import groupUserList from '../components/groupUserList'
import onGroupDismiss from '@/utils/im/onGroupDismiss.js'
export default { export default {
components: { components: {
groupUserList groupUserList
}, },
mixins: [
onGroupDismiss
],
data() { data() {
return { return {
targetId: '', targetId: '',
@@ -133,7 +137,6 @@
return item.key == res.join_type return item.key == res.join_type
})[0].name })[0].name
}).catch(err => { }).catch(err => {
console.log('getGroupInfo ERR', err);
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '群不存在' title: '群不存在'

View File

@@ -8,8 +8,9 @@
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98"> <u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<u-checkbox-group v-if="friends.length > 0" v-model="checkboxValue" placement="column"> <u-checkbox-group v-if="friends.length > 0" v-model="checkboxValue" placement="column">
<u-index-item v-for="(item, fkey) in friends" :key="fkey"> <u-index-item v-for="(item, fkey) in friends" :key="fkey">
<u-index-anchor :text="indexs[fkey]" v-if="indexs[fkey]" bgColor="#f9f9f9f" height="20" size="12" <u-index-anchor :text="indexs[fkey]" v-if="indexs[fkey]" bgColor="#f9f9f9f" height="20"
color="#666" style="border:none !important;padding: 10rpx 30rpx;background-color: #f9f9f9 !important;" /> size="12" color="#666"
style="border:none !important;padding: 10rpx 30rpx;background-color: #f9f9f9 !important;" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex" <view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
@click="addContact(friendItem.targetId)"> @click="addContact(friendItem.targetId)">
<u-checkbox :name="friendItem.targetId" shape="circle" activeColor="#34ce98" <u-checkbox :name="friendItem.targetId" shape="circle" activeColor="#34ce98"
@@ -44,10 +45,13 @@
getGroupUsers getGroupUsers
} from '@/apis/interfaces/im'; } from '@/apis/interfaces/im';
import utils from '@/utils/index.js' import utils from '@/utils/index.js'
import onGroupDismiss from '@/utils/im/onGroupDismiss.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
export default { export default {
mixins: [
onGroupDismiss
],
data() { data() {
return { return {
searchTxt: '', searchTxt: '',
@@ -80,11 +84,11 @@
}) })
return resList return resList
}) })
this.indexs = this.orignalIndexs.map((t, i) => { this.indexs = this.orignalIndexs.map((t, i) => {
if (this.friends[i].length > 0) { if (this.friends[i].length > 0) {
return t return t
} }
}) })
} else { } else {
this.friends = this.orignalFriends this.friends = this.orignalFriends
this.indexs = this.orignalIndexs this.indexs = this.orignalIndexs
@@ -101,7 +105,7 @@
this.orignalIndexs = res.indexList this.orignalIndexs = res.indexList
}) })
getGroupUsers(this.targetId).then(res => { getGroupUsers(this.targetId).then(res => {
res.map(res => { res.map(res => {
console.log(res) console.log(res)
this.checkboxValue.push(String(res.targetId)) this.checkboxValue.push(String(res.targetId))
this.selectValue.push(String(res.targetId)) this.selectValue.push(String(res.targetId))
@@ -122,17 +126,17 @@
} }
}, },
onInvite() { onInvite() {
console.log(this.checkboxValue,'userIds.....') console.log(this.checkboxValue, 'userIds.....')
console.log(this.selectValue,'userIds.....') console.log(this.selectValue, 'userIds.....')
let userIds = [] let userIds = []
this.checkboxValue.filter(item=>{ this.checkboxValue.filter(item => {
if(!utils.inArray(item, this.selectValue)){ if (!utils.inArray(item, this.selectValue)) {
userIds.push(item) userIds.push(item)
} }
}) })
// console.log(userIds) // console.log(userIds)
inviteGroupUser(this.targetId, this.checkboxValue,userIds).then(res => { inviteGroupUser(this.targetId, this.checkboxValue, userIds).then(res => {
uni.navigateBack({ uni.navigateBack({
delta: 1, delta: 1,
animationType: 'pop-out', animationType: 'pop-out',

View File

@@ -3,7 +3,7 @@
<view class="reviewed"> <view class="reviewed">
<block v-if="pendings.length > 0"> <block v-if="pendings.length > 0">
<view class="reviewed-item" v-for="(item, index) in pendings" :key="index"> <view class="reviewed-item" v-for="(item, index) in pendings" :key="index">
<u-avatar class="avatar" <u-avatar class="avatar"
:src="JSON.parse(item.content.extra).portraitUrl || require('@/static/user/cover.png')" :src="JSON.parse(item.content.extra).portraitUrl || require('@/static/user/cover.png')"
shape="square" size="46" /> shape="square" size="46" />
<view style="flex:1;" v-if="item.content.operation == 'GroupPending'"> <view style="flex:1;" v-if="item.content.operation == 'GroupPending'">
@@ -34,9 +34,12 @@
} from "@/apis/interfaces/im.js" } from "@/apis/interfaces/im.js"
import im from '@/utils/im/message.js' import im from '@/utils/im/message.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import onGroupDismiss from '@/utils/im/onGroupDismiss.js'
export default { export default {
mixins: [
onGroupDismiss
],
data() { data() {
return { return {
targetId: '', targetId: '',
@@ -86,21 +89,21 @@
// icon: 'none', // icon: 'none',
// mask: true, // mask: true,
// duration: 2000 // duration: 2000
// }) // })
RongIMLib.deleteMessagesByIds([latestMessageId], ({ RongIMLib.deleteMessagesByIds([latestMessageId], ({
code code
}) => { }) => {
console.log('code', code) console.log('code', code)
if (code == 0) { if (code == 0) {
uni.showToast({ uni.showToast({
title:err.message, title: err.message,
icon: 'none', icon: 'none',
mask: true, mask: true,
duration: 2000 duration: 2000
}) })
this.getList() this.getList()
uni.$emit('groupInvitedUser') uni.$emit('groupInvitedUser')
} }
}) })
}) })
// 直接调用通过或拒绝的接口 // 直接调用通过或拒绝的接口
@@ -153,6 +156,7 @@
} }
} }
.no-lists { .no-lists {
padding-top: $padding * 5; padding-top: $padding * 5;
display: flex; display: flex;

View File

@@ -4,7 +4,12 @@
<script> <script>
import groupUserList from '../components/groupUserList' import groupUserList from '../components/groupUserList'
import onGroupDismiss from '@/utils/im/onGroupDismiss.js'
export default { export default {
mixins: [
onGroupDismiss
],
components: { components: {
groupUserList groupUserList
}, },

View File

@@ -57,24 +57,28 @@
// 好友申请数量 // 好友申请数量
this.checkNewFriendPending() this.checkNewFriendPending()
// 监听新的好友申请 // 监听新的好友申请
uni.$on('onContactNotification', () => { uni.$on('onNewContactConversation', this.checkNewFriendPending)
this.checkNewFriendPending()
})
}, },
onShow() { onShow() {
if (this.$store.state.token !== '') { if (this.$store.state.token !== '') {
this.getConversationList() this.getConversationList()
} }
uni.$on('onConnectionStatusChange', (status) => {
this.connection = status
})
// 监听新消息 // 监听新消息
uni.$on('onReceiveMessage', (msg) => { uni.$on('onReceiveMessage', (msg) => {
this.getConversationList() this.getConversationList()
}) })
// 监听网络状态变化
uni.$on('onConnectionStatusChange', (status) => {
this.connection = status
if (status == 0) {
this.getConversationList()
}
})
}, },
onHide() { onHide() {
// 页面隐藏的时候,不监听了,性能可能会好一点
uni.$off('onReceiveMessage') uni.$off('onReceiveMessage')
uni.$off('onConnectionStatusChange')
}, },
methods: { methods: {
checkNewFriendPending() { checkNewFriendPending() {

View File

@@ -150,7 +150,7 @@
} else { } else {
IMLib.insertIncomingMessage(1, targetId, targetId, sentStatus, messageContent, sentTime) IMLib.insertIncomingMessage(1, targetId, targetId, sentStatus, messageContent, sentTime)
} }
uni.$emit('onReceiveMessage', { uni.$emit('onReceiveMessage_' + this.targetId, {
targetId: this.targetId targetId: this.targetId
}) })
}, },

View File

@@ -4,8 +4,8 @@
<!-- chat --> <!-- chat -->
<view class="body"> <view class="body">
<view class="scroll"> <view class="scroll">
<view class="cell" v-for="(message, index) in messages" :key="index"> <view class="cell" v-for="(message, index) in messages" :key="index">
<show-message-cell :message="message" /> <show-message-cell :message="message" />
</view> </view>
</view> </view>
</view> </view>
@@ -60,6 +60,10 @@
}) })
// 获取消息列表 // 获取消息列表
this.getMessageList() this.getMessageList()
// 监听新消息
uni.$on('onReceiveMessage_' + this.targetId, (message) => {
this.getNewMessage()
})
// 监听消息已读状态 // 监听消息已读状态
uni.$on('onReadReceiptReceived', (data) => { uni.$on('onReadReceiptReceived', (data) => {
if (data.targetId == this.targetId) { if (data.targetId == this.targetId) {
@@ -72,25 +76,20 @@
}) })
} }
}) })
// 监听收到新消息,判断是否是当前会话,更新会话内容 uni.$on('onRecallMessage', (res) => {
uni.$on('onReceiveMessage', (msg) => { if (res.targetId == this.targetId) {
if (msg.targetId == this.targetId) { this.messages = this.messages.map(item => {
this.getNewMessage() if (res.messageId == item.messageId) {
return res
} else {
return item
}
})
} }
})
uni.$on('onRecallMessage', (res) => {
if (res.targetId == this.targetId) {
this.messages = this.messages.map(item => {
if (res.messageId == item.messageId) {
return res
} else {
return item
}
})
}
}) })
}, },
onUnload() { onUnload() {
uni.$off('onReceiveMessage_' + this.targetId)
uni.$off('onRecallMessage') uni.$off('onRecallMessage')
uni.$off('onReadReceiptReceived') uni.$off('onReadReceiptReceived')
}, },

View File

@@ -20,7 +20,28 @@ const onReceiveMessage = (message) => {
} }
}) })
im.setNotifyBadge() im.setNotifyBadge()
// 发布全局事件,有新消息,刷新会话列表
uni.$emit('onReceiveMessage', message) uni.$emit('onReceiveMessage', message)
// 这个是为了更新消息列表页的
uni.$emit('onReceiveMessage_' + message.targetId, message)
}
// 检测联系人信息,不存在的时候,从服务端获取
const checkContactExists = (message) => {
if (!store.getters.contactIsExist(message.targetId)) {
getUserInfo(message.targetId).then(res => {
store.dispatch('initContact', res)
}).catch(err => {
console.error('getUserInfo ERR', err)
})
}
if (!store.getters.contactIsExist(message.senderUserId)) {
getUserInfo(message.senderUserId).then(res => {
store.dispatch('initContact', res)
}).catch(err => {
console.error('getUserInfo ERR', err)
})
}
} }
// 允许通知的消息类型,触发更新消息列表操作,提示音 // 允许通知的消息类型,触发更新消息列表操作,提示音
@@ -32,10 +53,7 @@ const notifyMsgTypes = [
IMLib.ObjectName.Location, IMLib.ObjectName.Location,
IMLib.ObjectName.Voice, IMLib.ObjectName.Voice,
IMLib.ObjectName.HQVoice, IMLib.ObjectName.HQVoice,
IMLib.ObjectName.Sight, IMLib.ObjectName.Sight
IMLib.ObjectName.Text,
IMLib.ObjectName.Text,
IMLib.ObjectName.Text
] ]
const imLibListeners = () => { const imLibListeners = () => {
@@ -48,31 +66,19 @@ const imLibListeners = () => {
IMLib.addReceiveMessageListener((res) => { IMLib.addReceiveMessageListener((res) => {
const message = res.data.message const message = res.data.message
console.error('[收到消息]', message) console.error('[收到消息]', message)
checkContactExists(message)
if (utils.inArray(message.objectName, notifyMsgTypes)) { if (utils.inArray(message.objectName, notifyMsgTypes)) {
if (!store.getters.contactIsExist(message.targetId)) {
getUserInfo(message.targetId).then(res => {
store.dispatch('initContact', res)
}).catch(err => {
console.error('getUserInfo ERR', err)
})
}
if (!store.getters.contactIsExist(message.senderUserId)) {
getUserInfo(message.senderUserId).then(res => {
store.dispatch('initContact', res)
}).catch(err => {
console.error('getUserInfo ERR', err)
})
}
onReceiveMessage(message) onReceiveMessage(message)
} else if (message.objectName === IMLib.ObjectName.ProfileNotification) { } else if (message.objectName === IMLib.ObjectName.ProfileNotification) {
// 更新会话信息 // 更新联系人信息
store.dispatch('updateContact', JSON.parse(message.content.data)) store.dispatch('updateContact', JSON.parse(message.content.data))
// 调用完更新之后,删除这条消息 // 调用完更新之后,删除这条消息
IMLib.deleteMessagesByIds([message.messageId]) IMLib.deleteMessagesByIds([message.messageId])
} else if (message.objectName === IMLib.ObjectName.ContactNotification) { } else if (message.objectName === IMLib.ObjectName.ContactNotification) {
console.error('触发一个新好友的通知事件', message); // 触发一个新好友的通知事件,【会话列表,通讯录,新朋友】页面
// 触发一个新好友的通知事件 uni.$emit('onNewContactConversation', message)
uni.$emit('onContactNotification', message) uni.$emit('onNewContactFriends', message)
uni.$emit('onNewContactPendings', message)
} else if (message.objectName === IMLib.ObjectName.GroupNotification) { } else if (message.objectName === IMLib.ObjectName.GroupNotification) {
// 解散群 // 解散群
if (message.content.operation === 'Dismiss') { if (message.content.operation === 'Dismiss') {
@@ -80,8 +86,11 @@ const imLibListeners = () => {
false) false)
// 解散了就删了吧 // 解散了就删了吧
IMLib.removeConversation(message.conversationType, message.targetId) IMLib.removeConversation(message.conversationType, message.targetId)
uni.$emit('onGroupDismiss', message.targetId) // 发布群解散的消息
uni.$emit('onGroupDismiss')
uni.$emit('onGroupDismiss_' + message.targetId)
} }
// 触发刷新会话列表
uni.$emit('onReceiveMessage', message) uni.$emit('onReceiveMessage', message)
} }
}) })
@@ -118,7 +127,7 @@ const imLibListeners = () => {
readers readers
}) })
// 在消息的扩展数据中,设置已读数量 // 在消息的扩展数据中,设置已读数量
IMLib.setMessageExtra(message.messageId, extra, (result) => { IMLib.setMessageExtra(message.messageId, extra, (result) => {
message.extra = extra message.extra = extra
uni.$emit('onReceiptResponse', message) uni.$emit('onReceiptResponse', message)
}) })

View File

@@ -0,0 +1,16 @@
// 监听群解散的消息,直接跳转到会话列表页面
const onGroupDismiss = {
onLoad(e) {
uni.$once('onGroupDismiss_' + e.targetId, () => {
uni.showToast({
icon: 'none',
title: '当前群已解散'
})
uni.switchTab({
url: '/pages/im/index'
})
})
}
}
export default onGroupDismiss