| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- var app = new Vue({
- 'el': '#app',
- 'data': {
- // 列表数据
- dataList: [],
- // 参数
- params: {
- page: 1,
- type: 0,
- pageSize: 10,
- lt: 1,
- },
- loading: false,
- loaded: false,
- },
- created: function(){
- this.params.lt = getParam('type');
- this.getDataList(0);
- },
- mounted: function(){
- var _this = this;
- $(".weui-navbar__item").click(function(){
- _this.params.page = 1;
- _this.loaded = false;
- _this.params.type = $(this).index();
- $(this).addClass('on').siblings().removeClass('on');
- _this.getDataList(0);
- });
- $(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/getAccountLogs', _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){
- console.log(item);
- _this.dataList.push(item);
- });
- }else{
- _this.dataList = res.data.data
- }
- }else if(res.code == 'login'){
- login(res.data.url);
- }
- }, "json");
- }
- }
- })
|