上拉加载 angular

var obj = {page:1};//默认获取商品列表时传入参数,为第一页

var flag = true;

 

function order_list(options){

  var requestParams = {

  userId:sessionStorage.getItem("userId"),

  rowSize : 10,

  page : options.page,

};

  var params = {

  url: configHttp+'order/list.do',

  method: 1,

  requestParams: requestParams,

  isShowLoading: false

};

sx.startRequest({

  params: params,

  success: function(res) {

  if(res && res.result_code == 1) {

  $scope.instances= res.object.instances;

  if($scope.instances.length == 0){

    $(".loading").html("暂无更多结果");

  }else if($scope.instances.length <10){

    $(".loading").html("暂无更多结果");

    for(var i in $scope.instances){

    $scope.data.push($scope.instances[i]);

  };

  }else{

    for(var i in $scope.instances){

    $scope.data.push($scope.instances[i]);

  };

  obj.page = obj.page+1;

  flag = true;

  $(".loading").html("加载更多");

}

  $scope.$apply();

}else{

  sixin.toast({message: "商品获取失败", type:"0"});

};

}

})

}

 

 

//控制回到顶部按钮的显隐及加载更多

$(window).on("scroll",function(){

  var windowBottom =$(window).scrollTop();

  var eleBottom = $(".orderList").offset().top+$(".orderList").height();

  remaining = windowBottom + $(window).height() + 50 - eleBottom;

  var shouldScroll = remaining>0?true:false;

  if(shouldScroll && flag){

    flag = false;

    order_list(obj);

  };

});

posted on 2016-11-08 09:48  124331  阅读(369)  评论(0编辑  收藏  举报

导航