| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- var app = new Vue({
- 'el': '#app',
- 'data': {
- // 列表数据
- dataList: [],
- // 参数
- params: {
- page: 1,
- status: 0,
- pageSize: 10,
- },
- loading: false,
- loaded: false,
- submitting: 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/getPrintOrderList', _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");
- },
- // 获取列表数据
- rePrint: function(id){
- var _this = this;
- if(_this.submitting){
- return false;
- }
- if(id<=0 || id == ''){
- $.showLoading("订单参数错误...");
- _this.getDataList(0);
- return false;
- }
- $.showLoading("打印中,请耐心等候...");
- $.post('/weixin/print/rePrint', {id: id}, function (res) {
- $.hideLoading();
- if (res.code == 'success') {
- $.toast('已成功发起打印,请留意设备口');
- }else if(res.code == 'login'){
- login(res.data.url);
- }else{
- $.toast(res.message);
- _this.getDataList(0);
- }
- }, "json");
- }
- }
- })
|