// index.js
let myPro = require("../../../utils/wxRequest.js");
let util = require("../../../utils/util.js");
Page({
    data: {
       page: 1,
	   size: 10,
	   finished: false,
	   dataList: []
    },
    onLoad: function (options) {
        // Do some initialize when page load.
		let that = this;
		that.getDataList();
    },
    onShow: function () {
        // Do something when page show.
		let that = this;
    },
    onReady: function () {
        // Do something when page ready.
    },
    onHide: function () {
        // Do something when page hide.
    },
    onUnload: function () {
        // Do something when page close.
    },
    onPullDownRefresh: function () {
        // Do something when pull down.
		
    },
    onReachBottom: function () {
        // Do something when page reach bottom.
		let that = this;
		if(!that.data.finished){
			that.getDataList();
		}
    },
    onPageScroll: function () {
        // Do something when page scroll
		
    },
    onResize: function () {
        // Do something when page resize
    },
	// 获取充值记录
	getDataList(){
		let that = this;
		let params = {
			page: that.data.page,
			size: that.data.size
		};
		myPro.wxRequest("user/v2/rechargeorderList","GET",params).then(res=>{
			let list = res.result;
			if(list.length == 0){
				// 无数据
				wx.showToast({
					title: "暂无更多数据",
					icon: "none"
				});
				that.setData({
					finished: true
				})
			}else{
				that.setData({
					dataList: that.data.dataList.concat(list),
					page: that.data.page + 1
				})
			}
		}).catch(err=>{
			console.log('报错信息',err);
			wx.showToast({
				title: err,
				icon: "none"
			})
		})
	}
});
