Fix:5371 【商城小程序】甄选好礼对应分类下无商品不会提示

This commit is contained in:
linxi
2026-07-14 14:17:31 +08:00
parent 6d963a5bc0
commit 8f7ff49641
+22 -4
View File
@@ -36,7 +36,7 @@
</view> </view>
</view> </view>
<view class="product-wrap v12-mt-3"> <view v-if="products.length > 0" class="product-wrap v12-mt-3">
<view class="product-card" v-for="(item, index) in products" :key="index" @click="toGoods(item)"> <view class="product-card" v-for="(item, index) in products" :key="index" @click="toGoods(item)">
<image :src="item.productImage" class="product-card-img" mode="heightFix|widthFix"></image> <image :src="item.productImage" class="product-card-img" mode="heightFix|widthFix"></image>
<view class="new-info"> <view class="new-info">
@@ -53,6 +53,9 @@
</view> </view>
</view> </view>
</view> </view>
<view v-else class="empty-wrap">
<view class="empty-text">暂无数据</view>
</view>
<ProductWindow <ProductWindow
ref="attrWindow" ref="attrWindow"
:attr="attr" :attr="attr"
@@ -99,8 +102,12 @@ export default{
onLoad() { onLoad() {
queryNewZone().then(res => { queryNewZone().then(res => {
this.details = res.data this.details = res.data
this.tabs = res.data.categories this.tabs = Array.isArray(res.data.categories) ? res.data.categories : []
this.handleClick(0, this.tabs[0]) if (this.tabs.length > 0) {
this.handleClick(0, this.tabs[0])
} else {
this.products = []
}
}) })
}, },
computed: { computed: {
@@ -112,7 +119,7 @@ export default{
methods: { methods: {
handleClick(index, tab) { handleClick(index, tab) {
this.activeIndex = index this.activeIndex = index
this.products = tab.products this.products = Array.isArray(tab && tab.products) ? tab.products : []
}, },
handleChange(e) { handleChange(e) {
this.current = e.detail.current this.current = e.detail.current
@@ -144,6 +151,17 @@ export default{
justify-content: space-between; justify-content: space-between;
flex-wrap: wrap; flex-wrap: wrap;
} }
.empty-wrap{
min-height: 260rpx;
display: flex;
align-items: center;
justify-content: center;
}
.empty-text{
font-size: 28rpx;
color: #999999;
text-align: center;
}
.tab-line{ .tab-line{
position: absolute; position: absolute;
bottom: 0; bottom: 0;