orderManage.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. var app = getApp();
  2. Page({
  3. mixins: [require('static/orderMixin.js')],
  4. data: {
  5. placeholdeImg: app.globalData.placeholdeImg,
  6. navList: [{
  7. name: "全部",
  8. status: "-1"
  9. }, {
  10. name: "待发货",
  11. status: "1"
  12. }, {
  13. name: "配送中",
  14. status: "14"
  15. }, {
  16. name: "待收货",
  17. status: "4"
  18. }, {
  19. name: "待付款",
  20. status: "3"
  21. }
  22. ],
  23. currentTab: -1,
  24. list: [],
  25. loadText: "加载中...",
  26. noData: 0,
  27. loadMore: true
  28. },
  29. page: 1,
  30. keyword: '',
  31. onLoad: function (options) {
  32. let currentTab = options.status || -1;
  33. this.setData({
  34. currentTab
  35. })
  36. },
  37. onShow: function () {
  38. this.initFn();
  39. },
  40. initFn: function(keyword=''){
  41. if(typeof keyword !=='string') keyword='';
  42. this.page = 1;
  43. this.keyword = keyword;
  44. this.setData({
  45. list: [],
  46. loadText: "加载中...",
  47. noData: 0,
  48. loadMore: true,
  49. showRaderList: false
  50. },()=>{
  51. this.getData();
  52. })
  53. },
  54. /**
  55. * 切换导航
  56. */
  57. switchNav: function (e) {
  58. let that = this;
  59. if (this.data.currentTab === 1 * e.target.dataset.current) return false;
  60. this.setData({
  61. currentTab: 1 * e.target.dataset.current
  62. }, ()=>{
  63. that.initFn();
  64. });
  65. },
  66. goResult: function(e) {
  67. let keyword = e.detail.value.replace(/\s+/g, '');
  68. // if (!keyword) {
  69. // wx.showToast({
  70. // title: '请输入关键词',
  71. // icon: 'none'
  72. // })
  73. // return;
  74. // }
  75. this.initFn(keyword);
  76. },
  77. getData: function () {
  78. let that = this;
  79. let token = wx.getStorageSync('token');
  80. let order_status = this.data.currentTab;
  81. let keyword = this.keyword;
  82. wx.showLoading();
  83. app.util.request({
  84. url: 'entry/wxapp/index',
  85. data: {
  86. controller: 'order.orderlist',
  87. token,
  88. is_supply: 1,
  89. order_status,
  90. page: this.page,
  91. keyword
  92. },
  93. dataType: 'json',
  94. success: function (res) {
  95. if (res.data.code == 0) {
  96. let h = {};
  97. let list = res.data.data;
  98. if (list.length < 10) h.noMore = true;
  99. let oldList = that.data.list;
  100. list = oldList.concat(list);
  101. that.page++;
  102. that.setData({ list, ...h })
  103. } else if(res.data.code==2) {
  104. app.util.message(res.data.msg, 'switchTo:/lionfish_comshop/pages/user/me', 'error');
  105. } else {
  106. let h = {};
  107. if(that.page==1) h.noData = 1;
  108. h.loadMore = false;
  109. h.noMore = false;
  110. h.loadText = "没有更多记录了~";
  111. that.setData( h )
  112. }
  113. wx.hideLoading();
  114. }
  115. })
  116. },
  117. callPhone: function(e){
  118. var phoneNumber = e.currentTarget.dataset.phone;
  119. phoneNumber && wx.makePhoneCall({
  120. phoneNumber: phoneNumber
  121. });
  122. },
  123. hideExpModal: function(){
  124. this.setData({
  125. showExpModal: false
  126. })
  127. },
  128. /**
  129. * 页面相关事件处理函数--监听用户下拉动作
  130. */
  131. onPullDownRefresh: function () {
  132. },
  133. /**
  134. * 页面上拉触底事件的处理函数
  135. */
  136. onReachBottom: function () {
  137. if (!this.data.loadMore) return false;
  138. this.getData();
  139. }
  140. })