mui.init({
	pullRefresh: {
		container: '#pullrefresh',
		down: {
			//						callback: pulldownRefresh
		},
		up: {
			contentrefresh: '正在加载...',
			callback: pullupRefresh
		}
	}
});
/**
 * 下拉刷新具体业务实现
 */
//			function pulldownRefresh() {
//				setTimeout(function() {
//					var table = document.body.querySelector('.mui-table-view');
//					var cells = document.body.querySelectorAll('.mui-table-view-cell');
//					for (var i = cells.length, len = i + 3; i < len; i++) {
//						var li = document.createElement('li');
//						li.className = 'mui-table-view-cell';
//						li.innerHTML = '<a class="mui-navigate-right">Item ' + (i + 1) + '</a>';
//						//下拉刷新，新纪录插到最前面；
//						table.insertBefore(li, table.firstChild);
//					}
//					mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
//				}, 1500);
//			}
var pageNumber = 0,
	pagesize = 10;
/**
 * 上拉加载具体业务实现
 */
function pullupRefresh() {
	++pageNumber;
	mui.ajax(base_path + '/withdraw/selectUserLogs', {
		data: {
			"pageSize": pagesize,
			"pageNo": pageNumber
		},
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 15000, //超时时间设置为15秒；
		success: function(dt) {
			//服务器返回响应
			//console.log(dt);
			if (dt.status) {
				var log_list = [];
				log_list = dt.data;
				mui('#pullrefresh').pullRefresh().endPullupToRefresh((log_list.length < pagesize)); //参数为true代表没有更多数据了。
				var table = document.body.querySelector('.my-tab-view-pull');
				var fenxiaostr = "";
				mui(log_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.withdrawalsStatus;
					switch (status) {
						case 1:
							status = "提现成功";
							break;
						case 2:
							status = "提现申请中";
							break;
						default:
							status = "提现失败";
					};
					var num = accDiv(this.withdrawalsLogsAmount,100);
					li.innerHTML = '<span>提现：<span class="cl-red">¥ -' + num + '</span></span><span class="mui-btn-link">' + status + '</span><font class="mui-badge mui-badge-inverted">' + this.withdrawalsLogsDate + '</font>';
					table.appendChild(li);
				});
			} else {
				var btnArray = ['否', '是'];
				mui.confirm(dt.message + '是否刷新页面？', '爱贝源-提示', btnArray, function(e) {
					if (e.index == 1) {
						location.reload(true);
					}
				});
			}
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			errorfn(xhr);
		}
	});
}
mui.ready(function() {
	document.querySelector('.loading-bg').style.display = 'none';
	mui('#pullrefresh').pullRefresh().pullupLoading();
});