order.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data: {
  5. order_status: '',
  6. evaluate_status: '',
  7. orderList: [],
  8. page: 1,
  9. size: 10,
  10. totalPages:0,
  11. tabList: ['全部', '待付款', '待发货', '待收货', '待评价'],
  12. tabIndex: 0,
  13. orderIds:[],
  14. currentStoreId: ''
  15. // markers: [{
  16. // iconPath: "/static/images/rider.png",
  17. // id: 0,
  18. // latitude: 31.834082,
  19. // longitude: 117.232939,
  20. // width: 40,
  21. // height: 40,
  22. // callout: {
  23. // content: '距离你2.77km',
  24. // color: '#fe7200',
  25. // display: 'ALWAYS',
  26. // padding: 10,
  27. // borderRadius: 30
  28. // }
  29. // }]
  30. },
  31. toggleTab(e) {
  32. this.setData({
  33. tabIndex: e.currentTarget.dataset.index,
  34. orderList: [],
  35. page: 1,
  36. });
  37. this.switchOrderType(e.currentTarget.dataset.index);
  38. },
  39. swiperChange(e) {
  40. this.setData({
  41. tabIndex: e.detail.current
  42. });
  43. this.switchOrderType(e.detail.current);
  44. },
  45. onLoad: function (options) {
  46. // 页面初始化 options为页面跳转所带来的参数
  47. if (options.tabIndex) {
  48. this.setData({
  49. tabIndex: options.tabIndex
  50. });
  51. }
  52. },
  53. getOrderList() {
  54. let that = this;
  55. wx.showLoading({
  56. title: '加载中...',
  57. });
  58. util.request(api.OrderList,
  59. {
  60. order_status: that.data.order_status,
  61. evaluate_status: that.data.evaluate_status,
  62. page: that.data.page,
  63. size: that.data.size
  64. }).then(function (res) {
  65. if (res.errno === 0) {
  66. let orderList = that.data.orderList.concat(res.data.data);
  67. // console.log(orderList);
  68. that.setData({
  69. orderList: orderList,
  70. totalPages: res.data.totalPages
  71. }, () => {
  72. //获取待付款倒计时
  73. that.data.orderList.forEach((item, num) => {
  74. if (item.pay_status == 0 || item.pay_status == 1) {
  75. util.countdown(that, that.data.orderList, 'orderList', num)
  76. }
  77. })
  78. });
  79. wx.hideLoading();
  80. }
  81. });
  82. },
  83. payOrder(event) {
  84. wx.redirectTo({
  85. url: '/pages/pay/pay?orderIds=' + event.target.dataset.orderId
  86. + '&actualPrice=' + event.target.dataset.actualPrice
  87. })
  88. },
  89. againBuy(event) {
  90. let orderId = event.target.dataset.orderId;
  91. // let goodType = event.target.dataset.goodType;
  92. // if (goodType!= '00'){
  93. // wx.showModal({
  94. // title: '提示信息',
  95. // content: '非保税仓商品不允许再来一单,需门店扫描二维码进行购买',
  96. // showCancel: false
  97. // });
  98. // return;
  99. // }
  100. util.request(api.CartAddByOrder, {orderId: orderId}).then(function (res) {
  101. if (res.errno === 0) {
  102. wx.switchTab({
  103. url: '/pages/cart/cart',
  104. });
  105. } else if (res.errno === 0) {
  106. wx.showToast({
  107. title: res.errmsg,
  108. image: '/static/images/icon_error.png',
  109. duration: 2000
  110. });
  111. }
  112. });
  113. },
  114. againBuyDisabel(event) {
  115. let goodType = event.target.dataset.goodType;
  116. let isStore = event.target.dataset.isStore;
  117. if (goodType != '00' && isStore) {
  118. wx.showModal({
  119. title: '提示信息',
  120. content: '非保税仓商品不允许再来一单,需门店扫描二维码进行购买',
  121. showCancel: false
  122. });
  123. }
  124. if (!isStore){
  125. wx.showModal({
  126. title: '',
  127. content: '该订单非当前门店订单,不允许再来一单,需切换门店进行购买',
  128. showCancel: false
  129. });
  130. }
  131. },
  132. switchOrderType(tabIndex) {
  133. let that = this;
  134. if (tabIndex == 0) {
  135. that.setData({
  136. order_status: '',
  137. evaluate_status: '',
  138. });
  139. } else if (tabIndex == 1) {
  140. that.setData({
  141. order_status: 0,
  142. evaluate_status: '',
  143. });
  144. } else if (tabIndex == 2) {
  145. that.setData({
  146. order_status: 201,
  147. evaluate_status: '',
  148. });
  149. } else if (tabIndex == 3) {
  150. that.setData({
  151. order_status: 300,
  152. evaluate_status: 0,
  153. });
  154. } else if (tabIndex == 4) {
  155. that.setData({
  156. order_status: 301,
  157. evaluate_status: 0,
  158. });
  159. }
  160. that.getOrderList();
  161. },
  162. onReady: function () {
  163. // 页面渲染完成
  164. },
  165. onShow: function () {
  166. // 页面显示
  167. let that = this;
  168. that.switchOrderType(that.data.tabIndex);
  169. that.setData({
  170. currentStoreId: wx.getStorageSync('storeId')
  171. });
  172. },
  173. onHide: function () {
  174. // 页面隐藏
  175. },
  176. onUnload: function () {
  177. // 页面关闭
  178. },
  179. onReachBottom() {
  180. var that = this;
  181. if (that.data.page <= that.data.totalPages) {
  182. that.setData({
  183. page: that.data.page + 1,
  184. });
  185. that.getOrderList();
  186. }
  187. },
  188. getWuliuList(event) {
  189. let shippingNo = event.target.dataset.shippingNo;
  190. let shippingCode = event.target.dataset.shippingCode;
  191. let orderId = event.target.dataset.orderId;
  192. wx.navigateTo({
  193. url: '/pages/ucenter/wuliu/wuliu?id=' + shippingNo + '&code=' + shippingCode + '&orderId=' + orderId,
  194. });
  195. }
  196. })