供销新增区域无商品时推荐

This commit is contained in:
weipengfei 2023-10-27 15:23:05 +08:00
parent 3dd0926ae1
commit 1b9a98da38

View File

@ -128,11 +128,21 @@
<image src="@/static/images/f4.png" mode="aspectFit"></image> <image src="@/static/images/f4.png" mode="aspectFit"></image>
</view> </view>
<view class="goodslist"> <view class="goodslist">
<WaterfallsFlow :wfList="productList" :type="1" /> <WaterfallsFlow v-if="productList.length>0" :wfList="productList" :type="1" />
<block v-else>
<view class="no-more">- 此区域没有更多商品了 -</view>
<view class="common-hd">
<view class="title">为你推荐</view>
</view>
<WaterfallsFlow :wfList="productList2" :type="1" />
</block>
</view> </view>
<view class='loadingicon acea-row row-center-wrapper' v-if='productList.length > 0'> <view class='loadingicon acea-row row-center-wrapper' v-if='productList.length > 0'>
<text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}} <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
</view> </view>
<view class='loadingicon acea-row row-center-wrapper' v-else>
<text class='loading iconfont icon-jiazai' :hidden='loading2==false'></text>{{loadTitle2}}
</view>
<view class="empty_wrapper" v-if="emptyShow"> <view class="empty_wrapper" v-if="emptyShow">
<u-empty :show="emptyShow" mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png"></u-empty> <u-empty :show="emptyShow" mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png"></u-empty>
</view> </view>
@ -227,13 +237,19 @@
page: 1, page: 1,
limit: 6 limit: 6
}, },
where2: {
category_id: 0,
page: 1,
limit: 6
},
currentItemId: 69, // 0 || 69 currentItemId: 69, // 0 || 69
keyword: '', keyword: '',
location: '', location: '',
emptyShow: false, emptyShow: false,
town: '', town: '',
productList: [], productList: [], //
productList2: [], //
recoList: [], recoList: [],
articleList: [], articleList: [],
street_id: '', street_id: '',
@ -244,6 +260,9 @@
loadend: false, loadend: false,
loading: false, loading: false,
loadTitle: '加载更多', loadTitle: '加载更多',
loadend2: false,
loading2: false,
loadTitle2: '加载更多',
} }
}, },
onPullDownRefresh() { onPullDownRefresh() {
@ -272,12 +291,18 @@
}, },
onReachBottom() { onReachBottom() {
console.log('ss');
if (this.productList.length > 0) { if (this.productList.length > 0) {
setTimeout(() => { setTimeout(() => {
this.list(false, this.street_id); this.list(false, this.street_id);
this.productList2 = [];
}, 500) }, 500)
} }
else if (this.productList2.length > 0) {
setTimeout(() => {
this.list2(false, '');
}, 500)
}
}, },
beforeDestroy() { beforeDestroy() {
// //
@ -316,8 +341,6 @@
} else if (scrollTop > 100) { } else if (scrollTop > 100) {
this.backColor = 1 this.backColor = 1
this.isFshow = true this.isFshow = true
} }
}, },
// #endif // #endif
@ -330,6 +353,7 @@
}, },
// //
list(isPage, id) { list(isPage, id) {
if(!id) return that.list2(true, ''); // ,
let that = this; let that = this;
if (that.loadend) return; if (that.loadend) return;
if (that.loading) return; if (that.loading) return;
@ -346,6 +370,9 @@
}).then(res => { }).then(res => {
// console.log(222) // console.log(222)
let list = res.data.list; let list = res.data.list;
if(list.length==0){
that.list2(true, '');
}
let productList = that.$util.SplitArray(list, that.productList); let productList = that.$util.SplitArray(list, that.productList);
let loadend = list.length < that.where.limit; let loadend = list.length < that.where.limit;
that.loadend = loadend; that.loadend = loadend;
@ -360,10 +387,39 @@
that.loadTitle = '加载更多'; that.loadTitle = '加载更多';
}); });
}, },
list2(isPage, id) {
let that = this;
if (that.loadend2) return;
if (that.loading2) return;
if (isPage === true) that.$set(that, 'productList2', []);
that.loading2 = true;
that.loadTitle2 = '';
cloudWarehouse({
page: that.where2.page,
limit: that.where2.limit,
street_code: id,
category_id: 0
}).then(res => {
// console.log(222)
let list = res.data.list;
let productList = that.$util.SplitArray(list, that.productList2);
let loadend = list.length < that.where2.limit;
that.loadend2 = loadend;
that.loading2 = false;
that.loadTitle2 = loadend ? '已全部加载' : '加载更多';
that.$set(that, 'productList2', productList);
// console.log(that.productList)
that.$set(that.where2, 'page', that.where2.page + 1);
if (that.where.page2 == 1 && res.data.list.length <= 0) that.emptyShow2 = true
}).catch(err => {
that.loading2 = false;
that.loadTitle2 = '加载更多';
});
},
scrolling() { scrolling() {
// //
let scrollTop = let scrollTop =
@ -417,7 +473,9 @@
this.street_id = e.value[1].code this.street_id = e.value[1].code
this.town = e.value[1].name this.town = e.value[1].name
this.loadend = false; this.loadend = false;
this.loadend2 = false;
this.$set(this.where, 'page', 1) this.$set(this.where, 'page', 1)
this.$set(this.where2, 'page', 1)
this.list(true, this.street_id) this.list(true, this.street_id)
this.$nextTick(() => { this.$nextTick(() => {
this.$bus.$emit('value-updated', e.value[1].name + ',' + e.value[1].code); this.$bus.$emit('value-updated', e.value[1].name + ',' + e.value[1].code);
@ -1014,5 +1072,25 @@
.goodslist { .goodslist {
margin: 0 auto; margin: 0 auto;
width: 725rpx; width: 725rpx;
.no-more{
text-align: center;
padding-top: 18rpx;
}
.common-hd {
display: flex;
align-items: center;
justify-content: center;
height: 118rpx;
.title {
padding: 0 80rpx;
font-size: 34rpx;
color: $theme-color;
font-weight: bold;
background-image: url("~@/static/images/index-title.png");
background-repeat: no-repeat;
background-size: 100% auto;
background-position: left center;
}
}
} }
</style> </style>