From fe9b79a18d5378b6b1fbcfd99c67d483e6a053d3 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 16 Feb 2022 16:29:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=A4=E5=A4=B4=E5=83=8F=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E5=90=8C=E6=AD=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/im/components/groupUserList.vue | 47 +++++++++++++++------------ pages/im/group/chat.nvue | 3 +- pages/im/group/info.vue | 4 +-- pages/im/private/chat.nvue | 2 +- store/modules/im.js | 10 +++--- utils/im/index.js | 3 +- 6 files changed, 37 insertions(+), 32 deletions(-) diff --git a/pages/im/components/groupUserList.vue b/pages/im/components/groupUserList.vue index c328223..4efd6f6 100644 --- a/pages/im/components/groupUserList.vue +++ b/pages/im/components/groupUserList.vue @@ -3,13 +3,14 @@ - + {{ item.name }} 管理 群主 - + 邀请好友 @@ -49,15 +50,20 @@ return { users: [], isOwner: false, - isAdmin: false, + isAdmin: false, adminUid: 0, members: 0, actionShow: false, actionMap: [], actionTitle: '', - currentUser: {} + currentUser: {}, + avatarSize: 40 } }, + created() { + this.avatarSize = 126 / 750 * wx.getSystemInfoSync().windowWidth + console.log(this.avatarSize) + }, mounted() { this.initGroupInfo() this.initUsers() @@ -66,7 +72,7 @@ initGroupInfo() { getGroupBase(this.targetId).then(res => { this.isOwner = res.is_owner - this.isAdmin = res.is_admin + this.isAdmin = res.is_admin this.adminUid = res.user_id this.members = res.members }) @@ -79,8 +85,6 @@ }, hideAction(item) { this.actionShow = false - this.actionTitle = '' - this.currentUser = {} }, showAction(item) { this.currentUser = item @@ -180,6 +184,7 @@ content: '这个操作不可逆转,确定要转让群主身份么?', success: (res) => { if (res.confirm) { + console.log(this.targetId, this.currentUser.targetId); transferGroupOwner(this.targetId, this.currentUser.targetId).then( res => { uni.showToast({ @@ -245,7 +250,7 @@ display: flex; flex-direction: column; justify-content: center; - align-items: center; + align-items: center; border-radius: 0 10rpx 0 0; &.active { @@ -274,19 +279,19 @@ text-align: center; right: -45rpx; top: -20rpx; - } - - .owner { - position: absolute; - background-color: $text-price; - transform: rotate(45deg); - color: #ffffff; - font-size: 12rpx; - width: 100rpx; - padding-top: 30rpx; - text-align: center; - right: -45rpx; - top: -20rpx; + } + + .owner { + position: absolute; + background-color: $text-price; + transform: rotate(45deg); + color: #ffffff; + font-size: 12rpx; + width: 100rpx; + padding-top: 30rpx; + text-align: center; + right: -45rpx; + top: -20rpx; } } } diff --git a/pages/im/group/chat.nvue b/pages/im/group/chat.nvue index b597f7a..a601c61 100644 --- a/pages/im/group/chat.nvue +++ b/pages/im/group/chat.nvue @@ -5,7 +5,6 @@ - @@ -54,7 +53,7 @@ }, computed: { latestMessage() { - if (this.messages.length > 1) { + if (this.messages.length) { return this.messages[this.messages.length - 1] } else { return { diff --git a/pages/im/group/info.vue b/pages/im/group/info.vue index b86f58a..a6cced9 100644 --- a/pages/im/group/info.vue +++ b/pages/im/group/info.vue @@ -17,8 +17,8 @@ - - + + diff --git a/pages/im/private/chat.nvue b/pages/im/private/chat.nvue index 02dfc0f..1dba707 100644 --- a/pages/im/private/chat.nvue +++ b/pages/im/private/chat.nvue @@ -62,7 +62,7 @@ }, computed: { latestMessage() { - if (this.messages.length > 1) { + if (this.messages.length) { return this.messages[this.messages.length - 1] } else { return { diff --git a/store/modules/im.js b/store/modules/im.js index 8077e66..6526937 100644 --- a/store/modules/im.js +++ b/store/modules/im.js @@ -34,7 +34,7 @@ export default { } }, mutations: { - updateContactInfo(state, contactInfo) { + updateContactInfo(state, contactInfo) { Vue.set(state.contacts, contactInfo.targetId, contactInfo) }, setSenderInfo(state, contactInfo) { @@ -68,7 +68,6 @@ export default { // 没有数据,直接新增一条 dispatch('initContact', contactInfo) } else if (contactInfo.hash != result[0].hash) { - commit('updateContactInfo', contactInfo) if (contactInfo.portraitUrl && contactInfo.portraitUrl != result[0].portraitUrl) { saveAvatar(contactInfo, (savedFilePath) => { const info = { @@ -79,8 +78,8 @@ export default { localAvatar: savedFilePath } model.update('targetId="' + contactInfo.targetId + '"', info, (err, - res) => { - console.log('UPDATE AVATAR, ERR', err); + res) => { + console.log('UPDATE AVATAR, ERR', err, info); }) commit('updateContactInfo', info) }) @@ -93,8 +92,9 @@ export default { localAvatar: result[0].localAvatar } model.update('targetId="' + contactInfo.targetId + '"', info, (err, res) => { - console.log('UPDATE NAME, ERR', err); + console.log('UPDATE NAME, ERR', err, info); }) + commit('updateContactInfo', info) } } else { console.log('updateContact, 无操作'); diff --git a/utils/im/index.js b/utils/im/index.js index 7f52693..59e44cc 100644 --- a/utils/im/index.js +++ b/utils/im/index.js @@ -150,7 +150,8 @@ const addListeners = () => { }) } newMessage(message) - } else if (message.objectName === RongIMLib.ObjectName.ProfileNotification) { + } else if (message.objectName === RongIMLib.ObjectName.ProfileNotification) { + // 更新会话信息 store.dispatch('updateContact', JSON.parse(message.content.data)) // 调用完更新之后,删除这条消息 RongIMLib.deleteMessagesByIds([message.messageId], ({