zhangqun 11 months ago
parent 047913eee5
commit 68d3c8a949
  1. 55
      pages/index/detail.vue
  2. 682
      pages/knowledge/index.vue

@ -55,6 +55,7 @@
height: isExpanded ? 'calc(100% - 350rpx)' : 'calc(100% - 250rpx)', height: isExpanded ? 'calc(100% - 350rpx)' : 'calc(100% - 250rpx)',
}" }"
class="chatlist" class="chatlist"
id="scrollView"
ref="scrollView" ref="scrollView"
@click="clickContent" @click="clickContent"
> >
@ -76,7 +77,7 @@
: '/static/left_user.png' : '/static/left_user.png'
" "
class="img" class="img"
/> />{{ isExpanded }}
<view class="content"> <view class="content">
<zeroMarkdownView :markdown="item.data" /> <zeroMarkdownView :markdown="item.data" />
<!-- <ua-markdown :source="mdvalue" /> --> <!-- <ua-markdown :source="mdvalue" /> -->
@ -228,14 +229,15 @@ export default {
}; };
}, },
onLoad(options) { onLoad(options) {
console.log(options)
let params = options; let params = options;
params.deptId = "3702000000"; // params.deptId = "3702000000";
params.id = "37020017609"; // params.id = "37020017609";
params.sectionId = "37020017609"; // params.sectionId = "37020017609";
params.roadName = "023县道"; // params.roadName = "023";
params.taskId = "000001"; // params.taskId = "000001";
params.userId = "admin1"; // params.userId = "admin1";
this.params = params; // this.params = params;
let str = ""; let str = "";
if (params.roadName) { if (params.roadName) {
str += "路段名:" + params.roadName; str += "路段名:" + params.roadName;
@ -297,7 +299,7 @@ export default {
id: this.params.id, id: this.params.id,
taskId: this.params.taskId, taskId: this.params.taskId,
sectionId: this.params.sectionId, sectionId: this.params.sectionId,
// sectionType: this.params.sectionType, sectionType: this.params.sectionType,
}), }),
signal: ctrl.signal, signal: ctrl.signal,
openWhenHidden: true, openWhenHidden: true,
@ -443,16 +445,12 @@ export default {
}; };
this.msgList.push(newQuestion); // this.msgList.push(newQuestion); //
// this.$store.commit('setMSg_List', this.msgList); // this.$store.commit('setMSg_List', this.msgList);
this.scrollBottom();
}, },
scrollBottom() { scrollBottom() {
uni.createSelectorQuery().in(this).select('#scroll-view-content').boundingClientRect((res)=>{
let top = res.height-this.scrollViewHeight;
if(top>0){ this.$nextTick(() => {
this.scrollTop=top;
}
}).exec()
// this.$nextTick(() => {
// const height = // const height =
// this.$refs.scrollView && // this.$refs.scrollView &&
// this.$refs.scrollView.$refs && // this.$refs.scrollView.$refs &&
@ -460,7 +458,8 @@ export default {
// ? this.$refs.scrollView.$refs.content.scrollHeight // ? this.$refs.scrollView.$refs.content.scrollHeight
// : 0; // : 0;
// this.scrollTop = height; // this.scrollTop = height;
// }); this.scrollTop = this.scrollTop + 1
});
}, },
// //
handleSend(text) { handleSend(text) {
@ -512,15 +511,7 @@ export default {
this.msgList[this.msgList.length - 1].data = newdata; this.msgList[this.msgList.length - 1].data = newdata;
} }
index += 1; index += 1;
this.$nextTick(() => { this.scrollBottom();
const height =
this.$refs.scrollView &&
this.$refs.scrollView.$refs &&
this.$refs.scrollView.$refs.content
? this.$refs.scrollView.$refs.content.scrollHeight
: 0;
this.scrollTop = height;
});
if (newdata == data) { if (newdata == data) {
if (optionType == 0 || optionType == 1) { if (optionType == 0 || optionType == 1) {
@ -545,15 +536,7 @@ export default {
data, data,
}, },
]; ];
this.$nextTick(() => { this.scrollBottom();
const height =
this.$refs.scrollView &&
this.$refs.scrollView.$refs &&
this.$refs.scrollView.$refs.content
? this.$refs.scrollView.$refs.content.scrollHeight
: 0;
this.scrollTop = height;
});
} }
}, },

