mui中slider的上拉刷新下拉加载

var flag1 = false;
var flag2 = false;

var page1 = 1;
var page2 = 1;

 

$$.ready(function() {
//循环初始化所有下拉刷新,上拉加载。
$$.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {
//console.log(index)
$$(pullRefreshEl).pullToRefresh({
down: {
callback: function() {
var self = this;
if (index == 0) {
setTimeout(function() {
GetNoCompletEnterprise(1, 0);
self.endPullDownToRefresh(flag1);
self.refresh(true);
}, 500);
} else if (index == 1) {
setTimeout(function() {
GetCompletEnterprise(1, 0);
self.endPullDownToRefresh(flag2);
self.refresh(true);
}, 500);
}
}
},
up: {
auto: true,
contentnomore: '没有更多数据了',
callback: function() {
var self = this;
if (index == 0) {
setTimeout(function() {
GetNoCompletEnterprise(page1, 1);
self.endPullUpToRefresh(flag1);
}, 500);
} else if (index == 1) {
setTimeout(function() {
GetCompletEnterprise(page2, 1);
self.endPullUpToRefresh(flag2);
}, 500);
}
}

}
});
});

});

 

 

 

function GetCompletEnterprise(thepage, init) {
$.ajax({
type: "get",
contentType: "application/json;charset=utf-8",
url: ServerIp + '/api/rectify/rectificationEnterList',
data: {
page: thepage,
unit: localStorage.getItem('unitId'),
state: 1,
enterprise: $('#search').val()
},
dataType: "json",
success: function(data) {
if (data != null && data != undefined) {
flag2 = data.length == 0 || data.length < 10;
if (flag2 == false) {
page2++;
}
mui('#item2mobile .mui-scroll').pullToRefresh().endPullUpToRefresh(flag2);
Bind_data(thepage, '#item2mobile .mui-scroll', data, init);
}
},
error: function(result, status) {

}
});
}

posted @ 2019-09-27 17:18  艺洁  阅读(445)  评论(0编辑  收藏  举报