(function() { Vue.component('yujing-list', { template: '
\
\
\
\
\
\
\ \
下拉刷新
\
\
\
{{yujing.create_time}}
\
地址暂无 {{yujing.sender_name}} {{yujing.value2Name}}\ 异常\
\
{{yujing.address}} {{yujing.sender_name}} {{yujing.value2Name}}\ 异常\
\
\
\
\
加载更多
\
\
\
\
', props: [], data: function() { return { yujingData: [], page: 1, pageSize: 50, myScroll: null, isEnd: false, loadingStep: 0, isRequestEnd:false } }, mounted: function() { var _self = this; var pullDown = $("#pullDown"), pullUp = $("#pullUp"), pullDownLabel = $("#pullDown .pullDownLabel"), pullUpLabel = $("#pullUp .pullUpLabel"); //初始化请求数据 getRequestData(); _self.myScroll = new IScroll("#wrapper", { scrollbars: "custom", mouseWheel: true, interactiveScrollbars: true, shrinkScrollbars: false, fadeScrollbars: false, scrollY: true, probeType: 2, resizeScrollbars: false // bindToWrapper:true }); _self.myScroll.on("scroll", function() { if(this.y > 40) { //下拉刷新操作 $(".pulldown-tips").hide(); pullDown.addClass("refresh").show(); pullDownLabel.text("松手刷新数据"); _self.loadingStep = 1; pullDownAction(_self); } else if(this.y <= this.maxScrollY &&!_self.isEnd) { //上拉加载更多 pullUp.addClass("refresh").show(); pullUpLabel.text("正在载入"); _self.loadingStep = 1; pullUpAction(_self); } }); _self.myScroll.on("scrollEnd", function() { if(_self.loadingStep == 1) { if(pullDown.hasClass("refresh")) { //下拉刷新操作 pullDown.removeClass("refresh").addClass("loading"); pullDownLabel.text("正在刷新"); _self.loadingStep = 2; pullDownAction(_self); } } }); document.addEventListener('touchmove', function(e) { e.preventDefault(); }, false); //下拉刷新 function pullDownAction() { setTimeout(function() { _self.page = 1; pullDown.hide(); getRequestData(); loadingStep = 0; $(".pulldown-tips").show(); _self.myScroll.refresh(); }, 400); } //上拉加载 function pullUpAction() { if(!_self.isEnd) { setTimeout(function() { pullUp.hide(); _self.page++; getRequestData(); _self.myScroll.refresh(); loadingStep = 0; }, 400); } } function getRequestData() { //警报信息 intelligentAPI.warningInformationAlarm({ page: _self.page, pageSize: _self.pageSize }).then(function(res) { if(res.status == 200) { var reqData = res.data; if(_self.page == 1) { _self.yujingData = reqData; } else { var dataArr = _.map(reqData, function(data) { _self.yujingData.push(data); return data; }) } if(reqData.length < _self.pageSize) { _self.isEnd = true; pullUpLabel.text("没有更多数据了..."); }else{ pullUpLabel.text("加载更多"); } setTimeout(function() { _self.myScroll.refresh(); }, 500) _self.isRequestEnd = true; } else { toastr.error(res.msg) } }) } } }); })()