@ -7,6 +7,7 @@
height: isExpanded ? 'calc(100% - 332rpx)' : 'calc(100% - 210rpx)', height: isExpanded ? 'calc(100% - 332rpx)' : 'calc(100% - 210rpx)',
}" }"
class="chatlist" class="chatlist"
id="scrollView"
ref="scrollView" ref="scrollView"
@click="clickContent" @click="clickContent"
> >
@ -34,7 +35,7 @@
</view> </view>
<view <view
:class="['bar', item.answerId == '0' ? 'currAnswer' : '']" :class="['bar', item.answerId == '0' ? 'currAnswer' : '']"
v-for="(item) in msgList" v-for="item in msgList"
:key="item.id" :key="item.id"
> >
<!--<image :src="item.answerId == '0' ? $.imgSrc + '/self.png' : $.imgSrc + '/left_user.png'" class="img" />--> <!--<image :src="item.answerId == '0' ? $.imgSrc + '/self.png' : $.imgSrc + '/left_user.png'" class="img" />-->
@ -161,253 +162,13 @@ export default {
this.es = null; this.es = null;
} }
}, },
// methods: {
// async queryChat(voiceText) {
// // console.log(voiceText,"voiceText");
// this.loading = true;
// const [err, res] = await uni.request({
// // url: 'http://10.16.3.159:8777/api/local_doc_qa/local_doc_chat',
// url: this.$.chatUrl+'/chat',
// dataType: 'json',
// method: 'POST',
// // responseType: 'arraybuffer',
// headers: {
// // 'Accept': 'text/event-stream',
// 'content-type': 'application/json'
// },
// data: {
// voiceText,
// "sceneFlag": "",
// "sessionId": this.sessionId,
// "id": this.id,
// "multiType": "",
// "userId": "admin1",
// "deptId": "3702000000",
// "type": '0',
// "stream": 'false',
// // "user_id": "zzp",
// // "kb_ids": ["KBa80ea15e786241eca70a20f136f4e34c"],
// // "question": "",
// // "streaming": true,
// // "history": []
// }
// });
// console.log(res)
// if (res && res.data && res.data.code == 200) {
// // console.log('request success', res.data)
// const {
// result = {}
// } = res.data;
// const {
// data = {}
// } = result;
// if (data.tabkey - 1 != this.active) {
// this.active = data.tabkey - 1 > 0 ? data.tabkey - 1 : 0;
// }
// if (data.content) {
// this.changeMsgList(data.answerId || '1', data.content);
// }
// this.loading = false;
// } else {
// if (err) {
// console.log('request fail', err.errMsg);
// }
// uni.showToast({
// title: "",
// icon: "error",
// duration: 2000
// })
// }
// },
// //
// handleBtn(text) {
// this.handleSend(text)
// },
// //
// onKeyInput(event) {
// this.inputValue = event.detail.value
// },
// //
// handleSend(text) {
// if (!this.inputValue & !text) {
// uni.showToast({
// title: "",
// icon: "closeempty",
// duration: 2000
// })
// }
// this.changeMsgList('0', this.inputValue || text);
// this.queryChat(this.inputValue || text,);
// this.inputValue = '';
// },
// //
// changeMsgList(answerId, data) {
// let id = 1;
// if (this.msgList.length > 0) {
// id = this.msgList[this.msgList.length - 1].id + 1;
// }
// if (answerId == '1') { //
// let newdata = '';
// let index = 0;
// const timer = setInterval(() => {
// console.log(this.msgList);
// newdata = newdata += data[index]
// if (this.msgList?.filter(item => (item.id == id)).length == 0) {
// this.msgList = [...this.msgList, {
// id,
// answerId,
// data: newdata,
// }];
// } else {
// this.msgList[this.msgList.length - 1].data = newdata;
// }
// index += 1;
// this.$nextTick(() => {
// const height = this.$refs.scrollView && this.$refs.scrollView.$refs && this
// .$refs.scrollView.$refs.content ? this.$refs.scrollView.$refs.content
// .scrollHeight : 0;
// this.scrollTop = height;
// })
// if (newdata == data) {
// clearInterval(timer);
// }
// }, 50)
// } else {
// this.msgList = [...this.msgList, {
// id,
// answerId,
// data,
// }];
// this.$nextTick(() => {
// const height = this.$refs.scrollView && this.$refs.scrollView.$refs && this.$refs
// .scrollView.$refs.content ? this.$refs.scrollView.$refs.content.scrollHeight : 0;
// this.scrollTop = height;
// })
// }
// },
// handlePlus() {
// this.isExpanded = !this.isExpanded;
// },
// clickContent() {
// if (this.isExpanded) {
// this.isExpanded = !this.isExpanded;
// }
// },
// goToKnowledge() {
// uni.navigateTo({
// url: `/pages/home/detail?params=${encodeURIComponent(JSON.stringify(item))}`
// })
// },
// //
// chooseImage() {
// uni.chooseImage({
// count: 6, //9
// sizeType: ['original', 'compressed'], //
// sourceType: ['album'], //
// success: (res) => {
// if (res.tempFilePaths && res.tempFilePaths.length) {
// let str = '';
// for (let i = 0; i < res.tempFilePaths.length; i++) {
// str += `![${i + 1}](${res.tempFilePaths[i]})`;
// }
// this.changeMsgList('0', str);
// this.queryChat(res.tempFilePaths);
// }
// }
// });
// }
// }
methods: { methods: {
// SSE
SSE(voiceText, answerId) {
const ctrl = new AbortController();
console.log(ctrl.signal);
fetchEventSource($.chatUrl + "/chat", {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: ["text/event-stream", "application/json"],
},
body: JSON.stringify({
voiceText,
deptId: "3702000000",
id: "37020017407",
multiType: "",
sceneFlag: "",
stream: true,
type: "0",
userId: "admin1",
}),
signal: ctrl.signal,
openWhenHidden: true,
onopen: () => {},
onmessage: (ev) => {
console.log(ev);
this.loading = true;
const res = JSON.parse(ev.data);
if (res?.code == 200 && res.result) {
console.log(res.result.data.tabkey);
console.log(res.result.data);
this.tabkey = res.result.data.tabkey;
if (this.tabkey - 1 != this.active) {
this.active = this.tabkey - 1 > 0 ? this.tabkey - 1 : 0;
}
if (this.msgList.length == 0) {
this.msgList = [
{
answerId,
data: res.result.data.content,
},
];
} else {
// debugger
//
if (this.msgList[this.msgList.length - 1].answerId == "1") {
//
this.msgList[this.msgList.length - 1].data +=
res.result.data.content;
} else {
//
this.msgList = [
...this.msgList,
{
answerId: "1",
data: res.result.data.content,
},
];
}
}
// debugger
this.scrollBottom();
}
},
onclose: () => {
console.log(1111);
this.loading = false;
if (this.isExpanded) {
this.isExpanded = !this.isExpanded;
}
},
onerror(error) {
console.log("error", error);
throw error;
},
});
},
async queryChat(voiceText) { async queryChat(voiceText) {
// console.log(voiceText,"voiceText"); // console.log(voiceText,"voiceText");
this.loading = true; this.loading = true;
const [err, res] = await uni.request({ const [err, res] = await uni.request({
// url: 'http://10.16.3.159:8777/api/local_doc_qa/local_doc_chat', // url: 'http://10.16.3.159:8777/api/local_doc_qa/local_doc_chat',
url: $.chatUrl + "/chat", url: this.$.chatUrl + "/chat",
dataType: "json", dataType: "json",
method: "POST", method: "POST",
// responseType: 'arraybuffer', // responseType: 'arraybuffer',
@ -417,14 +178,13 @@ export default {
}, },
data: { data: {
voiceText, voiceText,
sceneFlag: "", deptId: "3702000000",
sessionId: this.sessionId, id: "37020017407",
id: this.id,
multiType: "", multiType: "",
sceneFlag: "",
stream: false,
type: "0",
userId: "admin1", userId: "admin1",
deptId: "3702000000",
type: '0',
stream: true,
// "user_id": "zzp", // "user_id": "zzp",
// "kb_ids": ["KBa80ea15e786241eca70a20f136f4e34c"], // "kb_ids": ["KBa80ea15e786241eca70a20f136f4e34c"],
// "question": "", // "question": "",
@ -432,24 +192,18 @@ export default {
// "history": [] // "history": []
}, },
}); });
console.log(res);
if (res && res.data && res.data.code == 200) { if (res && res.data && res.data.code == 200) {
// console.log('request success', res.data) // console.log('request success', res.data)
const { result = {} } = res.data; // const { result = {} } = res.data;
const { data = {} } = result; // const { data = {} } = result;
if (data.tabkey - 1 != this.active) { // if (data.tabkey - 1 != this.active) {
this.active = data.tabkey - 1 > 0 ? data.tabkey - 1 : 0; // this.active = data.tabkey - 1 > 0 ? data.tabkey - 1 : 0;
} // }
if (data.content) { if (res.data.result) {
this.changeMsgList( this.changeMsgList("1", res.data.result);
data.answerId || "1",
data.content,
data.answerOptions
);
} }
this.loading = false; this.loading = false;
if (this.isExpanded) {
this.isExpanded = !this.isExpanded;
}
} else { } else {
if (err) { if (err) {
console.log("request fail", err.errMsg); console.log("request fail", err.errMsg);
@ -461,30 +215,14 @@ export default {
}); });
} }
}, },
//
handleBtn(text) {
this.handleSend(text);
},
// //
onKeyInput(event) { onKeyInput(event) {
this.inputValue = event.detail.value; this.inputValue = event.detail.value;
}, },
addQuestion(q, answerId) {
const newQuestion = {
answerId,
data: q,
};
this.msgList.push(newQuestion); //
// this.$store.commit('setMSg_List', this.msgList);
this.scrollBottom();
},
scrollBottom() {
this.$nextTick(() => {
const height =
this.$refs.scrollView &&
this.$refs.scrollView.$refs &&
this.$refs.scrollView.$refs.content
? this.$refs.scrollView.$refs.content.scrollHeight
: 0;
this.scrollTop = height;
});
},
// //
handleSend(text) { handleSend(text) {
if (!this.inputValue & !text) { if (!this.inputValue & !text) {
@ -494,20 +232,12 @@ export default {
duration: 2000, duration: 2000,
}); });
} }
if (text || this.inputValue) { this.changeMsgList("0", this.inputValue || text);
// if (this.params.id == 12121212) { this.queryChat(this.inputValue || text);
// this.changeMsgList("0", this.inputValue || text); this.inputValue = "";
// this.queryChat(this.inputValue || text);
// this.scrollBottom();
// } else {
this.addQuestion(this.inputValue || text, "0");
this.SSE(this.inputValue || text, "0");
// }
this.inputValue = "";
}
}, },
// //
changeMsgList(answerId, data, answerOptions) { changeMsgList(answerId, data) {
let id = 1; let id = 1;
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;
@ -517,7 +247,6 @@ export default {
let newdata = ""; let newdata = "";
let index = 0; let index = 0;
const timer = setInterval(() => { const timer = setInterval(() => {
console.log(this.msgList);
newdata = newdata += data[index]; newdata = newdata += data[index];
if (this.msgList?.filter((item) => item.id == id).length == 0) { if (this.msgList?.filter((item) => item.id == id).length == 0) {
this.msgList = [ this.msgList = [
@ -526,7 +255,6 @@ export default {
id, id,
answerId, answerId,
data: newdata, data: newdata,
// options: answerOptions // ['西','','','西'] answerOptions
}, },
]; ];
} else { } else {
@ -534,16 +262,15 @@ export default {
} }
index += 1; index += 1;
this.$nextTick(() => { this.$nextTick(() => {
const height = // const height =
this.$refs.scrollView && // this.$refs.scrollView &&
this.$refs.scrollView.$refs && // this.$refs.scrollView.$refs &&
this.$refs.scrollView.$refs.content // this.$refs.scrollView.$refs.content
? this.$refs.scrollView.$refs.content.scrollHeight // ? this.$refs.scrollView.$refs.content.scrollHeight
: 0; // : 0;
this.scrollTop = height; this.scrollTop = this.scrollTop + 1;
}); });
if (newdata == data) { if (newdata == data) {
this.msgList[this.msgList.length - 1].options = answerOptions;
clearInterval(timer); clearInterval(timer);
} }
}, 50); }, 50);
@ -557,24 +284,19 @@ export default {
}, },
]; ];
this.$nextTick(() => { this.$nextTick(() => {
const height = // const height =
this.$refs.scrollView && // this.$refs.scrollView &&
this.$refs.scrollView.$refs && // this.$refs.scrollView.$refs &&
this.$refs.scrollView.$refs.content // this.$refs.scrollView.$refs.content
? this.$refs.scrollView.$refs.content.scrollHeight // ? this.$refs.scrollView.$refs.content.scrollHeight
: 0; // : 0;
this.scrollTop = height; this.scrollTop = this.scrollTop + 1;
}); });
} }
}, },
handlePlus() { handlePlus() {
this.isExpanded = !this.isExpanded; this.isExpanded = !this.isExpanded;
}, },
//
handleBtn(text) {
this.handleSend(text);
},
clickContent() { clickContent() {
if (this.isExpanded) { if (this.isExpanded) {
this.isExpanded = !this.isExpanded; this.isExpanded = !this.isExpanded;
@ -582,10 +304,12 @@ export default {
}, },
goToKnowledge() { goToKnowledge() {
uni.navigateTo({ uni.navigateTo({
url: "/pages/home/knowledge", url: `/pages/home/detail?params=${encodeURIComponent(
// url: `/pages/home/knowledge?params=${encodeURIComponent(JSON.stringify(this.$route.query.params))}` JSON.stringify(item)
)}`,
}); });
}, },
// //
chooseImage() { chooseImage() {
uni.chooseImage({ uni.chooseImage({
@ -593,24 +317,26 @@ export default {
sizeType: ["original", "compressed"], // sizeType: ["original", "compressed"], //
sourceType: ["album"], // sourceType: ["album"], //
success: async (res) => { success: async (res) => {
console.log(res) console.log(res);
if (res.tempFilePaths && res.tempFilePaths.length) { if (res.tempFilePaths && res.tempFilePaths.length) {
let str = ""; let str = "";
let jsonArr = [] let jsonArr = [];
for (let i = 0; i < res.tempFilePaths.length; i++) { for (let i = 0; i < res.tempFilePaths.length; i++) {
const result = await this.uploadFilePromise(res.tempFilePaths[i]); const result = await this.uploadFilePromise(res.tempFilePaths[i]);
let json = JSON.parse(result) let json = JSON.parse(result);
str += `![图${i + 1}](${json.result})`; str += `![图${i + 1}](${json.result})`;
jsonArr.push(json.result) jsonArr.push(json.result);
} }
console.log(str) console.log(str);
if (this.id == 12121212) { if (this.id == 12121212) {
this.changeMsgList("0", str); this.changeMsgList("0", str);
this.queryChat(res.tempFilePaths); this.queryChat(jsonArr);
} else { } else {
this.addQuestion(str, "0"); // this.addQuestion(str, "0");
this.SSE(jsonArr, "0"); // this.SSE(jsonArr, "0");
this.changeMsgList("0", str);
this.queryChat(jsonArr);
} }
} }
}, },
@ -619,16 +345,310 @@ export default {
uploadFilePromise(url) { uploadFilePromise(url) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let a = uni.uploadFile({ let a = uni.uploadFile({
url: this.$.baseUrl + '/hiddenDanger/ftp/uploadFileToFtp', // url: this.$.baseUrl + "/hiddenDanger/ftp/uploadFileToFtp", //
filePath: url, filePath: url,
name: 'file', name: "file",
success: (res) => { success: (res) => {
resolve(res.data) resolve(res.data);
} },
}); });
}) });
}, },
}, },
// methods: {
// // SSE
// SSE(voiceText, answerId) {
// const ctrl = new AbortController();
// console.log(ctrl.signal);
// fetchEventSource($.chatUrl + "/chat", {
// method: "POST",
// headers: {
// "Content-Type": "application/json",
// Accept: ["text/event-stream", "application/json"],
// },
// body: JSON.stringify({
// voiceText,
// deptId: "3702000000",
// id: "37020017407",
// multiType: "",
// sceneFlag: "",
// stream: true,
// type: "0",
// userId: "admin1",
// }),
// signal: ctrl.signal,
// openWhenHidden: true,
// onopen: () => {},
// onmessage: (ev) => {
// console.log(ev);
// this.loading = true;
// const res = JSON.parse(ev.data);
// if (res?.code == 200 && res.result) {
// console.log(res.result.data.tabkey);
// console.log(res.result.data);
// this.tabkey = res.result.data.tabkey;
// if (this.tabkey - 1 != this.active) {
// this.active = this.tabkey - 1 > 0 ? this.tabkey - 1 : 0;
// }
// if (this.msgList.length == 0) {
// this.msgList = [
// {
// answerId,
// data: res.result.data.content,
// },
// ];
// } else {
// // debugger
// //
// if (this.msgList[this.msgList.length - 1].answerId == "1") {
// //
// this.msgList[this.msgList.length - 1].data +=
// res.result.data.content;
// } else {
// //
// this.msgList = [
// ...this.msgList,
// {
// answerId: "1",
// data: res.result.data.content,
// },
// ];
// }
// }
// // debugger
// this.scrollBottom();
// }
// },
// onclose: () => {
// console.log(1111);
// this.loading = false;
// if (this.isExpanded) {
// this.isExpanded = !this.isExpanded;
// }
// },
// onerror(error) {
// console.log("error", error);
// throw error;
// },
// });
// },
// async queryChat(voiceText) {
// // console.log(voiceText,"voiceText");
// this.loading = true;
// const [err, res] = await uni.request({
// // url: 'http://10.16.3.159:8777/api/local_doc_qa/local_doc_chat',
// url: $.chatUrl + "/chat",
// dataType: "json",
// method: "POST",
// // responseType: 'arraybuffer',
// headers: {
// // 'Accept': 'text/event-stream',
// "content-type": "application/json",
// },
// data: {
// voiceText,
// sceneFlag: "",
// sessionId: this.sessionId,
// id: this.id,
// multiType: "",
// userId: "admin1",
// deptId: "3702000000",
// type: '0',
// stream: false,
// // "user_id": "zzp",
// // "kb_ids": ["KBa80ea15e786241eca70a20f136f4e34c"],
// // "question": "",
// // "streaming": true,
// // "history": []
// },
// });
// if (res && res.data && res.data.code == 200) {
// // console.log('request success', res.data)
// const { result = {} } = res.data;
// const { data = {} } = result;
// if (data.tabkey - 1 != this.active) {
// this.active = data.tabkey - 1 > 0 ? data.tabkey - 1 : 0;
// }
// if (data.content) {
// this.changeMsgList(
// data.answerId || "1",
// data.content,
// data.answerOptions
// );
// }
// this.loading = false;
// if (this.isExpanded) {
// this.isExpanded = !this.isExpanded;
// }
// } else {
// if (err) {
// console.log("request fail", err.errMsg);
// }
// uni.showToast({
// title: "",
// icon: "error",
// duration: 2000,
// });
// }
// },
// //
// onKeyInput(event) {
// this.inputValue = event.detail.value;
// },
// addQuestion(q, answerId) {
// const newQuestion = {
// answerId,
// data: q,
// };
// this.msgList.push(newQuestion); //
// // this.$store.commit('setMSg_List', this.msgList);
// this.scrollBottom();
// },
// scrollBottom() {
// this.$nextTick(() => {
// // const height =
// // this.$refs.scrollView &&
// // this.$refs.scrollView.$refs &&
// // this.$refs.scrollView.$refs.content
// // ? this.$refs.scrollView.$refs.content.scrollHeight
// // : 0;
// this.scrollTop = this.scrollTop + 1;
// });
// },
// //
// handleSend(text) {
// if (!this.inputValue & !text) {
// uni.showToast({
// title: "",
// icon: "closeempty",
// duration: 2000,
// });
// }
// if (text || this.inputValue) {
// // if (this.params.id == 12121212) {
// this.changeMsgList("0", this.inputValue || text);
// this.queryChat(this.inputValue || text);
// this.scrollBottom();
// // } else {
// // this.addQuestion(this.inputValue || text, "0");
// // this.SSE(this.inputValue || text, "0");
// // }
// this.inputValue = "";
// }
// },
// //
// changeMsgList(answerId, data, answerOptions) {
// let id = 1;
// if (this.msgList.length > 0) {
// id = this.msgList[this.msgList.length - 1].id + 1;
// }
// if (answerId == "1") {
// //
// let newdata = "";
// let index = 0;
// const timer = setInterval(() => {
// newdata = newdata += data[index];
// if (this.msgList?.filter((item) => item.id == id).length == 0) {
// this.msgList = [
// ...this.msgList,
// {
// id,
// answerId,
// data: newdata,
// // options: answerOptions // ['西','','','西'] answerOptions
// },
// ];
// } else {
// this.msgList[this.msgList.length - 1].data = newdata;
// }
// index += 1;
// this.scrollBottom();
// if (newdata == data) {
// this.msgList[this.msgList.length - 1].options = answerOptions;
// clearInterval(timer);
// }
// }, 50);
// } else {
// this.msgList = [
// ...this.msgList,
// {
// id,
// answerId,
// data,
// },
// ];
// this.scrollBottom();
// }
// },
// handlePlus() {
// this.isExpanded = !this.isExpanded;
// },
// //
// handleBtn(text) {
// this.handleSend(text);
// },
// clickContent() {
// if (this.isExpanded) {
// this.isExpanded = !this.isExpanded;
// }
// },
// goToKnowledge() {
// uni.navigateTo({
// url: "/pages/home/knowledge",
// // url: `/pages/home/knowledge?params=${encodeURIComponent(JSON.stringify(this.$route.query.params))}`
// });
// },
// //
// chooseImage() {
// uni.chooseImage({
// count: 6, //9
// sizeType: ["original", "compressed"], //
// sourceType: ["album"], //
// success: async (res) => {
// console.log(res)
// if (res.tempFilePaths && res.tempFilePaths.length) {
// let str = "";
// let jsonArr = []
// for (let i = 0; i < res.tempFilePaths.length; i++) {
// const result = await this.uploadFilePromise(res.tempFilePaths[i]);
// let json = JSON.parse(result)
// str += `![${i + 1}](${json.result})`;
// jsonArr.push(json.result)
// }
// console.log(str)
// if (this.id == 12121212) {
// this.changeMsgList("0", str);
// this.queryChat(jsonArr);
// } else {
// // this.addQuestion(str, "0");
// // this.SSE(jsonArr, "0");
// this.changeMsgList("0", str);
// this.queryChat(jsonArr);
// }
// }
// },
// });
// },
// uploadFilePromise(url) {
// return new Promise((resolve, reject) => {
// let a = uni.uploadFile({
// url: this.$.baseUrl + '/hiddenDanger/ftp/uploadFileToFtp', //
// filePath: url,
// name: 'file',
// success: (res) => {
// resolve(res.data)
// }
// });
// })
// },
// },
}; };
</script> </script>

Loading…
Cancel
Save