mui.init({
	pullRefresh: {
		container: '#pullrefresh',
		down: {},
		up: {
			contentrefresh: '正在加载...',
			callback: pullupRefresh
		}
	}
});
var pageNumber = 0,
	pagesize = 10;

function pullupRefresh() {
	var btnArray = ['否', '是'];
	$.ajax(base_path + '/WithDrawalsLogs/historyWithdrawNext?dates=' + new Date().getTime(), {
		data: {
			"openid": "",
			"page": {
				"pageSize": pagesize,
				"pageNumber": pageNumber
			}
		},
		dataType: 'json',
		type: 'post',
		timeout: 15000,
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		success: function(dt) {
			if(dt.isRedirect) {
				location.href = dt.redirectURL;
			} else {
				if(dt.status) {
					var fenxiao_list = [];
					fenxiao_list = dt.data.list;
					$("#amount").html("¥" + accDiv(dt.data.amount, 100));
					mui('#pullrefresh').pullRefresh().endPullupToRefresh(fenxiao_list.length < pagesize);
					var table = document.body.querySelector('.my-tab-view-pull');
					mui(fenxiao_list).each(function(index) {
						var li = document.createElement('li');
						li.className = 'mui-table-view-cell';
						this.name == null ? this.name = "神仙哥哥" : this.name;
						var status = this.status;
						switch(status) {
							case 1:
								status = "申请中";
								break;
							case 2:
								status = "申请成功";
								break;
							default:
								status = "申请失败"
						};
						li.innerHTML = '<a><div class="mui-media-body">提现:<span class="cl-red">¥' + accDiv(this.withDrawalsNum, 100) + '</span><span class="mui-btn-link">' + status + '</span><span class="mui-badge mui-badge-inverted mui-pull-right">' + this.createDate + '</span><p class="mui-ellipsis">' + this.withDrawalsName + ':' + this.accountNo + '<span class="mui-badge mui-badge-inverted mui-pull-right">' + this.bankLocal + '</span></p></div></a>';
						table.appendChild(li)
					})
				} else {
					mui.confirm(dt.message, '爱贝源-提示', btnArray, function(e) {
						if(e.index == 1) {
							location.reload(true)
						}
					})
				}
			}
		},
		error: function(xhr, type, errorThrown) {
			console.log(xhr)
		}
	});
};

function getMoney() {
	window.location.href = base_path + "/drp/withdrawalsPage?openid="
};
mui.ready(function() {
	mui('#pullrefresh').pullRefresh().pullupLoading();
	getCartNum();
	document.querySelector('.loading-bg').style.display = 'none'
});