104 lines
2.0 KiB
Vue
104 lines
2.0 KiB
Vue
<template>
|
|
<div class="agent-message">
|
|
<img :src="avatar" class="avatar"/>
|
|
<div class="msg-body">
|
|
<div class="msg-header">
|
|
<span class="name">客服{{ name }}</span>
|
|
<span v-if="tag" class="tag agent-tag">{{ tag }}</span>
|
|
<span class="time">{{ time }}</span>
|
|
</div>
|
|
<!-- 文本消息 -->
|
|
<div v-if="type === 'text'" class="bubble text-bubble" v-html="content"></div>
|
|
<!-- 图片消息 -->
|
|
<div v-else-if="type === 'image'" class="bubble img-bubble">
|
|
<el-image :preview-src-list="[url]" :src="url" class="chat-img" @click="$emit('preview', url)"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import avatar from '@/assets/images/avatar.png'
|
|
|
|
const props = defineProps({
|
|
name: {type: String, default: '客服'},
|
|
avatar: {type: String, default: avatar},
|
|
content: {type: String, default: ''},
|
|
url: {type: String, default: ''},
|
|
type: {type: String as () => 'text' | 'image', default: 'text'},
|
|
tag: {type: String, default: '人工客服'},
|
|
time: {type: String, default: ''}
|
|
})
|
|
defineEmits(['preview'])
|
|
</script>
|
|
|
|
<style scoped>
|
|
.agent-message {
|
|
display: flex;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.avatar {
|
|
width: 36px;
|
|
height: 36px;
|
|
border-radius: 50%;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.msg-body {
|
|
margin-left: 8px;
|
|
max-width: 75%;
|
|
}
|
|
|
|
.msg-header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.name {
|
|
font-size: 12px;
|
|
color: #333;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.agent-tag {
|
|
background: #eff6ff;
|
|
color: #2563eb;
|
|
font-weight: bold;
|
|
font-size: 11px;
|
|
padding: 1px 6px;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.time {
|
|
font-size: 11px;
|
|
color: #999;
|
|
}
|
|
|
|
.bubble {
|
|
background: #fff;
|
|
border-radius: 4px 16px 16px 16px;
|
|
padding: 10px 14px;
|
|
font-size: 14px;
|
|
line-height: 22px;
|
|
color: rgba(31, 41, 55, 1);
|
|
}
|
|
|
|
.text-bubble {
|
|
display: inline-block;
|
|
word-break: break-all;
|
|
}
|
|
|
|
.img-bubble {
|
|
padding: 4px;
|
|
}
|
|
|
|
.chat-img {
|
|
max-width: 200px;
|
|
border-radius: 8px;
|
|
display: block;
|
|
}
|
|
</style>
|