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 endNO = 0,
	pageSize = 10;
/**
 * 上拉加载具体业务实现
 */
function pullupRefresh() {
/* 	++pageNumber; */
	var btnArray = ['否', '是'];
	$.ajax(base_path + '/member/porxyCheckUser', {
		data: {
			"endNO": endNO,
			"pageSize": pageSize
		},
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 15000, //超时时间设置为15秒；
		success: function(dt) {
			//服务器返回响应
			//console.log(dt);
			if (dt.status) {
				var xiaxian_list = [];
				endNO=dt.data.endNO;
				xiaxian_list = dt.data.list;
				document.querySelector('.buyedNum').innerHTML=dt.data.buyedNum;
				document.querySelector('.downNum').innerHTML=dt.data.downNum;
				mui('#pullrefresh').pullRefresh().endPullupToRefresh(xiaxian_list.length < pageSize); //参数为true代表没有更多数据了
				var table = document.body.querySelector('.my-tab-view-pull');
				var cells = document.body.querySelectorAll('.my-tab-view-pull .mui-table-view-cell');
				mui(xiaxian_list).each(function(index) {
					var li = document.createElement('li');
					li.className = 'mui-table-view-cell';
					var userHead = '/iamberry/common/shop/images/logo_head.png';
					if(this.userHead != null  && typeof(this.userHead)!="undefined" && this.userHead != ''){
						userHead =  this.userHead;
					}
					var userNickname = '爱贝源';
					if(this.userNickname != null  && typeof(this.userNickname)!="undefined" && this.userNickname != ''){
						userNickname = decodeURI(this.userNickname);
					}
					var userAddr = '';
					if(this.userAddr != null  && typeof(this.userAddr)!="undefined" && this.userAddr != ''){
						userAddr = this.userAddr;
					}
					li.innerHTML = '<a><img class="mui-media-object mui-pull-left" src="' + userHead + '"><div class="mui-media-body">' + userNickname + '<p class="mui-ellipsis">' + userAddr + '</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) {
			//异常处理；
			errorfn(xhr);
		}
	});
}
mui.ready(function() {
	document.querySelector('.loading-bg').style.display = 'none';
	mui('#pullrefresh').pullRefresh().pullupLoading();
});