|
@@ -3,11 +3,20 @@
|
|
|
<div class="counsel-header">
|
|
|
<span>会话</span>
|
|
|
</div>
|
|
|
+ <div class="counsel-left flex">
|
|
|
+ <div class="header-img">
|
|
|
+ <img src="/static/images/aiModel/kefu.png" />
|
|
|
+ </div>
|
|
|
+ <div class="content">
|
|
|
+ <span>Hi,有问题您可以这样问我:</span>
|
|
|
+ <span class="high" @click="sendDefault">{{ defaultMsg }}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
|
|
|
<!--右侧-->
|
|
|
<div v-for="(item, index) in questionList" :key="index">
|
|
|
<!--右侧-->
|
|
|
- <div class="counsel-right flex">
|
|
|
+ <div class="counsel-right flex" v-if="item.type == 0">
|
|
|
<div class="content">
|
|
|
<span>{{ item.content }}</span>
|
|
|
</div>
|
|
@@ -15,39 +24,22 @@
|
|
|
<img src="/static/images/aiModel/default.png" />
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <!--左侧-->
|
|
|
- <div class="counsel-left flex" v-if="searchauxiliaryList.length == 0">
|
|
|
- <div class="header-img">
|
|
|
- <img src="/static/images/aiModel/kefu.png" />
|
|
|
- </div>
|
|
|
- <div class="content">
|
|
|
- <span class="tit">参考意见</span>
|
|
|
- <span>您好,暂未找到符合的内容,可以试试别的关键词</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div
|
|
|
- class="counsel-left flex"
|
|
|
- v-for="(item, index) in searchauxiliaryList"
|
|
|
- :key="index"
|
|
|
- >
|
|
|
- <div class="header-img">
|
|
|
- <img src="/static/images/aiModel/kefu.png" />
|
|
|
- </div>
|
|
|
- <div class="content">
|
|
|
- <span class="tit">参考意见:</span>
|
|
|
- <span>{{ item.content }}</span>
|
|
|
+ <!--左侧-->
|
|
|
+ <div class="counsel-left flex" v-else>
|
|
|
+ <div class="header-img">
|
|
|
+ <img src="/static/images/aiModel/kefu.png" />
|
|
|
+ </div>
|
|
|
+ <div class="content">
|
|
|
+ <span v-if="item.type" class="tit">参考意见</span>
|
|
|
+ <span :class="{ high: item.type }" @click="onClick(item)">
|
|
|
+ {{ item.content }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="searchBtom">
|
|
|
<div v-if="spdisabled">正在识别...</div>
|
|
|
- <i
|
|
|
- class="el-icon-microphone icon"
|
|
|
- :disabled="spdisabled"
|
|
|
- title="按住说话"
|
|
|
- @click="voice"
|
|
|
- ></i>
|
|
|
+ <i class="el-icon-microphone icon" title="按住说话" @click="voice"></i>
|
|
|
<el-input
|
|
|
clearable
|
|
|
v-model="sendContent"
|
|
@@ -64,32 +56,22 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
+import { AddFzxz } from "../../api/ghss/ghxz.js";
|
|
|
+
|
|
|
let recognition = null;
|
|
|
export default {
|
|
|
props: {},
|
|
|
data() {
|
|
|
return {
|
|
|
- user: {},
|
|
|
- caseType: 0,
|
|
|
- questionList: [
|
|
|
- { type: 0, content: "-s--" },
|
|
|
- { type: 0, content: "---d" },
|
|
|
- ],
|
|
|
- auxiliaryList: [], // 随机数据
|
|
|
- searchauxiliaryList: [{ relatedName: "asncksdnclkdcndkn" }],
|
|
|
- sendContent: "aa",
|
|
|
+ questionList: [],
|
|
|
+ defaultMsg:
|
|
|
+ "我要进行选址,选择居住用地,距离幼儿园200米,距离医院300米,远离火葬场5000米",
|
|
|
+ sendContent: "",
|
|
|
spdisabled: false,
|
|
|
};
|
|
|
},
|
|
|
created() {},
|
|
|
- mounted() {
|
|
|
- // if (this.caseArray.length > 0) {
|
|
|
- // this.caseType = this.caseArray[0].k;
|
|
|
- // this.initLoadAuxiliary();
|
|
|
- // }
|
|
|
- this.send();
|
|
|
- console.log("========", this.questionList);
|
|
|
- },
|
|
|
+ mounted() {},
|
|
|
methods: {
|
|
|
initSpeech() {
|
|
|
// 检查浏览器是否支持SpeechRecognition
|
|
@@ -106,88 +88,91 @@ export default {
|
|
|
recognition.maxAlternatives = 1; // 返回的识别结果数量
|
|
|
|
|
|
recognition.onstart = () => {
|
|
|
- console.log("开始语音识别...");
|
|
|
+ this.$message.success("开始语音识别...");
|
|
|
this.spdisabled = true;
|
|
|
};
|
|
|
-
|
|
|
recognition.onresult = (event) => {
|
|
|
this.sendContent = event.results[0][0].transcript;
|
|
|
this.sendToBackend(); // 将识别结果发送到后台
|
|
|
};
|
|
|
-
|
|
|
recognition.onerror = (event) => {
|
|
|
- alert("语音识别出错: " + event.error);
|
|
|
+ this.$message.warning("语音识别出错: " + event.error);
|
|
|
};
|
|
|
-
|
|
|
recognition.onend = () => {
|
|
|
+ // this.$message.success("语音识别结束:");
|
|
|
console.log("语音识别结束");
|
|
|
this.spdisabled = false;
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
+ sendDefault() {
|
|
|
+ this.sendContent = this.defaultMsg;
|
|
|
+ this.send();
|
|
|
+ },
|
|
|
send() {
|
|
|
// 咨询问题
|
|
|
if (this.sendContent) {
|
|
|
- this.questionList.push({ content: this.sendContent });
|
|
|
+ this.questionList.push({ type: 0, content: this.sendContent });
|
|
|
this.sendToBackend(this.sendContent);
|
|
|
this.sendContent = "";
|
|
|
}
|
|
|
},
|
|
|
voice() {
|
|
|
- if (!recognition) this.initSpeech();
|
|
|
- recognition.start(); // 开始语音识别
|
|
|
+ if (!this.spdisabled) {
|
|
|
+ if (!recognition) this.initSpeech();
|
|
|
+ recognition.start(); // 开始语音识别
|
|
|
+ }
|
|
|
},
|
|
|
sendToBackend(msg) {
|
|
|
- fetch(`${window.aiURI}/msg`, {
|
|
|
+ axios({
|
|
|
method: "POST",
|
|
|
+ url: `${window.aiURI}/msg`,
|
|
|
+ data: JSON.stringify({ msg }),
|
|
|
headers: {
|
|
|
"Content-Type": "application/json",
|
|
|
- // 'Content-Type': 'application/json;charset=UTF-8',
|
|
|
- // "Content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
|
|
- "Access-Control-Allow-Origin": "*",
|
|
|
},
|
|
|
- body: JSON.stringify({ msg }),
|
|
|
- mode: "no-cors",
|
|
|
- })
|
|
|
- .then((response) => response.json())
|
|
|
- .then((data) => {
|
|
|
- console.log("服务器响应:", data);
|
|
|
- })
|
|
|
- .catch((error) => {
|
|
|
- console.error("发送到后台时发生错误:", error);
|
|
|
- alert("发送到后台时发生错误:", error);
|
|
|
+ }).then((mres) => {
|
|
|
+ if (mres.status == 200) {
|
|
|
+ if (mres.data.type == "selectLand") {
|
|
|
+ this.questionList.push({ type: 1, content: "分析中...请稍等" });
|
|
|
+ const loading = this.$loading({
|
|
|
+ lock: true,
|
|
|
+ text: "分析中",
|
|
|
+ spinner: "el-icon-loading",
|
|
|
+ background: "rgba(0, 0, 0, 0.7)",
|
|
|
+ });
|
|
|
+ AddFzxz(mres.data.data)
|
|
|
+ .then((res) => {
|
|
|
+ loading.close();
|
|
|
+ this.questionList.push({
|
|
|
+ type: mres.data.type,
|
|
|
+ content: "查看智能选址结果",
|
|
|
+ data: res.data,
|
|
|
+ });
|
|
|
+ this.$message({
|
|
|
+ message: res.message,
|
|
|
+ type: res.success ? "success" : "warning",
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ loading.close();
|
|
|
+ this.$message.error(error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$message.error("发送到后台时发生错误:");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onClick(item) {
|
|
|
+ if (item.type == "selectLand") {
|
|
|
+ this.$router.push({
|
|
|
+ path: "/siteselection",
|
|
|
+ query: { rwbsm: item.data.rwbsm },
|
|
|
});
|
|
|
+ this.$emit("close");
|
|
|
+ }
|
|
|
},
|
|
|
- // onSearchTune(k) {
|
|
|
- // this.caseType = k;
|
|
|
- // this.initLoadAuxiliary();
|
|
|
- // },
|
|
|
- // initLoadAuxiliary() {
|
|
|
- // // 随机智能辅调
|
|
|
- // this.auxiliaryList = [];
|
|
|
- // General.News.queryAutoConsulting({
|
|
|
- // caseType: this.caseType,
|
|
|
- // limit: 5,
|
|
|
- // }).then((res) => {
|
|
|
- // const { status, data } = res.data;
|
|
|
- // if (status == 0) {
|
|
|
- // this.auxiliaryList = data;
|
|
|
- // }
|
|
|
- // });
|
|
|
- // },
|
|
|
- // initKeywordsLoadAuxiliary(keywords) {
|
|
|
- // // 搜索关键词查询
|
|
|
- // this.searchauxiliaryList = [];
|
|
|
- // General.News.queryAutoConsulting({
|
|
|
- // keyWord: keywords,
|
|
|
- // limit: 5,
|
|
|
- // }).then((res) => {
|
|
|
- // const { status, data } = res.data;
|
|
|
- // if (status == 0) {
|
|
|
- // this.searchauxiliaryList = data;
|
|
|
- // }
|
|
|
- // });
|
|
|
- // },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -236,14 +221,18 @@ export default {
|
|
|
object-fit: cover;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ .high {
|
|
|
+ color: #b6e0ff !important;
|
|
|
+ cursor: pointer;
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
.content {
|
|
|
// flex: 1;
|
|
|
margin-left: 20px;
|
|
|
max-width: calc(100% - 100px);
|
|
|
padding: 5px 20px;
|
|
|
border-radius: 8px;
|
|
|
- background: #323f96;
|
|
|
+ background: #40a0ff6c;
|
|
|
|
|
|
.tit {
|
|
|
display: block;
|
|
@@ -260,7 +249,7 @@ export default {
|
|
|
margin-bottom: 30px;
|
|
|
align-items: flex-start;
|
|
|
.content {
|
|
|
- background: #999999;
|
|
|
+ background: #b6e1ff3b;
|
|
|
}
|
|
|
}
|
|
|
|