推广小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

77 lines
1.5 KiB

function query(self, queryParams){
// return (self.beforeGetData && self.beforeGetData()) ||
// queryParams || self.queryParams
// 深度合并对象
return self.$utils.deepMergeObject(
self.$utils.deepMergeObject(self.queryParams,
(self.beforeGetData && self.beforeGetData()) || {}),
queryParams)
}
export default {
data() {
return {
queryParams: {
pageNo: 1,
pageSize: 10,
},
total : 0,
list : [],
uvLoadMore : 'loading',
}
},
onPullDownRefresh() {
this.getData()
},
onReachBottom() {
this.loadMoreData()
},
onShow() {
this.getData()
},
methods: {
getData(queryParams){
return new Promise((success, error) => {
if(!this.mixinsListApi){
return console.error('mixinsListApi 缺失');
}
this.$api(this.mixinsListApi,
query(this, queryParams), res => {
uni.stopPullDownRefresh()
if(res.code == 200){
this.getDataThen && this.getDataThen(res.result.records, res.result.total, res.result)
success(res.result)
this[this.mixinsListKey || 'list'] = res.result.records || res.result
this.total = res.result.total || res.result.length
if(this.queryParams.pageSize < this.total){
this.uvLoadMore = 'loadmore'
}else{
this.uvLoadMore = 'nomore'
}
}
})
})
},
loadMoreData(){
console.log('loadMoreData----', this.queryParams.pageSize < this.total);
if(this.queryParams.pageSize < this.total){
this.queryParams.pageSize += 10
this.getData()
}
},
}
}