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

function pullupRefresh() {
	endNO ++ ; //为了适应后台的分页
	var btnArray = ['否', '是'];
	$.ajax(base_path + '/drp/select_place_list', {
		data: {
			"pageNO": endNO,
			"pageSize": pageSize
		},
		dataType: 'json',
		type: 'post',
		timeout: 15000,
		success: function(dt) {
			endNO--;  //为了适应后台的分页

			var allCount = dt.data.allCount;
			$("#allCount").html(allCount);

			if(dt.status) {
				mui('#pullrefresh').pullRefresh().endPullupToRefresh((++endNO > 2)); //参数为true代表没有更多数据了。
				var table = document.body.querySelector('.my-tab-view-pull');
				var cells = document.body.querySelectorAll('.mui-table-view-cell');
				mui(dt.data.placeList).each(function (index) {
					var img = "//s.iamberry.com/images/logo_tooth.jpg";
					if(this.userHead != null && this.userHead != ""){
						img = this.userHead;
					}
					var placeName = this.userName;   //商户名称
					var allReback = this.allReback.toFixed(2) / 100;	//总提成
					var li = document.createElement('li');
					li.className = 'mui-table-view-cell';
					li.innerHTML = '<a><input type="hidden" name="placeName" value="'+ placeName +'"><img class="mui-media-object mui-pull-left" src="'+ img +'"><div class="mui-media-body">'+this.userNickname+'<p class="mui-ellipsis">总提成￥'+ allReback +'</p></div></a><span class="center-right">用户数：'+ this.offlineubscriber +'位</span>';
					table.appendChild(li);
				})
			} else {
				mui.confirm(dt.message + '是否刷新页面？', '爱贝源-提示', btnArray, function(e) {
					if(e.index == 1) {}
				})
			}
		},
		error: function(xhr, type, errorThrown) {
			errorfn(xhr)
		}
	})
};
mui.ready(function() {
	mui('#pullrefresh').pullRefresh().pullupLoading();
	getCartNum();
	document.querySelector('.loading-bg').style.display = 'none'
});