建材商城系统20241014
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.
 
 
 

103 lines
1.9 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 : [],
hasMore: true, // 是否还有更多数据
loading: false, // 是否正在加载
}
},
onPullDownRefresh() {
},
onReachBottom() {
},
onShow() {
},
methods: {
// 刷新列表
refreshList() {
this.pageNo = 1;
this.hasMore = true;
this.orderList = [];
this.loadList();
},
// 加载更多
loadMore() {
if (!this.hasMore || this.loading) return;
this.pageNo++;
this.loadList();
},
// 加载订单列表
loadList() {
return new Promise((success, error) => {
if(!this.mixinsListApi){
return console.error('mixinsListApi 缺失');
}
if (this.loading) return;
this.loading = true;
const params = {
...this.queryParams,
};
this.$api(this.mixinsListApi, query(this, params))
.then(res => {
this.loading = false;
uni.stopPullDownRefresh();
if (res.code === 200 && res.result) {
this.getDataThen && this.getDataThen(res.result.records, res.result.total, res.result)
success(res.result)
const newList = res.result.records || [];
this.total = res.result.total
if (this.pageNo === 1) {
this.List = newList;
} else {
this.List = [...this.List, ...newList];
}
// 判断是否还有更多数据
this.hasMore = newList.length >= this.pageSize;
} else {
uni.showToast({
title: res.message || '加载失败',
icon: 'none'
});
error(res)
}
})
})
},
}
}