1
0

orderDetail.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data: {
  5. orderId: 0,
  6. orderInfo: {},
  7. orderGoods: [],
  8. handleOption: {},
  9. wuliu: {},
  10. currentStoreId: '',
  11. tabIndex: 0,
  12. refundInfo: {},
  13. createTime: '',
  14. refundTime:'',
  15. isRefundStatus: ''//true :申请中; false :已退款
  16. },
  17. onLoad: function (options) {
  18. // 页面初始化 options为页面跳转所带来的参数
  19. let that = this;
  20. that.setData({
  21. orderId: options.id,
  22. tabIndex: options.tabIndex,
  23. isRefundStatus: options.isRefundStatus
  24. });
  25. console.log(that.data.isRefundStatus);
  26. },
  27. getOrderDetail() {
  28. let that = this;
  29. util.request(api.OrderDetail, {
  30. orderId: that.data.orderId
  31. }).then(function (res) {
  32. if (res.errno === 0) {
  33. // console.log(res.data);
  34. that.setData({
  35. orderInfo: res.data.orderInfo,
  36. orderGoods: res.data.orderGoods,
  37. handleOption: res.data.handleOption,
  38. wuliu: res.data.wuliu
  39. });
  40. if (that.data.orderInfo.order_status == 401 || that.data.orderInfo.order_status == 402) {
  41. that.setData({
  42. refundInfo: res.data.refundInfo,
  43. createTime: util.tsFormatTime(res.data.refundInfo.createTime, 'Y-M-D h:m:s'),
  44. refundTime: util.tsFormatTime(res.data.refundInfo.refundTime, 'Y-M-D h:m:s')
  45. });
  46. }
  47. if (that.data.orderInfo.order_status == 0) {
  48. wx.setNavigationBarTitle({ title: "待支付" });
  49. }
  50. //待付款倒计时
  51. if (that.data.orderInfo.pay_status == 0||that.data.orderInfo.pay_status == 1){
  52. util.countdown(that, res.data.orderInfo, 'orderInfo', null)
  53. }
  54. }
  55. });
  56. },
  57. payOrder() {
  58. let that = this;
  59. wx.redirectTo({
  60. url: '/pages/pay/pay?orderId=' + that.data.orderId
  61. + '&actualPrice=' + that.data.orderInfo.actual_price
  62. })
  63. },
  64. onReady: function () {
  65. // 页面渲染完成
  66. },
  67. onShow: function () {
  68. // 页面显示
  69. this.getOrderDetail();
  70. this.setData({
  71. currentStoreId: wx.getStorageSync('storeId')
  72. });
  73. },
  74. onHide: function () {
  75. // 页面隐藏
  76. },
  77. onUnload: function () {
  78. // 页面关闭
  79. },
  80. postComment() {
  81. let that = this;
  82. wx.navigateTo({
  83. url: '/pages/commentPost/commentPost?typeId=0'+ '&orderId='+that.data.orderId,
  84. })
  85. },
  86. lookComment() {
  87. let that = this;
  88. wx.navigateTo({
  89. url: '/pages/comment/comment?typeId=0' + '&orderId=' + that.data.orderId,
  90. })
  91. },
  92. cancelOrder() {
  93. let that = this;
  94. util.request(api.OrderCancel, {
  95. orderId: that.data.orderId
  96. }).then(function (res) {
  97. if (res.errno === 0) {
  98. wx.showToast({
  99. title: '取消成功',
  100. duration: 1500,
  101. success: function () {
  102. setTimeout(function () {
  103. wx.navigateBack({
  104. delta: 1
  105. });
  106. },1500);
  107. }
  108. })
  109. }else {
  110. wx.showToast({
  111. title: res.errmsg,
  112. duration: 1500
  113. })
  114. }
  115. });
  116. },
  117. confirmOrder() {
  118. let that = this;
  119. util.request(api.OrderConfirm, {
  120. orderId: that.data.orderId
  121. }).then(function (res) {
  122. if (res.errno === 0) {
  123. wx.showToast({
  124. title: '订单完成',
  125. duration: 2000,
  126. complete: function () {
  127. wx.redirectTo({
  128. url: '/pages/ucenter/order/order',
  129. });
  130. }
  131. })
  132. }
  133. });
  134. },
  135. refund(){
  136. let that = this;
  137. util.request(api.refund, {
  138. orderId: that.data.orderId
  139. }).then(function (res) {
  140. if (res.errno === 0) {
  141. wx.showToast({
  142. title: '成功退款',
  143. duration: 2000,
  144. complete: function () {
  145. wx.redirectTo({
  146. url: '/pages/ucenter/order/order',
  147. });
  148. }
  149. })
  150. }else{
  151. wx.showModal({
  152. title: '',
  153. confirmColor: '#b4282d',
  154. content: res.errmsg,
  155. showCancel:false
  156. })
  157. }
  158. });
  159. }
  160. })