


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() {
        this.refreshList()
	},
	onReachBottom() {
        this.loadMore()
	},
	onLoad() {
        this.refreshList()
	},
	methods: {
		// 刷新列表
		refreshList() {
			this.queryParams.pageNo = 1;
			this.hasMore = true;
			this.List = [];
			this.loadList();
		},
		
		// 加载更多
		loadMore() {
            console.log(this.hasMore , this.loading);
            
			if (!this.hasMore || this.loading) return;
			this.queryParams.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), 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.queryParams.pageSize;
					} else {
						uni.showToast({
							title: res.message || '加载失败',
							icon: 'none'
						});
						error(res)
					}
				})
			})
		},
	}
}