|
@@ -2,9 +2,10 @@
|
|
|
<div class="counsel-container">
|
|
|
<div class="counsel-header">
|
|
|
<span>会话<i class="ai el-icon-chat-dot-round"></i></span>
|
|
|
+ <i class="el-icon-close cursor" @click="closeMsg"></i>
|
|
|
</div>
|
|
|
- <div class="counsel-chats" ref="scrollContainer" @scroll="handleScroll">
|
|
|
- <div class="counsel-left flex">
|
|
|
+ <div class="counsel-chats" ref="scrollRef">
|
|
|
+ <div class="counsel-left flex" v-if="nowType == 'selectLand'">
|
|
|
<div class="header-img">
|
|
|
<img src="/static/images/aiModel/kefu.png" />
|
|
|
</div>
|
|
@@ -13,7 +14,7 @@
|
|
|
<span class="high" @click="sendDefault">{{ defaultMsg }}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <!--右侧-->
|
|
|
+ <!--会话内容-->
|
|
|
<div v-for="(item, index) in questionList" :key="index">
|
|
|
<!--右侧-->
|
|
|
<div class="counsel-right flex" v-if="item.type == 0">
|
|
@@ -53,7 +54,18 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
+ <div class="consel-types">
|
|
|
+ <div
|
|
|
+ v-for="(titem, i) in types"
|
|
|
+ :key="i"
|
|
|
+ class="typeitem cursor"
|
|
|
+ :class="{ heigType: nowType == titem.value }"
|
|
|
+ @click="nowType = titem.value"
|
|
|
+ >
|
|
|
+ <i :class="titem.icon"></i>
|
|
|
+ {{ titem.label }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="voice" v-if="spdisabled">
|
|
|
<div>正在识别</div>
|
|
|
<div class="noise"></div>
|
|
@@ -85,7 +97,7 @@
|
|
|
</template>
|
|
|
<script>
|
|
|
import { AddFzxz } from "../../api/ghss/ghxz.js";
|
|
|
-import { GetMsg, uploadAudio } from "../../api/aiModel.js";
|
|
|
+import { GetMsg, uploadAudio, closeMsg } from "../../api/aiModel.js";
|
|
|
import record from "./record.js";
|
|
|
let recognition = null;
|
|
|
export default {
|
|
@@ -97,10 +109,16 @@ export default {
|
|
|
"我要在抱坡区进行选址,用地面积30到50亩,选择居住用地,距离幼儿园200米,距离医院300米,距离火葬场大于5000米",
|
|
|
sendContent: "",
|
|
|
spdisabled: false,
|
|
|
+ nowType: "selectLand",
|
|
|
+ types: [
|
|
|
+ { label: "智能选址", value: "selectLand", icon: "el-icon-s-home" },
|
|
|
+ { label: "知识问答", value: "answer", icon: "el-icon-chat-line-round" },
|
|
|
+ ],
|
|
|
};
|
|
|
},
|
|
|
created() {},
|
|
|
mounted() {},
|
|
|
+
|
|
|
methods: {
|
|
|
initSpeech() {
|
|
|
// 检查浏览器是否支持SpeechRecognition
|
|
@@ -205,7 +223,7 @@ export default {
|
|
|
},
|
|
|
sendToBackend(msg, mindex) {
|
|
|
this.questionList[mindex].mstatus = 0;
|
|
|
- GetMsg(msg)
|
|
|
+ GetMsg({ msg, type: this.nowType })
|
|
|
.then((mres) => {
|
|
|
if (mres.status == 200) {
|
|
|
this.questionList[mindex].mstatus = 2;
|
|
@@ -213,6 +231,8 @@ export default {
|
|
|
if (mres.data.type == "selectLand") {
|
|
|
this.questionList.push({ content: "分析中...请稍等" });
|
|
|
this.AddFzxz(mres.data.data, mres.data.type);
|
|
|
+ } else {
|
|
|
+ this.questionList.push({ content: mres.data.data });
|
|
|
}
|
|
|
} else {
|
|
|
this.questionList.push({
|
|
@@ -264,22 +284,29 @@ export default {
|
|
|
this.$emit("close");
|
|
|
}
|
|
|
},
|
|
|
- handleScroll(event) {
|
|
|
- const { scrollTop, scrollHeight, clientHeight } = event.target;
|
|
|
- // 检查是否滚动到底部
|
|
|
- if (scrollTop + clientHeight >= scrollHeight) {
|
|
|
- // 滚动到最底部时的逻辑处理
|
|
|
- console.log("已滚动到最底部");
|
|
|
- }
|
|
|
+ closeMsg() {
|
|
|
+ this.$emit("close");
|
|
|
+ closeMsg().then((ares) => {
|
|
|
+ if (ares.status == 200) {
|
|
|
+ this.questionList[mindex].content = ares.data.voiceMsg;
|
|
|
+ this.sendToBackend(ares.data.voiceMsg, mindex);
|
|
|
+ } else {
|
|
|
+ this.$message.error(ares.data.msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
- scrollToBottom() {
|
|
|
- this.$refs.scroll.scrollTop = this.$refs.scroll.scrollHeight;
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ questionList() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.scrollRef.scrollTop = this.$refs.scrollRef.scrollHeight;
|
|
|
+ });
|
|
|
},
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="less" scoped>
|
|
|
+<style lang="scss" scoped>
|
|
|
.flex {
|
|
|
display: flex;
|
|
|
}
|
|
@@ -293,10 +320,12 @@ export default {
|
|
|
.counsel-header {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
- padding: 20px;
|
|
|
+ padding: 10px 20px;
|
|
|
font-size: 16px;
|
|
|
color: #fff;
|
|
|
border-bottom: 1px solid #1f4099;
|
|
|
+ margin-bottom: 10px;
|
|
|
+ position: relative;
|
|
|
}
|
|
|
|
|
|
.time {
|
|
@@ -308,7 +337,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
.counsel-chats {
|
|
|
- height: calc(100% - 150px);
|
|
|
+ height: calc(100% - 190px);
|
|
|
overflow-x: hidden;
|
|
|
overflow-y: auto;
|
|
|
.header-img {
|
|
@@ -382,6 +411,22 @@ export default {
|
|
|
// color: #fff;
|
|
|
}
|
|
|
}
|
|
|
+.consel-types {
|
|
|
+ position: absolute;
|
|
|
+ bottom: 100px;
|
|
|
+ width: calc(100% - 20px);
|
|
|
+ display: flex;
|
|
|
+ .typeitem {
|
|
|
+ border: 1px solid #ffffff;
|
|
|
+ border-radius: 8px;
|
|
|
+ padding: 5px 10px;
|
|
|
+ margin-right: 20px;
|
|
|
+ }
|
|
|
+ .heigType {
|
|
|
+ border-color: #f0c472;
|
|
|
+ color: #f0c472;
|
|
|
+ }
|
|
|
+}
|
|
|
.voice {
|
|
|
width: 75%;
|
|
|
// height: 100px;
|
|
@@ -429,4 +474,15 @@ export default {
|
|
|
color: #0f7ac8;
|
|
|
}
|
|
|
}
|
|
|
+/deep/ .el-icon-close:before {
|
|
|
+ position: absolute;
|
|
|
+ top: 10px;
|
|
|
+ right: 10px;
|
|
|
+ font-size: larger;
|
|
|
+ font-weight: bold;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ color: aqua;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|