Refactor(云灵AI):礼品商品轮播效果实现

This commit is contained in:
lifizer
2026-04-15 18:59:18 +08:00
parent 1d8b75e2d2
commit bca2513d22
6 changed files with 339 additions and 21 deletions
+101 -10
View File
@@ -3,8 +3,11 @@ import {
getCompletionsV3,
deleteChatItemByConversationId,
// getAnalyzeKeywordsV1,
getAnalyzeKeywordsChangeV1
getAnalyzeKeywordsChangeV3
} from '@/api/chat/index'
import {
postCartAdd
} from '@/api/store'
import { VUE_APP_API_URL } from '@/config'
import settings from '@/config/baseSetting.js'
import { formatAiMsgContent } from '../utils/aiChat'
@@ -46,6 +49,7 @@ export const chatMixinsV2 = {
isScrollToBottom: false,
// 状态栏高度
statusBarHeight: 20,
bottomSafeDistance: 0,
fileHttpStr: Object.freeze(VUE_APP_API_URL + settings.sysPrefix),
keyboardHeight: 0,
optionsFrom: '',
@@ -75,7 +79,9 @@ export const chatMixinsV2 = {
audioAyy: [],
isPlayAudio: false,
audioContext: null,
audioPlayId: ''
audioPlayId: '',
showGiftBtn: false,
buyLoading: false
}
},
computed: {
@@ -118,6 +124,7 @@ export const chatMixinsV2 = {
// #endif
// 状态栏高度
_this.statusBarHeight = statusBar
_this.bottomSafeDistance = e.safeAreaInsets.bottom
}
})
_this.createdCallbak()
@@ -226,6 +233,19 @@ export const chatMixinsV2 = {
conversationId: '',
prompt,
listQuestion: [],
// 特产商品
goodsList: [],
// 礼品商品
giftGoodsList: [],
// 非遗文化
ichList: [],
// 千县名品
qianxianList: [],
// 抽奖
prizeList: [],
// 店铺
shopList: [],
// 订单
orderList: [],
type: -2,
showMoreInfo: {}
@@ -315,6 +335,11 @@ export const chatMixinsV2 = {
this.chatMessageList[this.chatMessageListLength - 1].orderList = message.listCards || []
}
}
if (contentType ==='shop') {
if (!finish && message.listCards) {
this.chatMessageList[this.chatMessageListLength - 1].shopList = message.listCards || []
}
}
this.$forceUpdate()
this.$nextTick(() => {
this.scrollToBottomHandle()
@@ -346,23 +371,39 @@ export const chatMixinsV2 = {
console.log('send failed (' + err.code + ')')
}
},
analyzeKeywordsChangeHandle(conversationId, showMoreInfo) {
getAnalyzeKeywordsChangeV1({
conversationId,
...showMoreInfo
analyzeKeywordsChangeHandle(conversationId, item) {
let listKey = ''
// 抽奖和订单查询没有换一换
if (item.goodsList.length > 0) {
listKey = 'goodsList'
}
if (item.giftGoodsList.length > 0) {
listKey = 'giftGoodsList'
}
if (item.ichList.length > 0) {
listKey = 'ichList'
}
if (item.qianxianList.length > 0) {
listKey = 'qianxianList'
}
if (item.shopList.length > 0) {
listKey = 'shopList'
}
getAnalyzeKeywordsChangeV3({
conversationId
}).then(res => {
const { success, data } = res
if (success) {
let resultItems = []
let changeList = []
let idx = -1
this.chatMessageList.map((item, index) => {
if (item.conversationId === conversationId) {
resultItems = data.resultItems || []
changeList = data.list || []
idx = index
}
})
if (idx > -1) {
this.$set(this.chatMessageList[idx].showMoreInfo, 'resultItems', resultItems)
if (idx > -1 && listKey) {
this.$set(this.chatMessageList[idx], 'listKey', changeList)
this.$forceUpdate()
}
}
@@ -377,6 +418,56 @@ export const chatMixinsV2 = {
}
})
},
productItemBuyNowClickHandle(item) {
this.showGiftBtn = false
this.cart_num = 1
this.addToCart(item)
},
productItemGiftBuyClickHandle(item) {
this.showGiftBtn = true
this.cart_num = 1
this.addToCart(item)
},
buyNowOrGiftBuyReq(type) {
const _this = this
if (_this.buyLoading) {
return
}
_this.buyLoading = true
postCartAdd({
productId: _this.m_id,
cartNum: _this.attr.productSelect.cart_num,
new: 1,
uniqueId: _this.attr.productSelect !== undefined ? _this.attr.productSelect.unique : ''
}).then(function (res) {
try {
_this.$set(_this.attr, 'cartAttr', false)
const { cartId } = res.data
if (type === 1) {
uni.navigateTo({
url: '/pages/order/OrderSubmission/index?id=' + cartId
})
return
}
if(type === 2) {
uni.navigateTo({
url: '/pkg_user/views/gift/gift?cartId=' + cartId
})
return
}
} catch (error) {
console.log(error)
}
}).catch(error => {
uni.showToast({
title: error.msg,
icon: "none",
duration: 5000
})
}).finally(() => {
_this.buyLoading = false
})
},
hotelItemClickHandle(item) {
this.audioStopHandle()
this.$yrouter.push({