数据量过多就会使用分页
第一种:API
onReachBottom: function (){
if (this.pages >this.current) {
this.current++
this.loadOrderData(this.sts,this.current)
}else {
uni.showToast({
title: '暂无更多信息',
icon: 'none'
});
}
},
loadOrderData: function (sts, current) {
var ths = this
uni.showLoading({
title: '加载中'
});
var params = {
url: '/p/myOrder/mySelect',
method: 'GET',
data: {
current: current,
size: this.size,
status: sts,
},
callBack: function (res) {
var temp = []
res.records.forEach((orderItem) => {
orderItem.totalCounts = 0
orderItem.orderItemDtos.forEach((prod) => {
this.prodlist = prod
orderItem.totalCounts += prod.prodCount
})
})
if (res.current == 1) {
temp = res.records
} else {
temp = ths.list
temp = ths.list.concat(res.records)
}
ths.list = temp
ths.pages = res.pages
ths.current = res.current
uni.hideLoading()
console.log( ths.pages )
}
}
http.request(params)
},
第二种:组件形式
<scroll-view class="content"
:style="windowHeight"
scroll-y
:scroll-top=scrollTop
:refresher-enabled="true"
:refresher-threshold="100"
:scroll-with-animation='true'
:refresher-triggered="refresherTriggered"
@scrolltolower="handleScrollToLower">
</scroll-view>
methods: {
handleScrollToLower () {
if (this.size * this.getinfo.current < this.total) {
this.getinfo.current = this.getinfo.current + 1;
this.getinfoList()
} else {
uni.showToast({
title: '没有更多信息啦!',
icon: 'none'
});
}
},
getinfoList () {
uni.showLoading({
title: '加载中'
});
let params = {
url: '/prod/pageProd',
method: 'GET',
data: {
...this.getinfo
},
callBack: (res) => {
if (this.getinfo.current > 1) {
this.shopList = [...this.shopList, ...res.records]
} else {
this.shopList = res.records
this.size = res.size
this.total = res.total
}
uni.hideLoading();
}
}
http.request(params)
},
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)