私聊中头像错误展示

This commit is contained in:
2022-02-16 16:58:45 +08:00
parent fe9b79a18d
commit 255a727d32
8 changed files with 43 additions and 38 deletions

View File

@@ -64,7 +64,7 @@
} }
}, },
computed: { computed: {
user() { sender() {
return this.$store.getters.sender return this.$store.getters.sender
} }
}, },
@@ -87,8 +87,7 @@
sourceType: ['album'], sourceType: ['album'],
success: res => { success: res => {
im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0], im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0],
this.user, ( this.sender, (res) => {
res) => {
this.success() this.success()
}) })
} }
@@ -99,8 +98,7 @@
sourceType: ['camera'], sourceType: ['camera'],
success: res => { success: res => {
im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0], im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0],
this.user, ( this.sender, (res) => {
res) => {
this.success() this.success()
}) })
} }

View File

@@ -29,7 +29,7 @@
disabled() { disabled() {
return this.inputTxt.length === 0 return this.inputTxt.length === 0
}, },
user() { sender() {
return this.$store.getters.sender return this.$store.getters.sender
} }
}, },
@@ -50,7 +50,7 @@
sent() { sent() {
if (!this.disabled) { if (!this.disabled) {
RongIMLib.clearTextMessageDraft(this.conversationType, this.targetId) RongIMLib.clearTextMessageDraft(this.conversationType, this.targetId)
im.sentText(this.conversationType, this.targetId, this.inputTxt, this.user, () => { im.sentText(this.conversationType, this.targetId, this.inputTxt, this.sender, () => {
this.$emit('success') this.$emit('success')
this.inputTxt = '' this.inputTxt = ''
}) })

View File

@@ -36,7 +36,7 @@
} }
}, },
computed: { computed: {
user() { sender() {
return this.$store.getters.sender return this.$store.getters.sender
} }
}, },
@@ -85,8 +85,7 @@
// 监听录音结束 // 监听录音结束
this.recorderManager.onStop(res => { this.recorderManager.onStop(res => {
im.sentVoice(this.conversationType, this.targetId, res.tempFilePath, (this.maxRecordTime - im.sentVoice(this.conversationType, this.targetId, res.tempFilePath, (this.maxRecordTime -
this this.recordTime), this.sender, () => {
.recordTime), this.user, () => {
setTimeout(() => { setTimeout(() => {
this.$emit('success') this.$emit('success')
}, 500) }, 500)

View File

@@ -8,7 +8,7 @@
</view> </view>
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'"> <view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
<u-avatar class="avatar" size="36" shape="square" @click="showUser(targetId, item.messageDirection)" <u-avatar class="avatar" size="36" shape="square" @click="showUser(targetId, item.messageDirection)"
:src="userInfo.portraitUrl" /> :src="contact(item.senderUserId).portraitUrl" />
<view class="msg"> <view class="msg">
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1" <show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
:msg="item.content" /> :msg="item.content" />
@@ -69,6 +69,11 @@
sentTime: 0 sentTime: 0
} }
} }
},
contact() {
return function(targetId) {
return this.$store.getters.contactInfo(targetId)
}
} }
}, },
onLoad(e) { onLoad(e) {
@@ -113,6 +118,7 @@
1, 1,
false, false,
(messages) => { (messages) => {
console.log(messages);
this.messages = this.messages.concat(messages) this.messages = this.messages.concat(messages)
this.scrollBottom() this.scrollBottom()
}) })
@@ -126,6 +132,7 @@
100, 100,
true, true,
(messages) => { (messages) => {
console.log(messages);
this.messages = messages.reverse() this.messages = messages.reverse()
this.scrollBottom() this.scrollBottom()
}) })

View File

@@ -109,8 +109,7 @@ class userAuth {
.access_token) .access_token)
// 在这里登录成功链接IM服务 // 在这里登录成功链接IM服务
getImToken().then(res => { getImToken().then(res => {
console.log('在这获取IM-TOKEN', res); im.connect(res.token, res.userInfo, () => {})
im.connect(res.token, res.userInfo)
}) })
resolve() resolve()
}).catch(err => { }).catch(err => {

View File

@@ -151,14 +151,15 @@ const sentImage = (conversationType, targetId, imageUrl, user, callback) => {
}) })
} }
const sentGif = (conversationType, targetId, gifUrl, time, callback) => { const sentGif = (conversationType, targetId, gifUrl, time, user, callback) => {
const msg = { const msg = {
conversationType: conversationType, conversationType: conversationType,
targetId: String(targetId), targetId: String(targetId),
content: { content: {
objectName: 'RC:GIFMsg', objectName: 'RC:GIFMsg',
local: 'file:///' + plus.io.convertLocalFileSystemURL(gifUrl), local: 'file:///' + plus.io.convertLocalFileSystemURL(gifUrl),
duration: time duration: time,
userInfo: user
} }
} }
RongIMLib.sendMediaMessage(msg, { RongIMLib.sendMediaMessage(msg, {
@@ -177,14 +178,15 @@ const sentGif = (conversationType, targetId, gifUrl, time, callback) => {
}) })
} }
const sendFile = (conversationType, targetId, fileUrl, time, callback) => { const sendFile = (conversationType, targetId, fileUrl, time, user, callback) => {
const msg = { const msg = {
conversationType: conversationType, conversationType: conversationType,
targetId: String(targetId), targetId: String(targetId),
content: { content: {
objectName: 'RC:FileMsg', objectName: 'RC:FileMsg',
local: 'file:///' + plus.io.convertLocalFileSystemURL(fileUrl), local: 'file:///' + plus.io.convertLocalFileSystemURL(fileUrl),
duration: time duration: time,
userInfo: user
} }
} }
RongIMLib.sendMediaMessage(msg, { RongIMLib.sendMediaMessage(msg, {