分页add

This commit is contained in:
2022-12-08 16:22:27 +08:00
parent 404d5ad4aa
commit 7a2e3904cd
3 changed files with 50 additions and 7 deletions

View File

@@ -54,6 +54,7 @@
</table>
</view>
</view>
<uni-load-more color="#007AFF" iconType="circle" :status="status" :icon-size="14" :content-text="contentText" v-if="dataList.length > 0"/>
</view>
<view class="submit-bar">
<button class="submit-button" @tap="_queryRawFoil">查询</button>
@@ -76,7 +77,17 @@
val2: '',
options: [],
index: '',
dataList: []
dataList: [],
reload: false,
status: 'more',
contentText: {
contentdown: '查看更多',
contentrefresh: '加载中',
contentnomore: '没有更多'
},
totalCount: 0,
pageNum: 1,
pageSize: 10
};
},
created () {
@@ -96,10 +107,38 @@
let res = await queryProductArea()
this.options = [...res.data]
},
// /** 初始化查询 */
// async _queryRawFoil () {
// let res = await queryRawFoil(this.val1, this.val2, this.index)
// this.dataList = [...res.data]
// }
/** 初始化查询 */
async _queryRawFoil () {
let res = await queryRawFoil(this.val1, this.val2, this.index)
this.dataList = [...res.data]
let res = await queryRawFoil(this.val1, this.val2, this.index, this.pageNum + '', this.pageSize + '')
this.totalCount = res.size
if (res.size > 0) {
const dataMap = res.data
this.dataList = this.reload ? dataMap : this.dataList.concat(dataMap)
this.reload = false
} else {
this.dataList = []
}
if (this.totalCount == this.dataList.length) {
this.reload = false
this.status = 'noMore'
}
},
onReachBottom () {
if (this.totalCount > this.dataList.length) {
this.status = 'loading'
setTimeout(() => {
this.pageNum++
this._queryRawFoil()
}, 1000)
} else { //停止加载
this.status = 'noMore'
}
}
}
}