html:
<scroll-view style="height: 100%"
scroll-y="true"
refresher-enabled
@scrolltolower="lowerRefresh()"
@refresherrefresh="pullRefresh()":refresher-triggered="refresh">
<view class="item" v-for="(item,index) in tableData" :key="item.vehicleId"></view><uni-load-more :status="showMore"></uni-load-more>
</scroll-view>
js:
export default {
data() {
return {showMore:'nomore' //有两个选项 'more' : 'noMore',
refresh:false,//控制刷新的状态
},
methods: {
/**
* 上拉刷新
*/
pullRefresh() {
console.log('在进行上拉操作')
this.refresh = true
this.searchForm.page = 1
this.getTableData()
},/**
* 下拉刷新
*/
lowerRefresh() {
console.log('在进行下拉操作', this.showMore)
if (this.showMore === 'more') {
this.getTableData()
}
},getTableData() {
this.pageLoadingShow = true
if (val === 1) {
this.searchForm.page = 1
this.tableData = []
}
uni.$u.http.post('/spendPay/search', data).then(res => {
this.pageLoadingShow = false
const list = JSON.parse(JSON.stringify(res.list))
this.total = res.total
this.refresh = false
if (this.searchForm.page === 1) {
this.tableData = list
} else {
this.tableData.push(...list)
}
this.showMore = this.total > this.tableData.length ? 'more' : 'noMore'
if (this.showMore === 'more') {
this.searchForm.page++
}
// if (this.companyList.length) {
// this.selCompanyId = this.companyList[0].id
// }
});
},}