店铺列表和店铺详情分页功能添加

This commit is contained in:
2022-06-11 15:18:39 +08:00
parent 1f2a85c2d7
commit e82b7d74ce
13 changed files with 877 additions and 809 deletions

View File

@@ -28,7 +28,7 @@
</scroll-view>
</view>
<view class="right">
<scroll-view scroll-y="true" class="scroll-view-right">
<scroll-view scroll-y="true" class="scroll-view-right" @scrolltolower='lower'>
<block v-if="goods.length > 0">
<view class="goods-item" v-for="(item,index) in goods" :key="index"
@click="onGoods(item.goods_id)">
@@ -39,7 +39,7 @@
<view class="price">{{item.price.price_min || '0'}}
<view class="price-type">
<text> DT积分</text>
<text class="kucun"> 库存量:1222</text>
<text class="kucun"> 库存量:{{item.stock}}</text>
</view>
</view>
</view>
@@ -70,12 +70,14 @@
category_id : '',
classify : [],
goods : [],
pages : {}
has_more:true,
page:1,
}
},
onLoad(e) {
this.ShopId = this.$Route.query.ShopId
shopsDetail(this.ShopId).then(res => {
shopsDetail(this.ShopId).then(res => {
console.log(res);
this.classify = [{
category_id: '',
name: '全部商品',
@@ -89,15 +91,20 @@
icon: 'none'
})
})
},
},
onPullDownRefresh() {
this.has_more = true;
this.page = 1;
this.getGoods()
},
methods: {
getGoods() {
uni.showLoading({
title: '加载中...'
})
shopsGoods(this.ShopId, this.category_id).then(res => {
this.goods = res.data
this.pages = res.page
shopsGoods(this.ShopId, this.category_id,this.page).then(res => {
this.goods = this.goods.concat(res.data);
this.has_more = res.page.has_more;
uni.hideLoading()
}).catch(err => {
uni.showToast({
@@ -105,10 +112,20 @@
icon: 'none'
})
})
},
},
lower(){
if(this.has_more){
this.page = this.page + 1;
this.has_more = true;
this.getGoods()
}
},
selectClassify(id) {
if (id === this.category_id) return;
this.category_id = id;
this.page = 1;
this.goods =[];
this.has_more = true;
this.getGoods()
},
search() {