main
sunjianxi 11 months ago
parent b839698591
commit 79a5e39313
  1. 44
      pages/index/detail.vue

@ -58,7 +58,7 @@
<view class="content"> <view class="content">
<view style="width: 100%; overflow: hidden;"> <view style="width: 100%; overflow: hidden;">
<zeroMarkdownView :markdown="item.data || ''" /> <zeroMarkdownView :markdown="item.data || ''" />
<view class="yindao" @click="clickYinDao(item.data)"> <view class="yindao" v-if="isShowYindao" @click="clickYinDao(item.data)">
安装条件引导 安装条件引导
</view> </view>
</view> </view>
@ -178,6 +178,7 @@
title: "工单生成", title: "工单生成",
}, },
], ],
isShowYindao:false,
inputValue: "", inputValue: "",
es: null, es: null,
msgList: [], msgList: [],
@ -214,11 +215,15 @@
} }
console.log(params); console.log(params);
if (params.id == 12121212) { if (params.id == 12121212) {
console.log('11111111111111111111111111111')
this.queryChat("开始隐患排查," + str); this.queryChat("开始隐患排查," + str);
} else { } else {
// this.SSE("," + str, "1"); // this.SSE("," + str, "1");
if (params.id != "undefined") { if (params.id != "undefined") {
this.queryChat("开始隐患排查," + str); console.log('2222222222222222222222222222222')
setTimeout(() =>{
this.queryChat("开始隐患排查," + str);
},500)
} else { } else {
this.$.toast('缺少相关信息'); this.$.toast('缺少相关信息');
@ -249,6 +254,7 @@
// }, // },
methods: { methods: {
clickYinDao(data) { clickYinDao(data) {
console.log('data12121 ========>',data)
let newData = data.content + data.reference.content let newData = data.content + data.reference.content
const timer = setInterval(() => { const timer = setInterval(() => {
data.content += data.reference.content data.content += data.reference.content
@ -257,6 +263,7 @@
clearInterval(timer); clearInterval(timer);
} }
}, 50); }, 50);
console.log('data ========>',data)
// data.content += data.reference.content // data.content += data.reference.content
}, },
// SSE // SSE
@ -287,7 +294,7 @@
openWhenHidden: true, openWhenHidden: true,
onopen: () => {}, onopen: () => {},
onmessage: (ev) => { onmessage: (ev) => {
console.log(ev); console.log('ev ==========》',ev);
this.loading = true; this.loading = true;
const res = JSON.parse(ev.data); const res = JSON.parse(ev.data);
if (res?.code == 200 && res.result) { if (res?.code == 200 && res.result) {
@ -372,6 +379,7 @@
if (res && res.data && res.data.code == 200) { if (res && res.data && res.data.code == 200) {
const result = res.data.result const result = res.data.result
let id = 1 let id = 1
let arr = this.msgList
result.forEach((item, index) => { result.forEach((item, index) => {
let questionList = { let questionList = {
answerId: '1', answerId: '1',
@ -383,13 +391,15 @@
id: id + 1, id: id + 1,
data: item.response data: item.response
} }
this.msgList.push(questionList) arr.push(questionList)
this.msgList.push(responseList) arr.push(responseList)
id += 2 id += 2
}) })
console.log(this.msgList) this.msgList = arr
console.log('msgList =========>',this.msgList)
} }
}, },
async queryChat(voiceText) { async queryChat(voiceText) {
// console.log(voiceText,"voiceText"); // console.log(voiceText,"voiceText");
@ -461,6 +471,7 @@
this.active = data.tabkey - 1 > 0 ? data.tabkey - 1 : 0; this.active = data.tabkey - 1 > 0 ? data.tabkey - 1 : 0;
} }
if (data.content) { if (data.content) {
console.log('1212111111111111111111111 ===========>',data)
this.changeMsgList( this.changeMsgList(
data.answerId || "1", data.answerId || "1",
data.content, data.content,
@ -468,6 +479,11 @@
data.answerOptions data.answerOptions
); );
} }
if(JSON.stringify(data.reference) != '{}'){
this.isShowYindao = true
}else{
this.isShowYindao = false
}
this.loading = false; this.loading = false;
if (this.isExpanded) { if (this.isExpanded) {
this.isExpanded = !this.isExpanded; this.isExpanded = !this.isExpanded;
@ -476,11 +492,11 @@
if (err) { if (err) {
console.log("request fail", err.errMsg); console.log("request fail", err.errMsg);
} }
uni.showToast({ // uni.showToast({
title: "查询失败", // title: "",
icon: "error", // icon: "error",
duration: 2000, // duration: 2000,
}); // });
} }
}, },
// //
@ -536,15 +552,18 @@
let id = 1; let id = 1;
data = data.replace("undefined", '') data = data.replace("undefined", '')
data = data.replace("null", '') data = data.replace("null", '')
this.msgList = [...this.msgList]
console.log('this.msgList ==========>',this.msgList)
if (this.msgList.length > 0) { if (this.msgList.length > 0) {
id = this.msgList[this.msgList.length - 1].id + 1; id = this.msgList[this.msgList.length - 1].id + 1;
} }
console.log('id ========>',id)
if (answerId == "1") { if (answerId == "1") {
// //
let newdata = ""; let newdata = "";
let index = 0; let index = 0;
const timer = setInterval(() => { const timer = setInterval(() => {
newdata = newdata += data[index]; newdata = data[index] ? newdata += data[index] : newdata += '';
if (this.msgList?.filter((item) => item.id == id).length == 0) { if (this.msgList?.filter((item) => item.id == id).length == 0) {
this.msgList = [ this.msgList = [
...this.msgList, ...this.msgList,
@ -585,7 +604,6 @@
]; ];
this.scrollBottom(); this.scrollBottom();
} }
console.log('检查msgList', this.msgList)
this.msgList.forEach(item => { this.msgList.forEach(item => {
delete item.answerOptions delete item.answerOptions
}) })

Loading…
Cancel
Save