var app = new Vue({ 'el': '#app', 'data': { // 列表数据 dataList: [], // 参数 params: { page: 1, status: 0, pageSize: 10, }, loading: false, loaded: false, }, created: function(){ this.getDataList(0); }, mounted: function(){ var _this = this; $(".weui-navbar__item").click(function(){ _this.params.page = 1; _this.loaded = false; _this.params.status = $(this).index(); $(this).addClass('on').siblings().removeClass('on'); _this.dataList = []; _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/order/getList', _this.params, function (res) { _this.loading = false; $.hideLoading(); if (res.code == 'success') { if(res.data.length<=0 && _this.params.page > 1){ _this.loaded = true; $.toast("已加载完全部...",'text'); return false; } if(more){ $.each(res.data, function(k,item){ console.log(item); _this.dataList.push(item); }); }else{ _this.dataList = res.data } }else if(res.code == 'login'){ login(res.data.url); } }, "json"); }, // 商品详情 showGoods:function(id){ if(id>0){ location.href = '/weixin/goods/detail?id='+id; } }, // 确认收货 delivery: function(data){ var _this = this; $.modal({ title: "确认收货", text: "发货信息:"+(data.confirm_remark? data.confirm_remark : '无'), buttons: [ { text: "取消", onClick: function(){ return false; }}, { text: "确认", className: "default", onClick: function(){ $.showLoading("提交处理中..."); $.post('/weixin/order/delivery', {id: data.id}, function (res) { $.hideLoading(); console.log(res); if (res.code == 'success') { $.toast(res.message, 'text'); setTimeout(function(){ _this.getDataList(0); }, 500) }else if(res.code == 'login'){ login(res.data.url); }else { $.toast(res.message, 'text'); } },"json"); return false; } }, ] }); }, } })