1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| <script src="/js/4.2.5iscroll.js"></script>
<div class="wrap" id="#wrapper"> <div class="main_list"> <div class="other_list"> //循环开始 <ul>....</ul> <ul>....</ul> ... //循环结束 </div> <div class="more" abc=""> <div class="more_center"> <i class="pull_icon"></i><span>上拉加载...</span> </div> </div> </div> </div>
<script> var kp = '{{ $datas['skip'] }}'; $(".more").attr("abc",kp); var myscroll = new iScroll("#wrapper",{ onScrollMove:function(){ if (this.y<(this.maxScrollY)) { $('.pull_icon').addClass('flip'); $('.pull_icon').removeClass('loading'); $('.more span').text('释放加载...'); }else{ $('.pull_icon').removeClass('flip loading'); $('.more span').text('上拉加载...') } }, onScrollEnd:function(){ if ($('.pull_icon').hasClass('flip')) { $('.pull_icon').addClass('loading'); $('.more span').text('加载中...'); pullUpAction(); }
}, onRefresh:function(){ $('.more').removeClass('flip'); $('.more span').text('上拉加载...'); } }); function pullUpAction(){ var skip=$(".more").attr("abc"); $.ajax({ url: '', type: 'post', headers: {'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')}, data: { skip: skip }, dataType: 'json', success: function (data) { if(data.success){ $(".more").attr("abc",data.info.skip); var obj = Object.keys(data.info.products) if(obj.length > 0){ var arr=data.info.products; var path = '{{ env('CDN_DOMAIN_NAME') }}'; var html="<ul>....</ul>" $('.other_list').append(html) }else{ $(".more_center").empty(); $(".more_center").text("我是有底线的"); } myscroll.refresh(); }else{
} } }); } if ($('.main_list').height()<$('.wrap').height()) { $('.more').hide(); myscroll.destroy(); } </script>
|