|
|
@@ -16,7 +16,6 @@
|
|
|
'https://birdseye-img.sysuimars.com/dinggou-mini/defalut-icon.png'
|
|
|
"
|
|
|
/>
|
|
|
- <img src="" alt="" />
|
|
|
<div class="bubble" :class="{ 'no-bubble': msg.messageType === 'image' ,'card-bubble': msg.messageType === 'card'}">
|
|
|
<!-- 文本消息 -->
|
|
|
<div v-if="msg.messageType === 'text'" class="content">{{ msg.content }}</div>
|
|
|
@@ -45,18 +44,15 @@
|
|
|
</div>
|
|
|
|
|
|
<!-- 对话样式消息 -->
|
|
|
- <div v-if="msg.messageType === 'card'" class="card-message" @click="handleCardClick(msg)">
|
|
|
- <template v-if="(msg.cardType || msg.content.cardType) === 'quotation'">
|
|
|
- <div class="card-title">向您发送了一张 服务报价单</div>
|
|
|
- <img src="https://birdseye-img.sysuimars.com/temp/price.png" alt="" />
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- <div class="card-title">{{ msg.title || msg.content.title }}</div>
|
|
|
- <img :src="handleImgUrl(msg.coverUrl || msg.content.coverUrl)" alt="" />
|
|
|
- </template>
|
|
|
+ <div v-if="msg.messageType === 'question'" class="question-message" @click="handleCardClick(msg)">
|
|
|
+ <div class="question-title">{{ msg.content }}</div>
|
|
|
+ <div class="image-wrap">
|
|
|
+ <img src="@/assets/img/monitor/image.png" alt="" />
|
|
|
+ <img src="@/assets/img/monitor/image.png" alt="" />
|
|
|
+ <img src="@/assets/img/monitor/image.png" alt="" />
|
|
|
+ </div>
|
|
|
+ <div class="btn-detail" @click="handleDetailClick">查看详情</div>
|
|
|
</div>
|
|
|
-
|
|
|
- <!-- <div class="time">{{ msg.time }}</div> -->
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -100,8 +96,6 @@
|
|
|
<img :src="handleImgUrl(msg.coverUrl || msg.content.coverUrl)" alt="" />
|
|
|
</template>
|
|
|
</div>
|
|
|
-
|
|
|
- <!-- <div class="time">{{ msg.time }}</div> -->
|
|
|
</div>
|
|
|
<!-- <div class="avatar avatar-r">{{ msg.senderName.charAt(0) }}</div> -->
|
|
|
<el-avatar
|
|
|
@@ -118,12 +112,12 @@
|
|
|
|
|
|
<!-- 输入框区域 -->
|
|
|
<div class="input-area">
|
|
|
- <div class="toolbar">
|
|
|
+ <!-- <div class="toolbar">
|
|
|
<el-icon class="link" @click="startImageUpload"><Link /></el-icon>
|
|
|
<input type="file" ref="fileInput" accept="image/*" style="display: none" @change="handleImageUpload" />
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
|
|
|
- <input type="text" v-model="inputMessage" placeholder="请输入你想说的话~" @keyup.enter="sendTextMessage" />
|
|
|
+ <input type="text" v-model="inputMessage" placeholder="给 专家 发送消息" @keyup.enter="sendTextMessage" />
|
|
|
<div class="send" @click="sendTextMessage">发送</div>
|
|
|
</div>
|
|
|
|
|
|
@@ -136,7 +130,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, onUnmounted, nextTick, watch, onActivated, onDeactivated } from "vue";
|
|
|
+import { ref, nextTick, onDeactivated, onMounted } from "vue";
|
|
|
import { useRouter ,useRoute} from "vue-router";
|
|
|
import { base_img_url2 } from "@/api/config";
|
|
|
import { getFileExt } from "@/utils/util";
|
|
|
@@ -163,8 +157,6 @@ const props = defineProps({
|
|
|
},
|
|
|
});
|
|
|
|
|
|
-const emit = defineEmits(['update:name']);
|
|
|
-
|
|
|
const curUserId = Number(localStorage.getItem("MINI_USER_ID"));
|
|
|
const senderIcon = ref("");
|
|
|
const receiverIcon = ref("");
|
|
|
@@ -182,12 +174,6 @@ const localUserInfoIcon = (() => {
|
|
|
|
|
|
// 初始化本地头像为默认发送者头像
|
|
|
senderIcon.value = localUserInfoIcon;
|
|
|
-const nameVal = ref('');
|
|
|
-
|
|
|
-// 监听 nameVal 变化,传递给父组件
|
|
|
-watch(nameVal, (newVal) => {
|
|
|
- emit('update:name', newVal);
|
|
|
-});
|
|
|
|
|
|
// mqtt 连接
|
|
|
const mqttClient = ref(null);
|
|
|
@@ -199,13 +185,15 @@ const messages = ref([]);
|
|
|
// 输入相关
|
|
|
const inputMessage = ref("");
|
|
|
const fileInput = ref(null);
|
|
|
-const showEmojiPicker = ref(false);
|
|
|
-const emojis = ["😀", "😂", "😍", "👍", "👋", "🎉", "❤️", "🙏"];
|
|
|
|
|
|
function handleImageLoad() {
|
|
|
scrollToBottom();
|
|
|
}
|
|
|
|
|
|
+const handleDetailClick = () => {
|
|
|
+ router.push('/interaction_list');
|
|
|
+}
|
|
|
+
|
|
|
// 图片预览
|
|
|
const previewImage = ref(null);
|
|
|
|
|
|
@@ -256,7 +244,6 @@ const sendImageMessage = (thumbnailUrl) => {
|
|
|
messageType: "image",
|
|
|
senderIcon: senderIcon.value,
|
|
|
content: thumbnailUrl,
|
|
|
- time: getCurrentTime(),
|
|
|
};
|
|
|
sendMessage(message);
|
|
|
};
|
|
|
@@ -319,21 +306,12 @@ const sendTextMessage = () => {
|
|
|
messageType: "text",
|
|
|
senderIcon: senderIcon.value,
|
|
|
content: inputMessage.value,
|
|
|
- time: getCurrentTime(),
|
|
|
};
|
|
|
sendMessage(message);
|
|
|
inputMessage.value = "";
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-// 辅助函数
|
|
|
-const getCurrentTime = () => {
|
|
|
- return new Date().toLocaleTimeString("zh-CN", {
|
|
|
- hour: "2-digit",
|
|
|
- minute: "2-digit",
|
|
|
- });
|
|
|
-};
|
|
|
-
|
|
|
const scrollToBottom = () => {
|
|
|
nextTick(() => {
|
|
|
setTimeout(() => {
|
|
|
@@ -345,12 +323,10 @@ const scrollToBottom = () => {
|
|
|
};
|
|
|
|
|
|
const farmVal = ref("");
|
|
|
-const options = ref([]);
|
|
|
const curRole = ref(null);
|
|
|
|
|
|
// 点击农场报告对话框
|
|
|
const handleReportClick = (msg) => {
|
|
|
- console.log(msg);
|
|
|
if(msg.reportType === 'farm_report' || msg.messageType === 'report'){
|
|
|
const params = {
|
|
|
farmId: msg.reportId || msg.content?.reportId,
|
|
|
@@ -362,6 +338,24 @@ const handleReportClick = (msg) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 页面加载时自动添加欢迎消息
|
|
|
+onMounted(() => {
|
|
|
+ const welcomeMessage = {
|
|
|
+ sender: "received",
|
|
|
+ messageType: "text",
|
|
|
+ content: "您好,我叫冼继东。我是种植专家,介绍专家介绍专家",
|
|
|
+ receiverIcon: receiverIcon.value || 'https://birdseye-img.sysuimars.com/dinggou-mini/defalut-icon.png',
|
|
|
+ };
|
|
|
+ const questionMessage = {
|
|
|
+ sender: "received",
|
|
|
+ messageType: "question",
|
|
|
+ content: "为了更方便分析农场问题,请先采集农情互动信息",
|
|
|
+ receiverIcon: receiverIcon.value || 'https://birdseye-img.sysuimars.com/dinggou-mini/defalut-icon.png',
|
|
|
+ };
|
|
|
+ messages.value.push(welcomeMessage,questionMessage);
|
|
|
+ scrollToBottom();
|
|
|
+});
|
|
|
+
|
|
|
onDeactivated(() => {
|
|
|
mqttClient.value && mqttClient.value.client.end(true);
|
|
|
});
|
|
|
@@ -386,7 +380,7 @@ onDeactivated(() => {
|
|
|
flex: 1;
|
|
|
padding: 12px;
|
|
|
overflow-y: auto;
|
|
|
- background-color: #f5f5f5;
|
|
|
+ background-color: #fff;
|
|
|
box-sizing: border-box;
|
|
|
.message {
|
|
|
display: flex;
|
|
|
@@ -395,7 +389,7 @@ onDeactivated(() => {
|
|
|
.received {
|
|
|
justify-content: flex-start;
|
|
|
.bubble {
|
|
|
- background-color: white;
|
|
|
+ background-color: #F4F5F8;
|
|
|
border-radius: 0 10px 10px 10px;
|
|
|
padding: 10px 12px;
|
|
|
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
|
|
|
@@ -434,14 +428,7 @@ onDeactivated(() => {
|
|
|
|
|
|
.content {
|
|
|
font-size: 16px;
|
|
|
- line-height: 1.4;
|
|
|
-}
|
|
|
-
|
|
|
-.time {
|
|
|
- font-size: 12px;
|
|
|
- color: #fff;
|
|
|
- margin-top: 5px;
|
|
|
- text-align: right;
|
|
|
+ color: #666666;
|
|
|
}
|
|
|
|
|
|
.input-area {
|
|
|
@@ -586,17 +573,31 @@ onDeactivated(() => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-.card-message{
|
|
|
- .card-title{
|
|
|
- font-size: 15px;
|
|
|
- font-weight: 600;
|
|
|
- color: #000;
|
|
|
- margin-bottom: 5px;
|
|
|
+.question-message{
|
|
|
+ .question-title{
|
|
|
+ font-size: 16px;
|
|
|
+ color: #666666;
|
|
|
+ margin-bottom: 6px;
|
|
|
}
|
|
|
- img{
|
|
|
- width: 222px;
|
|
|
- height: 180px;
|
|
|
- object-fit: cover;
|
|
|
+ .image-wrap{
|
|
|
+ display: flex;
|
|
|
+ // flex-wrap: wrap;
|
|
|
+ gap: 10px;
|
|
|
+ img{
|
|
|
+ flex: 1;
|
|
|
+ width: 75px;
|
|
|
+ height: 70px;
|
|
|
+ border-radius: 8px;
|
|
|
+ object-fit: cover;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .btn-detail{
|
|
|
+ font-size: 14px;
|
|
|
+ margin-top: 8px;
|
|
|
+ background: #FFFFFF;
|
|
|
+ border-radius: 6px;
|
|
|
+ text-align: center;
|
|
|
+ padding: 6px;
|
|
|
}
|
|
|
}
|
|
|
|