feat:注册功能
This commit is contained in:
@@ -73,3 +73,45 @@
|
||||
color: $color-text-primary;
|
||||
}
|
||||
}
|
||||
|
||||
.chat-message__image-wrap {
|
||||
max-width: 360rpx;
|
||||
overflow: hidden;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.chat-message__image {
|
||||
display: block;
|
||||
width: 360rpx;
|
||||
height: 360rpx;
|
||||
background: #f2f3f5;
|
||||
}
|
||||
|
||||
.chat-message__bubble--file {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
min-width: 280rpx;
|
||||
}
|
||||
|
||||
.chat-message__file-icon {
|
||||
flex-shrink: 0;
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
}
|
||||
|
||||
.chat-message__file-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.4;
|
||||
word-break: break-all;
|
||||
|
||||
.chat-message__bubble--user & {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.chat-message__bubble--service & {
|
||||
color: $color-text-primary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,38 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import type { ChatMessage } from '@/types/customer-service'
|
||||
import fileIcon from '@/static/icons/PDF.png'
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
message: ChatMessage
|
||||
}>()
|
||||
|
||||
const messageType = computed(() => props.message.type || 'text')
|
||||
|
||||
function handlePreviewImage() {
|
||||
if (!props.message.imageUrl)
|
||||
return
|
||||
|
||||
uni.previewImage({
|
||||
urls: [props.message.imageUrl],
|
||||
current: props.message.imageUrl,
|
||||
})
|
||||
}
|
||||
|
||||
function handleOpenFile() {
|
||||
if (!props.message.filePath) {
|
||||
uni.showToast({ title: props.message.fileName || '文件', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
uni.openDocument({
|
||||
filePath: props.message.filePath,
|
||||
showMenu: true,
|
||||
fail: () => {
|
||||
uni.showToast({ title: `已发送${props.message.fileName || '文件'}`, icon: 'none' })
|
||||
},
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -21,7 +50,37 @@ defineProps<{
|
||||
<text class="chat-message__nickname">
|
||||
{{ message.nickname }}
|
||||
</text>
|
||||
|
||||
<view
|
||||
v-if="messageType === 'image' && message.imageUrl"
|
||||
class="chat-message__image-wrap"
|
||||
@tap="handlePreviewImage"
|
||||
>
|
||||
<image
|
||||
class="chat-message__image"
|
||||
:src="message.imageUrl"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view
|
||||
v-else-if="messageType === 'file'"
|
||||
class="chat-message__bubble chat-message__bubble--file"
|
||||
:class="`chat-message__bubble--${message.role}`"
|
||||
@tap="handleOpenFile"
|
||||
>
|
||||
<image
|
||||
class="chat-message__file-icon"
|
||||
:src="fileIcon"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<text class="chat-message__file-name">
|
||||
{{ message.fileName || message.content }}
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view
|
||||
v-else
|
||||
class="chat-message__bubble"
|
||||
:class="`chat-message__bubble--${message.role}`"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user