order.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. tabList: ['全部', '待付款', '待收货', '待评价'],
  11. tabIndex: 0,
  12. orderIds:[]
  13. // markers: [{
  14. // iconPath: "/static/images/rider.png",
  15. // id: 0,
  16. // latitude: 31.834082,
  17. // longitude: 117.232939,
  18. // width: 40,
  19. // height: 40,
  20. // callout: {
  21. // content: '距离你2.77km',
  22. // color: '#fe7200',
  23. // display: 'ALWAYS',
  24. // padding: 10,
  25. // borderRadius: 30
  26. // }
  27. // }]
  28. },
  29. toggleTab(e) {
  30. this.setData({
  31. tabIndex: e.currentTarget.dataset.index,
  32. orderList: [],
  33. page: 1,
  34. });
  35. this.switchOrderType(e.currentTarget.dataset.index);
  36. },
  37. swiperChange(e) {
  38. this.setData({
  39. tabIndex: e.detail.current
  40. });
  41. this.switchOrderType(e.detail.current);
  42. },
  43. onLoad: function (options) {
  44. // 页面初始化 options为页面跳转所带来的参数
  45. if (options.tabIndex) {
  46. this.setData({
  47. tabIndex: options.tabIndex
  48. });
  49. }
  50. },
  51. getOrderList() {
  52. let that = this;
  53. util.request(api.OrderList,
  54. {
  55. order_status: that.data.order_status,
  56. evaluate_status: that.data.evaluate_status,
  57. page: that.data.page,
  58. size: that.data.size
  59. }).then(function (res) {
  60. if (res.errno === 0) {
  61. let orderList = res.data.data;
  62. that.setData({
  63. orderList: that.data.orderList.concat(orderList)
  64. });
  65. //获取待付款倒计时
  66. that.data.orderList.forEach((item, num) => {
  67. if (item.pay_status == 0 || item.pay_status == 1) {
  68. util.countdown(that, that.data.orderList, 'orderList', num)
  69. }
  70. })
  71. }
  72. });
  73. },
  74. payOrder(event) {
  75. wx.redirectTo({
  76. url: '/pages/pay/pay?orderIds=' + event.target.dataset.orderId
  77. + '&actualPrice=' + event.target.dataset.actualPrice
  78. })
  79. },
  80. againBuy(event) {
  81. let orderId = event.target.dataset.orderId;
  82. // let goodType = event.target.dataset.goodType;
  83. // if (goodType!= '00'){
  84. // wx.showModal({
  85. // title: '提示信息',
  86. // content: '非保税仓商品不允许再来一单,需门店扫描二维码进行购买',
  87. // showCancel: false
  88. // });
  89. // return;
  90. // }
  91. util.request(api.CartAddByOrder, {orderId: orderId}).then(function (res) {
  92. if (res.errno === 0) {
  93. wx.switchTab({
  94. url: '/pages/cart/cart',
  95. });
  96. } else if (res.errno === 0) {
  97. wx.showToast({
  98. title: res.errmsg,
  99. image: '/static/images/icon_error.png',
  100. duration: 2000
  101. });
  102. }
  103. });
  104. },
  105. switchOrderType(tabIndex) {
  106. let that = this;
  107. if (tabIndex == 0) {
  108. that.setData({
  109. order_status: '',
  110. evaluate_status: '',
  111. });
  112. } else if (tabIndex == 1) {
  113. that.setData({
  114. order_status: 0,
  115. evaluate_status: '',
  116. });
  117. } else if (tabIndex == 2) {
  118. that.setData({
  119. order_status: 300,
  120. evaluate_status: '',
  121. });
  122. } else if (tabIndex == 3) {
  123. that.setData({
  124. order_status: 301,
  125. evaluate_status: 0,
  126. });
  127. }
  128. that.getOrderList();
  129. },
  130. onReady: function () {
  131. // 页面渲染完成
  132. },
  133. onShow: function () {
  134. // 页面显示
  135. let that = this;
  136. that.switchOrderType(that.data.tabIndex);
  137. },
  138. onHide: function () {
  139. // 页面隐藏
  140. },
  141. onUnload: function () {
  142. // 页面关闭
  143. },
  144. onReachBottom() {
  145. var that = this;
  146. that.setData({
  147. page: that.data.page + 1,
  148. });
  149. that.getOrderList();
  150. }
  151. })