loadcontent() 方法是获取初始化数据的,但是如果初始化没有数据,选项卡会一直提示 “正在加载中...”如图
window.onload = function(){
vm = new Vue({
el : 'body',
data :{
}
});
loadcontent();
};
function loadcontent(){
var userid = localStorage.getItem("userid");
var params = {
userid : userid
}
$.ajax({
type:"post",
url:ipAddr,
data : {
params : params
},
success : function(data){
if(data.code == 1){
//如果是第一页,页面滚动至顶部
var nT = mui('.mui-slider').slider().slideNumber;
++nT;
mui('.mui-scroll-wrapper').scroll()[nT].scrollTo(0,0,100);
vm.distributedList = data.distributedList.list;//待分配
// vm.proceSize = data.proceSize;
vm.followList = data.followList.list;//跟进中
vm.follSize = data.follSize;
processedNum = data.distributedList.pageNumber;
followNum = data.followList.pageNumber;
processedPage = data.distributedList.totalPage;
followPage = data.followList.totalPage;
mui.plusReady(function(){
//关闭等待框
plus.nativeUI.closeWaiting();
//显示当前页面
mui.currentWebview.show();
});
}else{
mui.alert(data.msg);
}
}
});
}
//阻尼系数
var deceleration = mui.os.ios?0.003:0.0009;
$('.mui-scroll-wrapper').scroll({
bounce: false,
indicators: true, //是否显示滚动条
deceleration:deceleration
});
//循环初始化所有下拉刷新,上拉加载。
$.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {
$(pullRefreshEl).pullToRefresh({
down: {
callback: function() {
var self = this;
var href = jQuery("#sliderSegmentedControl").find(".mui-active").attr("href");
loadcontent();
self.endPullDownToRefresh();
}
},
up: {
contentdown: '没有更多数据',
callback: function() {
var self = this;
setTimeout(function (){
href = jQuery("#sliderSegmentedControl").find(".mui-active").attr("href");
var pageNumber;
if(href=="#item1mobile" ){
processedNum++;
pageNumber=processedNum;
if(pageNumber>processedPage){
processedNum--;
self.endPullUpToRefresh();
return
}
}else if(href=="#item2mobile"){
followNum++;
pageNumber=followNum;
if(pageNumber>followPage){
followNum--;
self.endPullUpToRefresh();
return
}
}
$.ajax({
type : "post",
url : ipAddr,
data:{
params:params
},
success: function(data){
if(data.code==1){
if(href=="#item1mobile"){
if(pageNumber==1){//首页替换原数据,否则,在原数组追加数据
vm.distributedList = data.customersList.list;//待处理
}else{
vm.distributedList = vm.distributedList.concat(data.customersList.list);
}
processedNum = data.customersList.pageNumber;
processedPage = data.customersList.totalPage;
}else if(href=="#item2mobile"){
if(pageNumber==1){//首页替换原数据,否则,在原数组追加数据
vm.followList = data.customersList.list;//跟进中
}else{
vm.followList = vm.followList.concat( data.customersList.list);
}
followNum = data.customersList.pageNumber;
followPage = data.customersList.totalPage;
}
self.endPullUpToRefresh();
}
}
});
},500)
}
}
});
});