chore:商品可以分享给智能客服进行解答
This commit is contained in:
@@ -257,6 +257,20 @@ export default {
|
||||
// ========== 初始化页面 ==========
|
||||
initChat() {
|
||||
console.log('AI聊天页面初始化');
|
||||
|
||||
// 检查是否有从商品分类传递过来的商品信息
|
||||
const selectedProduct = uni.getStorageSync('selectedProduct')
|
||||
if (selectedProduct) {
|
||||
console.log('检测到选择的商品:', selectedProduct)
|
||||
|
||||
// 清除存储的商品信息,避免重复发送
|
||||
uni.removeStorageSync('selectedProduct')
|
||||
|
||||
// 延迟发送商品信息,确保聊天组件已经初始化
|
||||
setTimeout(() => {
|
||||
this.sendProductToAI(selectedProduct)
|
||||
}, 500)
|
||||
}
|
||||
},
|
||||
|
||||
async initNavigation() {
|
||||
@@ -482,6 +496,20 @@ export default {
|
||||
onVideoPause(message) {
|
||||
console.log('视频暂停:', message);
|
||||
},
|
||||
|
||||
sendProductToAI(product) {
|
||||
if (!this.$refs.chat) {
|
||||
console.error('聊天组件未初始化')
|
||||
return
|
||||
}
|
||||
|
||||
const productContent = `我想了解以下商品的详细信息:\n商品名称:${product.goods_name}\n价格:¥${product.price}\n商品ID:${product.goods_id}`
|
||||
|
||||
console.log('商品信息已发送到AI客服:', productContent)
|
||||
|
||||
// 使用sendMessageWithContent方法发送商品信息
|
||||
this.$refs.chat.sendMessageWithContent(productContent)
|
||||
},
|
||||
|
||||
onLinkOpen(message) {
|
||||
uni.showModal({
|
||||
|
||||
Reference in New Issue
Block a user