shop-order.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. type: 1,
  12. },
  13. loading: false,
  14. loaded: false,
  15. submitting: false,
  16. },
  17. created: function(){
  18. this.getDataList(0);
  19. },
  20. mounted: function(){
  21. var _this = this;
  22. $(".weui-navbar__item").click(function(){
  23. _this.params.page = 1;
  24. _this.loaded = false;
  25. _this.params.status = $(this).index();
  26. $(this).addClass('on').siblings().removeClass('on');
  27. _this.dataList = [];
  28. _this.getDataList(0);
  29. });
  30. $(window).scroll(function(){
  31. var scrollHeight = $(this).scrollTop();
  32. var height = $('body')[0].scrollHeight;
  33. var docHeight = $(this).outerHeight();
  34. if(docHeight+scrollHeight >= height){
  35. if(_this.loading || _this.loaded){
  36. return false;
  37. }
  38. _this.params.page++;
  39. _this.getDataList(1);
  40. }
  41. })
  42. },
  43. methods: {
  44. // 获取列表数据
  45. getDataList: function(more){
  46. var _this = this;
  47. _this.loading = true;
  48. if(_this.params.page == 1){
  49. _this.dataList = [];
  50. }
  51. $.showLoading("数据加载中...");
  52. $.post('/weixin/order/getList', _this.params, function (res) {
  53. _this.loading = false;
  54. $.hideLoading();
  55. if (res.code == 'success') {
  56. if(res.data.length<=0 && _this.params.page > 1){
  57. _this.loaded = true;
  58. $.toast("已加载完全部...",'text');
  59. return false;
  60. }
  61. if(more){
  62. $.each(res.data, function(k,item){
  63. console.log(item);
  64. _this.dataList.push(item);
  65. });
  66. }else{
  67. _this.dataList = res.data
  68. }
  69. }else if(res.code == 'login'){
  70. login(res.data.url);
  71. }
  72. }, "json");
  73. },
  74. // 商品详情
  75. showGoods:function(id){
  76. if(id>0){
  77. location.href = '/weixin/goods/detail?id='+id;
  78. }
  79. },
  80. // 确认发货
  81. send: function(id){
  82. var _this = this;
  83. var remark = prompt('确认发货?请填写发货信息');
  84. if(id>0 && remark){
  85. $.showLoading("提交处理中...");
  86. $.post('/weixin/order/send', {id: id, remark: remark}, function (res) {
  87. $.hideLoading();
  88. if (res.code == 'success') {
  89. $.toast(res.message, 'text');
  90. setTimeout(function(){
  91. _this.getDataList(0);
  92. }, 500)
  93. }else if(res.code == 'login'){
  94. login(res.data.url);
  95. }else {
  96. $.toast(res.message, 'text');
  97. }
  98. },"json");
  99. }
  100. },
  101. }
  102. })