orderDetail.js 4.1 KB

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