【新增】:mall 客服图片消息显示

pull/468/head
puhui999 2024-07-02 17:31:26 +08:00
parent 91c262fb24
commit 00619ca6db
2 changed files with 40 additions and 6 deletions

View File

@ -24,6 +24,7 @@
alt="avatar"
/>
<div class="kefu-message p-10px">
<!-- TODO puhui999: 消息相关等后续完成后统一抽离封装 -->
<!-- 文本消息 -->
<template v-if="KeFuMessageContentTypeEnum.TEXT === item.contentType">
<div
@ -38,8 +39,25 @@
class="flex items-center"
></div>
</template>
<template v-else>
{{ item.content }}
<!-- 图片消息 -->
<template v-if="KeFuMessageContentTypeEnum.IMAGE === item.contentType">
<div
:class="[
item.senderType === UserTypeEnum.MEMBER
? `ml-10px`
: item.senderType === UserTypeEnum.ADMIN
? `mr-10px`
: ''
]"
class="flex items-center"
>
<el-image
:src="item.content"
fit="contain"
style="width: 200px; height: 200px"
@click="imagePreview(item.content)"
/>
</div>
</template>
</div>
<el-avatar
@ -75,6 +93,7 @@ import { Emoji, replaceEmoji } from './emoji'
import { KeFuMessageContentTypeEnum } from './constants'
import { isEmpty } from '@/utils/is'
import { UserTypeEnum } from '@/utils/constants'
import { createImageViewer } from '@/components/ImageViewer'
defineOptions({ name: 'KeFuMessageBox' })
const messageTool = useMessage()
@ -134,6 +153,13 @@ const scrollToBottom = async () => {
scrollbarRef.value!.setScrollTop(innerRef.value!.clientHeight)
}
/** 图预览 */
const imagePreview = (imgUrl: string) => {
createImageViewer({
urlList: [imgUrl]
})
}
// TODO puhui999:
onBeforeUnmount(() => {
if (!poller.value) {

View File

@ -16,10 +16,17 @@
{{ formatDate(item.lastMessageTime) }}
</span>
</div>
<div
v-dompurify-html="replaceEmoji(item.lastMessageContent)"
class="last-message flex items-center color-[#989EA6]"
></div>
<!-- 文本消息 -->
<template v-if="KeFuMessageContentTypeEnum.TEXT === item.lastMessageContentType">
<div
v-dompurify-html="replaceEmoji(item.lastMessageContent)"
class="last-message flex items-center color-[#989EA6]"
></div>
</template>
<!-- 图片消息 -->
<template v-if="KeFuMessageContentTypeEnum.IMAGE === item.lastMessageContentType">
<div class="last-message flex items-center color-[#989EA6]">图片消息</div>
</template>
</div>
</div>
</div>
@ -30,6 +37,7 @@
import { KeFuConversationApi, KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
import { replaceEmoji } from '@/views/mall/promotion/kefu/components/emoji'
import { formatDate, getNowDateTime } from '@/utils/formatTime'
import { KeFuMessageContentTypeEnum } from '@/views/mall/promotion/kefu/components/constants'
defineOptions({ name: 'KeFuConversationBox' })
const activeConversationIndex = ref(-1) //