diff --git a/apis/interfaces/im.js b/apis/interfaces/im.js index 0f0e1af..11c75be 100644 --- a/apis/interfaces/im.js +++ b/apis/interfaces/im.js @@ -88,9 +88,9 @@ const searchFriend = (value) => { const pedingFriend = (recipient, message) => { return request({ method: 'POST', - url: 'im/friends/' + recipient, - data: { - message + url: 'im/friends/' + recipient, + data: { + message } }) } @@ -120,7 +120,7 @@ const getGroupBase = (groupId) => { }) } -const getGroupUsers = (groupId, limit) => { +const getGroupUsers = (groupId, limit) => { limit = limit || 0 return request({ url: 'im/groups/' + groupId + '/users?limit=' + limit @@ -141,9 +141,9 @@ const createGroupAnnouncement = (groupId, content) => { content: content } }) -} +} // 查看该公告详情 -const getGroupAnnouncement = (groupId, announcementId) => { +const getGroupAnnouncement = (groupId, announcementId) => { return request({ method: 'GET', url: 'im/groups/' + groupId + '/announcements/' + announcementId @@ -155,12 +155,12 @@ const deleteGroupAnnouncement = (groupId, announcementId) => { method: 'DELETE', url: 'im/groups/' + groupId + '/announcements/' + announcementId }) -} -// 置顶群公告 -const topGroupAnnouncement = (groupId, announcementId) => { +} +// 置顶群公告 +const topGroupAnnouncement = (groupId, announcementId) => { return request({ method: 'POST', - url: 'im/groups/' + groupId + '/announcements/' + announcementId+'/top', + url: 'im/groups/' + groupId + '/announcements/' + announcementId + '/top', }) } @@ -241,12 +241,13 @@ const removeGroupUser = (groupId, userId) => { /** * 邀请群成员 */ -const inviteGroupUser = (groupId, userIds) => { +const inviteGroupUser = (groupId, userIds, allowIds) => { return request({ method: 'POST', url: 'im/groups/' + groupId + '/invite', data: { - userIds + userIds: userIds, + allowIds: allowIds } }) } @@ -280,16 +281,16 @@ const transferGroupOwner = (groupId, userId) => { url: 'im/groups/' + groupId + '/owner/' + userId }) } - + // 通过审核验证群成员 -const groupMakeSure = (groupId,user) => { +const groupMakeSure = (groupId, user) => { return request({ - url:`im/groups/${groupId}/makesure/${user}`, - method:'POST' + url: `im/groups/${groupId}/makesure/${user}`, + method: 'POST' }) -} - +} + export { @@ -310,16 +311,16 @@ export { getGroupInfo, getGroupBase, getGroupUsers, - getGroupAnnouncements, + getGroupAnnouncements, getGroupAnnouncement, createGroupAnnouncement, - deleteGroupAnnouncement, + deleteGroupAnnouncement, topGroupAnnouncement, searchGroup, joinGroupPre, joinGroup, quitGroup, - dismissGroup, + dismissGroup, inviteGroupUser, removeGroupUser, setGroupAdmin, diff --git a/pages/im/group/chat.vue b/pages/im/group/chat.vue index b053190..f3297f9 100644 --- a/pages/im/group/chat.vue +++ b/pages/im/group/chat.vue @@ -89,14 +89,25 @@ this.getNewMessage() } }) - uni.$on('onReceiptRequested', (msg) => { + uni.$on('onReceiptRequest', (msg) => { if (msg.targetId == this.targetId) { - console.log('群聊消息是否已读', msg); + RongIMLib.getMessageByUId(msg.messageUId, (result) => { + RongIMLib.sendReadReceiptResponse(3, this.targetId, [result.message], (res) => { + console.error('发送群聊已读回执成功', res); + }) + }) } }) + uni.$on('onReceiptResponse', (msg) => { + console.log('远端消息已读,本地获取有几个人读了', msg); + }) // 清理聊天记录 uni.$once('cleanGroupMessage', this.getMessageList) }, + onUnload() { + uni.$off('onReceiptRequest') + uni.$off('onReceiptResponse') + }, onNavigationBarButtonTap() { uni.navigateTo({ url: '/pages/im/group/info?targetId=' + this.targetId @@ -138,30 +149,13 @@ 20, true, (messages) => { + RongIMLib.sendReadReceiptResponse(3, this.targetId, messages, (res) => { + console.error('发送群聊已读回执成功', res); + }) this.messages = messages this.scrollBottom() }) }, - // 发送已读回执 - sendReadReceiptResponse(messages) { - const msgs = messages.map((item) => { - if (item.receivedStatus == 0) { - return { - conversationType: 3, - targetId: this.targetId, - messageId: item.messageId, - messageDirection: item.messageDirection, - objectName: item.objectName - } - } - }).filter(Boolean) - if (msgs.length) { - console.error('发送群聊已读回执', msgs); - RongIMLib.sendReadReceiptResponse(3, this.targetId, msgs, (res) => { - console.error('发送群聊已读回执成功', res); - }) - } - }, // 滚动到底部 scrollBottom(type) { if (this.latestMessage) { diff --git a/pages/im/group/invite.vue b/pages/im/group/invite.vue index 8ef5a9e..0356cab 100644 --- a/pages/im/group/invite.vue +++ b/pages/im/group/invite.vue @@ -8,8 +8,8 @@ - + { - // if(!utils.inArray(item, this.selectValue)){ - // userIds.push(item) - // } - // }) + let userIds = [] + this.checkboxValue.filter(item=>{ + if(!utils.inArray(item, this.selectValue)){ + userIds.push(item) + } + }) // console.log(userIds) - inviteGroupUser(this.targetId, this.checkboxValue).then(res => { + inviteGroupUser(this.targetId, this.checkboxValue,userIds).then(res => { uni.navigateBack({ delta: 1, animationType: 'pop-out', diff --git a/pages/im/group/reviewed.vue b/pages/im/group/reviewed.vue index 63235b1..2dd2b5b 100644 --- a/pages/im/group/reviewed.vue +++ b/pages/im/group/reviewed.vue @@ -96,7 +96,7 @@ title:err.message, icon: 'none', mask: true, - duration: 500 + duration: 2000 }) this.getList() uni.$emit('groupInvitedUser') diff --git a/utils/im/listeners.js b/utils/im/listeners.js index 23c08b0..81fa163 100644 --- a/utils/im/listeners.js +++ b/utils/im/listeners.js @@ -101,11 +101,11 @@ const imLibListeners = () => { data }) => { console.error('onReceiptRequested', data); - uni.$emit('onReceiptRequested', data) + uni.$emit('onReceiptRequest', data) }) // 群消息已读的回执 IMLib.addReceiptResponseListener((res) => { - console.error('addReceiptResponseListener', res); + console.error('onReceiptResponse', res); }) }