1
0

orderDetail.js 4.4 KB

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