var app = new Vue({ 'el': '#app', 'data': { // 列表数据 dataList: [], // 参数 params: { page: 1, pageSize: 10, lt: 1, }, loading: false, loaded: false, }, created: function(){ this.params.lt = getParam('type'); this.getDataList(0); }, mounted: function(){ var _this = this; $(window).scroll(function(){ var scrollHeight = $(this).scrollTop(); var height = $('body')[0].scrollHeight; var docHeight = $(this).outerHeight(); if(docHeight+scrollHeight >= height){ if(_this.loading || _this.loaded){ return false; } _this.params.page++; _this.getDataList(1); } }) }, methods: { // 获取列表数据 getDataList: function(more){ var _this = this; _this.loading = true; if(_this.params.page == 1){ _this.dataList = []; } $.showLoading("数据加载中..."); $.post('/weixin/member/getNotices', _this.params, function (res) { _this.loading = false; $.hideLoading(); if (res.code == 'success') { if(res.data.data.length<=0 && _this.params.page > 1){ _this.loaded = true; $.toast("已加载完全部...",'text'); return false; } if(more){ $.each(res.data.data, function(k,item){ _this.dataList.push(item); }); }else{ _this.dataList = res.data.data } }else if(res.code == 'login'){ login(res.data.url); } }, "json"); } } })