diff --git a/src/views/AI/components/chat.vue b/src/views/AI/components/chat.vue index 88158ba..e9583ff 100644 --- a/src/views/AI/components/chat.vue +++ b/src/views/AI/components/chat.vue @@ -212,10 +212,10 @@ export default { think: '', isLike: false, isDisLike: false, - }), + }) ) this.messages.push(this.currentMessage) - const params = { + let params = { query: this.newMessage, isDeep: this.isDeep ? 1 : 0, isOnline: this.isSearching ? 1 : 0, @@ -223,6 +223,11 @@ export default { conversationId: this.conversationId, productName: this.productName, } + + if (this.$route.query.compareId) { + params.compareResult = JSON.parse(sessionStorage.getItem('results')) + } + fetch(chat(), { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -307,6 +312,8 @@ export default { sendMessage() { if (this.messageStatus === 'send') return if (this.newMessage.trim() === '') return + // 防止xss + this.newMessage = this.newMessage.replace(/<[^>]+>/g, '') this.messages.push({ type: 'user', text: this.newMessage }) this.$emit('update:messageStatus', 'send') // this.messageStatus = 'send' @@ -315,10 +322,10 @@ export default { return } - if (this.newMessage.includes('产品对比')) { - // this.hasTreasureBox() - return - } + // if (this.newMessage.includes('产品对比')) { + // // this.hasTreasureBox() + // return + // } // this.autoScrollEnabled = true this.$emit('update:autoScrollEnabled', true) diff --git a/src/views/AI/components/message.vue b/src/views/AI/components/message.vue index be51e7c..5d4d9d4 100644 --- a/src/views/AI/components/message.vue +++ b/src/views/AI/components/message.vue @@ -3,7 +3,7 @@
-

{{ message.text }}

+

diff --git a/src/views/AI/index.vue b/src/views/AI/index.vue index 0bc24cc..8aa9f5a 100644 --- a/src/views/AI/index.vue +++ b/src/views/AI/index.vue @@ -82,15 +82,25 @@ export default { } if (!compareId) { + sessionStorage.removeItem('results') this.messages.push({ type: 'bot', text: '欢迎使用AI智能助手,请输入问题开始对话或输入关键词 "xxx工具箱","产品对比"。', }) } else { // 可以调用接口展示 名字 或者存在session里 + + let sesstions = JSON.parse(sessionStorage.getItem('results')).productResults + console.log(sesstions) + let text = sesstions.map((item) => { + return item.productName + '
' + }) + console.log(text) + let other = '对比产品
' + text.join('') + this.messages.push({ type: 'user', - text: compareId, + text: other, }) } this.getHotProducts() diff --git a/src/views/app/Home.vue b/src/views/app/Home.vue index 989991b..1408326 100644 --- a/src/views/app/Home.vue +++ b/src/views/app/Home.vue @@ -34,6 +34,9 @@ export default { [Swipe.name]: Swipe, [SwipeItem.name]: SwipeItem, }, + created() { + sessionStorage.removeItem('results') + }, data() { return { navigationItems: [ diff --git a/src/views/comparison/table.vue b/src/views/comparison/table.vue index 47e87d6..304d003 100644 --- a/src/views/comparison/table.vue +++ b/src/views/comparison/table.vue @@ -18,7 +18,7 @@
返回 - + 提问
@@ -83,7 +83,7 @@ export default { obj[item.productId] = item.knowledge[keys] } }) - console.log(this.tableData) + sessionStorage.setItem('results', JSON.stringify(res.content)) } }) },