print-order.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. var app = new Vue({
  2. 'el': '#app',
  3. 'data': {
  4. // 列表数据
  5. dataList: [],
  6. // 参数
  7. params: {
  8. page: 1,
  9. status: 0,
  10. pageSize: 10,
  11. },
  12. loading: false,
  13. loaded: false,
  14. submitting: false,
  15. },
  16. created: function(){
  17. this.getDataList(0);
  18. },
  19. mounted: function(){
  20. var _this = this;
  21. $(".weui-navbar__item").click(function(){
  22. _this.params.page = 1;
  23. _this.loaded = false;
  24. _this.params.status = $(this).index();
  25. $(this).addClass('on').siblings().removeClass('on');
  26. _this.dataList = [];
  27. _this.getDataList(0);
  28. });
  29. $(window).scroll(function(){
  30. var scrollHeight = $(this).scrollTop();
  31. var height = $('body')[0].scrollHeight;
  32. var docHeight = $(this).outerHeight();
  33. if(docHeight+scrollHeight >= height){
  34. if(_this.loading || _this.loaded){
  35. return false;
  36. }
  37. _this.params.page++;
  38. _this.getDataList(1);
  39. }
  40. })
  41. },
  42. methods: {
  43. // 获取列表数据
  44. getDataList: function(more){
  45. var _this = this;
  46. _this.loading = true;
  47. if(_this.params.page == 1){
  48. _this.dataList = [];
  49. }
  50. $.showLoading("数据加载中...");
  51. $.post('/weixin/order/getPrintOrderList', _this.params, function (res) {
  52. _this.loading = false;
  53. $.hideLoading();
  54. if (res.code == 'success') {
  55. if(res.data.length<=0 && _this.params.page > 1){
  56. _this.loaded = true;
  57. $.toast("已加载完全部...",'text');
  58. return false;
  59. }
  60. if(more){
  61. $.each(res.data, function(k,item){
  62. console.log(item);
  63. _this.dataList.push(item);
  64. });
  65. }else{
  66. _this.dataList = res.data
  67. }
  68. }else if(res.code == 'login'){
  69. login(res.data.url);
  70. }
  71. }, "json");
  72. },
  73. // 获取列表数据
  74. rePrint: function(id){
  75. var _this = this;
  76. if(_this.submitting){
  77. return false;
  78. }
  79. if(id<=0 || id == ''){
  80. $.showLoading("订单参数错误...");
  81. _this.getDataList(0);
  82. return false;
  83. }
  84. $.showLoading("打印中,请耐心等候...");
  85. $.post('/weixin/print/rePrint', {id: id}, function (res) {
  86. $.hideLoading();
  87. if (res.code == 'success') {
  88. $.toast('已成功发起打印,请留意设备口');
  89. }else if(res.code == 'login'){
  90. login(res.data.url);
  91. }else{
  92. $.toast(res.message);
  93. _this.getDataList(0);
  94. }
  95. }, "json");
  96. }
  97. }
  98. })