|
@@ -17,6 +17,12 @@
|
|
<div v-for="(item, index) in questionList" :key="index">
|
|
<div v-for="(item, index) in questionList" :key="index">
|
|
<!--右侧-->
|
|
<!--右侧-->
|
|
<div class="counsel-right flex" v-if="item.type == 0">
|
|
<div class="counsel-right flex" v-if="item.type == 0">
|
|
|
|
+ <i class="el-icon-loading" v-if="item.status == 0"></i>
|
|
|
|
+ <i
|
|
|
|
+ class="el-icon-warning cursor"
|
|
|
|
+ v-else-if="item.status == 1"
|
|
|
|
+ @click="sendToBackend(item.content, index)"
|
|
|
|
+ ></i>
|
|
<div class="content">
|
|
<div class="content">
|
|
<span>{{ item.content }}</span>
|
|
<span>{{ item.content }}</span>
|
|
</div>
|
|
</div>
|
|
@@ -44,7 +50,12 @@
|
|
<div class="noise"></div>
|
|
<div class="noise"></div>
|
|
</div>
|
|
</div>
|
|
<div class="searchBtom">
|
|
<div class="searchBtom">
|
|
- <i class="el-icon-microphone icon" title="按住说话" @click="voice"></i>
|
|
|
|
|
|
+ <div
|
|
|
|
+ class="el-icon-microphone icon"
|
|
|
|
+ title="按住说话"
|
|
|
|
+ :disabled="spdisabled"
|
|
|
|
+ @click="voice"
|
|
|
|
+ ></div>
|
|
<el-input
|
|
<el-input
|
|
clearable
|
|
clearable
|
|
v-model="sendContent"
|
|
v-model="sendContent"
|
|
@@ -68,7 +79,7 @@ export default {
|
|
props: {},
|
|
props: {},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- questionList: [],
|
|
|
|
|
|
+ questionList: [{ type: 0, content: "aaa" }],
|
|
defaultMsg:
|
|
defaultMsg:
|
|
"我要进行选址,选择居住用地,距离幼儿园200米,距离医院300米,远离火葬场5000米",
|
|
"我要进行选址,选择居住用地,距离幼儿园200米,距离医院300米,远离火葬场5000米",
|
|
sendContent: "",
|
|
sendContent: "",
|
|
@@ -98,7 +109,7 @@ export default {
|
|
};
|
|
};
|
|
recognition.onresult = (event) => {
|
|
recognition.onresult = (event) => {
|
|
this.sendContent = event.results[0][0].transcript;
|
|
this.sendContent = event.results[0][0].transcript;
|
|
- this.sendToBackend(); // 将识别结果发送到后台
|
|
|
|
|
|
+ this.send(); // 将识别结果发送到后台
|
|
};
|
|
};
|
|
recognition.onerror = (event) => {
|
|
recognition.onerror = (event) => {
|
|
this.$message.warning("语音识别出错: " + event.error);
|
|
this.$message.warning("语音识别出错: " + event.error);
|
|
@@ -117,18 +128,24 @@ export default {
|
|
send() {
|
|
send() {
|
|
// 咨询问题
|
|
// 咨询问题
|
|
if (this.sendContent) {
|
|
if (this.sendContent) {
|
|
- this.questionList.push({ type: 0, content: this.sendContent });
|
|
|
|
- this.sendToBackend(this.sendContent);
|
|
|
|
|
|
+ this.questionList.push({
|
|
|
|
+ type: 0,
|
|
|
|
+ content: this.sendContent,
|
|
|
|
+ status: 0,
|
|
|
|
+ });
|
|
|
|
+ this.sendToBackend(this.sendContent, this.questionList.length - 1);
|
|
this.sendContent = "";
|
|
this.sendContent = "";
|
|
}
|
|
}
|
|
},
|
|
},
|
|
voice() {
|
|
voice() {
|
|
|
|
+ console.log("---this.spdisabled-", this.spdisabled);
|
|
if (!this.spdisabled) {
|
|
if (!this.spdisabled) {
|
|
if (!recognition) this.initSpeech();
|
|
if (!recognition) this.initSpeech();
|
|
recognition.start(); // 开始语音识别
|
|
recognition.start(); // 开始语音识别
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- sendToBackend(msg) {
|
|
|
|
|
|
+ sendToBackend(msg, mindex) {
|
|
|
|
+ this.questionList[mindex].status = 0;
|
|
axios({
|
|
axios({
|
|
method: "POST",
|
|
method: "POST",
|
|
url: `${window.aiURI}/msg`,
|
|
url: `${window.aiURI}/msg`,
|
|
@@ -136,38 +153,45 @@ export default {
|
|
headers: {
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
"Content-Type": "application/json",
|
|
},
|
|
},
|
|
- }).then((mres) => {
|
|
|
|
- if (mres.status == 200) {
|
|
|
|
- if (mres.data.type == "selectLand") {
|
|
|
|
- this.questionList.push({ 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);
|
|
|
|
|
|
+ })
|
|
|
|
+ .then((mres) => {
|
|
|
|
+ if (mres.status == 200) {
|
|
|
|
+ this.questionList[mindex].status = 2;
|
|
|
|
+ if (mres.data.type == "selectLand") {
|
|
|
|
+ this.questionList.push({ 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.questionList[mindex].status = 1;
|
|
|
|
+ // this.$message.error("发送到后台时发生错误:");
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- this.$message.error("发送到后台时发生错误:");
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {
|
|
|
|
+ this.questionList[mindex].status = 1;
|
|
|
|
+ // this.$message.error("发送到后台时发生错误:");
|
|
|
|
+ });
|
|
},
|
|
},
|
|
onClick(item) {
|
|
onClick(item) {
|
|
if (item.type == "selectLand") {
|
|
if (item.type == "selectLand") {
|
|
@@ -235,9 +259,12 @@ export default {
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
display: block;
|
|
display: block;
|
|
}
|
|
}
|
|
|
|
+ .cursor {
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ }
|
|
.content {
|
|
.content {
|
|
// flex: 1;
|
|
// flex: 1;
|
|
- margin-left: 20px;
|
|
|
|
|
|
+ margin-left: 10px;
|
|
max-width: calc(100% - 100px);
|
|
max-width: calc(100% - 100px);
|
|
padding: 5px 20px;
|
|
padding: 5px 20px;
|
|
border-radius: 8px;
|
|
border-radius: 8px;
|
|
@@ -266,6 +293,9 @@ export default {
|
|
justify-content: flex-end;
|
|
justify-content: flex-end;
|
|
align-items: flex-start;
|
|
align-items: flex-start;
|
|
width: 100%;
|
|
width: 100%;
|
|
|
|
+ i {
|
|
|
|
+ font-size: 20px;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|