Refactor(云灵AI):各种列表展示通过类型逻辑对接

This commit is contained in:
lifizer
2026-04-15 23:55:47 +08:00
parent bca2513d22
commit b8413ab13f
2 changed files with 113 additions and 66 deletions
+41 -6
View File
@@ -245,10 +245,13 @@ export const chatMixinsV2 = {
prizeList: [], prizeList: [],
// 店铺 // 店铺
shopList: [], shopList: [],
// 地标好物--屏蔽原因:实现此功能时,后端通过AI动态返回的图片不满足需求,后面就不要了
landmarksList: [],
// 订单 // 订单
orderList: [], orderList: [],
type: -2, type: -2,
showMoreInfo: {} showMoreInfo: {},
currentSwiperIndex: 0
}) })
_this.loading = true _this.loading = true
_this.showCursor = false _this.showCursor = false
@@ -316,30 +319,59 @@ export const chatMixinsV2 = {
console.log('-------------监听 WebSocket 接受到服务器的消息事件') console.log('-------------监听 WebSocket 接受到服务器的消息事件')
const resData = JSON.parse(res.data) const resData = JSON.parse(res.data)
if (resData) { if (resData) {
console.log(resData)
const message = resData.message const message = resData.message
console.log(message)
if (message && this.chatMessageListLength > 1) { if (message && this.chatMessageListLength > 1) {
const mesContent = message.content const mesContent = message.content
const contentType = message.contentType const contentType = message.contentType
const finish = message.finish const finish = message.finish
// todo:判断是文本还是列表 if (contentType === 'text') {
if (contentType ==='text') {
if (!finish && mesContent) { if (!finish && mesContent) {
this.chatMessageList[this.chatMessageListLength - 1].nodes = formatAiMsgContent(mesContent) this.chatMessageList[this.chatMessageListLength - 1].nodes = formatAiMsgContent(mesContent)
this.chatMessageList[this.chatMessageListLength - 1].content = mesContent this.chatMessageList[this.chatMessageListLength - 1].content = mesContent
this.chatMessageList[this.chatMessageListLength - 1].listQuestion = message.listQuestion || [] this.chatMessageList[this.chatMessageListLength - 1].listQuestion = message.listQuestion || []
} }
} }
if (contentType ==='order') { if (contentType === 'order') {
if (!finish && message.listCards) { if (!finish && message.listCards) {
this.chatMessageList[this.chatMessageListLength - 1].orderList = message.listCards || [] this.chatMessageList[this.chatMessageListLength - 1].orderList = message.listCards || []
} }
} }
if (contentType ==='shop') { if (contentType === 'shop') {
if (!finish && message.listCards) { if (!finish && message.listCards) {
this.chatMessageList[this.chatMessageListLength - 1].shopList = message.listCards || [] this.chatMessageList[this.chatMessageListLength - 1].shopList = message.listCards || []
} }
} }
if (contentType === 'gift') {
if (!finish && message.listCards) {
this.chatMessageList[this.chatMessageListLength - 1].giftGoodsList = message.listCards || []
}
}
if (contentType === 'discount') {
if (!finish && message.listCards) {
this.chatMessageList[this.chatMessageListLength - 1].prizeList = message.listCards || []
}
}
if (contentType === 'goods') {
if (!finish && message.listCards) {
this.chatMessageList[this.chatMessageListLength - 1].goodsList = message.listCards || []
}
}
if (contentType === 'famous') {
if (!finish && message.listCards) {
this.chatMessageList[this.chatMessageListLength - 1].qianxianList = message.listCards || []
}
}
if (contentType === 'ich') {
if (!finish && message.listCards) {
this.chatMessageList[this.chatMessageListLength - 1].ichList = message.listCards || []
}
}
if (contentType === 'landmarks') {
if (!finish && message.listCards) {
this.chatMessageList[this.chatMessageListLength - 1].landmarksList = message.listCards || []
}
}
this.$forceUpdate() this.$forceUpdate()
this.$nextTick(() => { this.$nextTick(() => {
this.scrollToBottomHandle() this.scrollToBottomHandle()
@@ -371,6 +403,9 @@ export const chatMixinsV2 = {
console.log('send failed (' + err.code + ')') console.log('send failed (' + err.code + ')')
} }
}, },
onSwiperChange(index, e) {
this.chatMessageList[index].currentSwiperIndex = e.detail.current
},
analyzeKeywordsChangeHandle(conversationId, item) { analyzeKeywordsChangeHandle(conversationId, item) {
let listKey = '' let listKey = ''
// 抽奖和订单查询没有换一换 // 抽奖和订单查询没有换一换
+72 -60
View File
@@ -38,7 +38,7 @@
})">播放</button> --> })">播放</button> -->
<block v-if="chatMessageListLength < 1"> <block v-if="chatMessageListLength < 1">
<view class="home-wrap"> <view class="home-wrap">
<view class="home-focus-wrap" style="display: none;"> <view class="home-focus-wrap">
<view class="focus-guide-wrap"> <view class="focus-guide-wrap">
<view class="guide-left"> <view class="guide-left">
<image <image
@@ -54,7 +54,7 @@
</view> </view>
</view> </view>
<!-- 这里实现商品轮播 --> <!-- 这里实现商品轮播 -->
<view class="recommend-goods-wrap" v-if="recommendGoodsList.length > 0"> <!-- <view class="recommend-goods-wrap" v-if="recommendGoodsList.length > 0">
<swiper <swiper
class="goods-swiper" class="goods-swiper"
:indicator-dots="false" :indicator-dots="false"
@@ -95,7 +95,7 @@
</view> </view>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view> -->
<view class="topic-wrap"> <view class="topic-wrap">
<view class="title"> <view class="title">
<view class="title-left">大家都在问</view> <view class="title-left">大家都在问</view>
@@ -240,13 +240,68 @@
item.nodes && item.nodes &&
item.nodes.length && item.nodes.length &&
!item.isError && !item.isError &&
(item.showMoreInfo.show || item.orderList.length > 0) (item.orderList.length > 0 ||
item.giftGoodsList.length > 0 ||
item.goodsList.length > 0 ||
item.shopList.length > 0 ||
item.prizeList.length > 0 ||
item.ichList.length > 0 ||
item.qianxianList.length > 0
)
" "
class="change-list-wrap" class="change-list-wrap"
> >
<view v-if="item.showMoreInfo.showType === '特产商品'" class="list-wrap"> <!-- 礼品 -->
<view
v-if="item.giftGoodsList.length > 0"
class="recommend-goods-wrap"
>
<swiper
class="goods-swiper"
:indicator-dots="false"
:autoplay="false"
:current="item.currentSwiperIndex"
previous-margin="120rpx"
next-margin="120rpx"
circular
@change="e => onSwiperChange(index, e)"
>
<swiper-item
v-for="(goodItem, goodIndex) in item.giftGoodsList"
:key="goodIndex"
>
<view
:class="{ 'active': item.currentSwiperIndex === goodIndex }"
class="goods-item"
@click="productItemClickHandle(goodItem)"
>
<view class="supplier">
<image
:src="webUrl + '/aiChat/icon-57.png'"
class="icon"
mode="widthFix"
/>
<text class="s-name">{{ goodItem.supplierName }}</text>
<u-icon name="arrow-right" color="#999" size="12"></u-icon>
</view>
<view class="title one-t">{{ goodItem.name }}</view>
<image :src="goodItem.img" class="p-img" mode="aspectFill" />
<view class="price">
<text class="unit">¥</text>
<text class="num">{{ goodItem.price }}</text>
</view>
<view class="actions">
<view class="btn-buy" @click.stop="productItemBuyNowClickHandle(goodItem)">立即下单</view>
<view class="btn-gift" @click.stop="productItemGiftBuyClickHandle(goodItem)">送给朋友</view>
</view>
</view>
</swiper-item>
</swiper>
</view>
<!-- 特产商品 -->
<view v-if="item.goodsList.length > 0" class="list-wrap">
<view <view
v-for="(productItem, productIndex) in item.showMoreInfo.resultItems" v-for="(productItem, productIndex) in item.goodsList"
:key="productIndex" :key="productIndex"
class="product-item" class="product-item"
@click="productItemClickHandle(productItem)" @click="productItemClickHandle(productItem)"
@@ -268,6 +323,7 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 店铺 -->
<view v-if="item.shopList.length > 0" class="list-wrap"> <view v-if="item.shopList.length > 0" class="list-wrap">
<view <view
v-for="(hotel, hotelIndex) in item.shopList" v-for="(hotel, hotelIndex) in item.shopList"
@@ -292,9 +348,10 @@
</view> </view>
</view> </view>
</view> </view>
<view v-if="item.showMoreInfo.showType === '非遗文化'" class="list-wrap"> <!-- 非遗 -->
<view v-if="item.ichList.length > 0" class="list-wrap">
<view <view
v-for="(ich, ichIndex) in item.showMoreInfo.resultItems" v-for="(ich, ichIndex) in item.ichList"
:key="ichIndex" :key="ichIndex"
class="product-item" class="product-item"
@click="ichItemClickHandle(ich)" @click="ichItemClickHandle(ich)"
@@ -313,9 +370,10 @@
</view> </view>
</view> </view>
</view> </view>
<view v-if="item.showMoreInfo.showType === '千县名品'" class="list-wrap"> <!-- 千县 -->
<view v-if="item.qianxianList.length > 0" class="list-wrap">
<view <view
v-for="(qianxian, qianxianIndex) in item.showMoreInfo.resultItems" v-for="(qianxian, qianxianIndex) in item.qianxianList"
:key="qianxianIndex" :key="qianxianIndex"
class="product-item" class="product-item"
@click="qianxianItemClickHandle(qianxian)" @click="qianxianItemClickHandle(qianxian)"
@@ -331,9 +389,10 @@
</view> </view>
</view> </view>
</view> </view>
<view v-if="item.showMoreInfo.showType === '优惠活动'" class="list-wrap prize-list-wrap"> <!-- 抽奖 -->
<view v-if="item.prizeList.length > 0" class="list-wrap prize-list-wrap">
<view <view
v-for="(prize, prizeIndex) in item.showMoreInfo.resultItems" v-for="(prize, prizeIndex) in item.prizeList"
:key="prizeIndex" :key="prizeIndex"
class="prize-item" class="prize-item"
@click="prizeItemClickHandle(prize)" @click="prizeItemClickHandle(prize)"
@@ -345,6 +404,7 @@
/> />
</view> </view>
</view> </view>
<!-- 订单 -->
<view v-if="item.orderList.length > 0" class="order-list-wrap"> <view v-if="item.orderList.length > 0" class="order-list-wrap">
<view <view
v-for="(order, orderIndex) in item.orderList" v-for="(order, orderIndex) in item.orderList"
@@ -507,51 +567,6 @@ export default {
animationStr: '', animationStr: '',
settingInfo: {}, settingInfo: {},
topicList: [], topicList: [],
currentSwiperIndex: 0,
recommendGoodsList: [
{
supplierName: '供应商名称',
productName: '云南枇杷花蜜',
image: 'https://resource.xdd618.com/最近喜欢上了独龙玉手镯_3_若瑜_来自小红书网页版-20250616101810.jpg',
price: '65.00',
id: 334
},
{
supplierName: '供应商名称',
productName: '云南枇杷花蜜',
image: 'https://resource.xdd618.com/最近喜欢上了独龙玉手镯_3_若瑜_来自小红书网页版-20250616101810.jpg',
price: '65.00',
id: 334
},
{
supplierName: '供应商名称',
productName: '云南枇杷花蜜',
image: 'https://resource.xdd618.com/最近喜欢上了独龙玉手镯_3_若瑜_来自小红书网页版-20250616101810.jpg',
price: '65.00',
id: 334
},
{
supplierName: '供应商名称',
productName: '云南枇杷花蜜',
image: 'https://resource.xdd618.com/最近喜欢上了独龙玉手镯_3_若瑜_来自小红书网页版-20250616101810.jpg',
price: '65.00',
id: 334
},
{
supplierName: '供应商名称',
productName: '云南枇杷花蜜',
image: 'https://resource.xdd618.com/最近喜欢上了独龙玉手镯_3_若瑜_来自小红书网页版-20250616101810.jpg',
price: '65.00',
id: 334
},
{
supplierName: '供应商名称',
productName: '云南枇杷花蜜',
image: 'https://resource.xdd618.com/最近喜欢上了独龙玉手镯_3_若瑜_来自小红书网页版-20250616101810.jpg',
price: '65.00',
id: 334
}
],
onlyOneToAddCart: false onlyOneToAddCart: false
} }
}, },
@@ -618,9 +633,6 @@ export default {
this.createNewHandle() this.createNewHandle()
} }
}, },
onSwiperChange(e) {
this.currentSwiperIndex = e.detail.current
},
pageContainerBeforeleave() { pageContainerBeforeleave() {
if (!this.chatNumber) { if (!this.chatNumber) {
if (getCurrentPages().length > 1) { if (getCurrentPages().length > 1) {