mirror of
https://gitee.com/hhyykk/ipms-sjy-ui.git
synced 2025-08-09 15:41:53 +08:00
【新增】:mall 客服会话未读消息展示和消息已读处理
This commit is contained in:
@@ -18,12 +18,12 @@
|
||||
{{ formatDate(item.createTime) }}
|
||||
</div>
|
||||
<!-- 系统消息 -->
|
||||
<view
|
||||
<div
|
||||
v-if="item.contentType === KeFuMessageContentTypeEnum.SYSTEM"
|
||||
class="system-message"
|
||||
>
|
||||
{{ item.content }}
|
||||
</view>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
:class="[
|
||||
@@ -154,9 +154,10 @@ const handleSendMessage = async () => {
|
||||
|
||||
// 发送消息 【共用】
|
||||
const sendMessage = async (msg: any) => {
|
||||
// 发送消息
|
||||
await KeFuMessageApi.sendKeFuMessage(msg)
|
||||
message.value = ''
|
||||
// 3. 加载消息列表
|
||||
// 加载消息列表
|
||||
await getMessageList(keFuConversation.value)
|
||||
// 滚动到最新消息处
|
||||
await scrollToBottom()
|
||||
@@ -166,8 +167,11 @@ const innerRef = ref<HTMLDivElement>()
|
||||
const scrollbarRef = ref<InstanceType<typeof ElScrollbarType>>()
|
||||
// 滚动到底部
|
||||
const scrollToBottom = async () => {
|
||||
// 1. 滚动到最新消息
|
||||
await nextTick()
|
||||
scrollbarRef.value!.setScrollTop(innerRef.value!.clientHeight)
|
||||
// 2. 消息已读
|
||||
await KeFuMessageApi.updateKeFuMessageReadStatus(keFuConversation.value.id)
|
||||
}
|
||||
/**
|
||||
* 是否显示时间
|
||||
|
@@ -8,7 +8,15 @@
|
||||
@click="openRightMessage(item, index)"
|
||||
>
|
||||
<div class="flex justify-center items-center w-100%">
|
||||
<el-avatar :src="item.userAvatar" alt="avatar" />
|
||||
<div class="flex justify-center items-center" style="width: 50px; height: 50px">
|
||||
<el-badge
|
||||
:hidden="item.adminUnreadMessageCount === 0"
|
||||
:max="99"
|
||||
:value="item.adminUnreadMessageCount"
|
||||
>
|
||||
<el-avatar :src="item.userAvatar" alt="avatar" />
|
||||
</el-badge>
|
||||
</div>
|
||||
<div class="ml-10px w-100%">
|
||||
<div class="flex justify-between items-center w-100%">
|
||||
<span>{{ item.userNickname }}</span>
|
||||
@@ -24,8 +32,10 @@
|
||||
></div>
|
||||
</template>
|
||||
<!-- 图片消息 -->
|
||||
<template v-if="KeFuMessageContentTypeEnum.IMAGE === item.lastMessageContentType">
|
||||
<div class="last-message flex items-center color-[#989EA6]">【图片消息】</div>
|
||||
<template v-else>
|
||||
<div class="last-message flex items-center color-[#989EA6]">
|
||||
{{ getContentType(item.lastMessageContentType) }}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -55,6 +65,25 @@ const openRightMessage = (item: KeFuConversationRespVO, index: number) => {
|
||||
activeConversationIndex.value = index
|
||||
emits('change', item)
|
||||
}
|
||||
// 获得消息类型
|
||||
const getContentType = computed(() => (lastMessageContentType: number) => {
|
||||
switch (lastMessageContentType) {
|
||||
case KeFuMessageContentTypeEnum.SYSTEM:
|
||||
return '[系统消息]'
|
||||
case KeFuMessageContentTypeEnum.VIDEO:
|
||||
return '[视频消息]'
|
||||
case KeFuMessageContentTypeEnum.IMAGE:
|
||||
return '[图片消息]'
|
||||
case KeFuMessageContentTypeEnum.PRODUCT:
|
||||
return '[商品消息]'
|
||||
case KeFuMessageContentTypeEnum.ORDER:
|
||||
return '[订单消息]'
|
||||
case KeFuMessageContentTypeEnum.VOICE:
|
||||
return '[语音消息]'
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import KeFuConversationBox from './KeFuConversationBox.vue'
|
||||
import KeFuChatBox from './KeFuChatBox.vue'
|
||||
import * as Constants from './tools/constants'
|
||||
|
||||
export { KeFuConversationBox, KeFuChatBox, Constants }
|
||||
export { KeFuConversationBox, KeFuChatBox }
|
||||
|
Reference in New Issue
Block a user