orderDetail.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data: {
  5. excludeAxb:'',//订单不包含安心包,才可以退款
  6. orderId: 0,
  7. orderInfo: {},
  8. orderGoods: [],
  9. expressInfo: {},
  10. flag: false,
  11. handleOption: {}
  12. },
  13. onLoad: function(options) {
  14. // 页面初始化 options为页面跳转所带来的参数
  15. this.setData({
  16. orderId: options.id
  17. });
  18. this.getOrderDetail();
  19. },
  20. onPullDownRefresh() {
  21. wx.showNavigationBarLoading() //在标题栏中显示加载
  22. this.getOrderDetail();
  23. wx.hideNavigationBarLoading() //完成停止加载
  24. wx.stopPullDownRefresh() //停止下拉刷新
  25. },
  26. expandDetail: function() {
  27. let that = this;
  28. this.setData({
  29. flag: !that.data.flag
  30. })
  31. },
  32. getOrderDetail: function() {
  33. wx.showLoading({
  34. title: '加载中',
  35. });
  36. setTimeout(function() {
  37. wx.hideLoading()
  38. }, 2000);
  39. let that = this;
  40. util.request(api.OrderDetail, {
  41. orderId: that.data.orderId
  42. }).then(function(res) {
  43. if (res.errno === 0) {
  44. console.log(res.data);
  45. that.setData({
  46. orderInfo: res.data.orderInfo,
  47. orderGoods: res.data.orderGoods,
  48. handleOption: res.data.orderInfo.handleOption,
  49. expressInfo: res.data.expressInfo
  50. });
  51. }
  52. let excludeAxb=(res.data.orderGoods).every((item)=>{return item.goodsSn!='1036016'});
  53. that.setData({
  54. excludeAxb:excludeAxb
  55. })
  56. wx.hideLoading();
  57. });
  58. },
  59. // “去付款”按钮点击效果
  60. payOrder: function() {
  61. let that = this;
  62. util.request(api.OrderPrepay, {
  63. orderId: that.data.orderId
  64. }, 'POST').then(function(res) {
  65. if (res.errno === 0) {
  66. const payParam = res.data;
  67. console.log("支付过程开始");
  68. wx.requestPayment({
  69. 'timeStamp': payParam.timeStamp,
  70. 'nonceStr': payParam.nonceStr,
  71. 'package': payParam.packageValue,
  72. 'signType': payParam.signType,
  73. 'paySign': payParam.paySign,
  74. 'success': function(res) {
  75. console.log("支付过程成功");
  76. util.redirect('/pages/ucenter/order/order');
  77. },
  78. 'fail': function(res) {
  79. console.log("支付过程失败");
  80. util.showErrorToast('支付失败');
  81. },
  82. 'complete': function(res) {
  83. console.log("支付过程结束")
  84. }
  85. });
  86. }
  87. });
  88. },
  89. // “取消订单”点击效果
  90. cancelOrder: function() {
  91. let that = this;
  92. let orderInfo = that.data.orderInfo;
  93. wx.showModal({
  94. title: '',
  95. content: '确定要取消此订单?',
  96. success: function(res) {
  97. if (res.confirm) {
  98. util.request(api.OrderCancel, {
  99. orderId: orderInfo.id
  100. }, 'POST').then(function(res) {
  101. if (res.errno === 0) {
  102. wx.showToast({
  103. title: '取消订单成功'
  104. });
  105. util.redirect('/pages/ucenter/order/order');
  106. } else {
  107. util.showErrorToast(res.errmsg);
  108. }
  109. });
  110. }
  111. }
  112. });
  113. },
  114. // “取消订单并退款”点击效果
  115. refundOrder: function() {
  116. let that = this;
  117. let orderInfo = that.data.orderInfo;
  118. wx.showModal({
  119. title: '',
  120. content: '确定要取消此订单?',
  121. success: function(res) {
  122. if (res.confirm) {
  123. util.request(api.OrderRefund, {
  124. orderId: orderInfo.id
  125. }, 'POST').then(function(res) {
  126. if (res.errno === 0) {
  127. wx.showToast({
  128. title: '取消订单成功'
  129. });
  130. util.redirect('/pages/ucenter/order/order');
  131. } else {
  132. util.showErrorToast(res.errmsg);
  133. }
  134. });
  135. }
  136. }
  137. });
  138. },
  139. // “删除”点击效果
  140. deleteOrder: function() {
  141. let that = this;
  142. let orderInfo = that.data.orderInfo;
  143. wx.showModal({
  144. title: '',
  145. content: '确定要删除此订单?',
  146. success: function(res) {
  147. if (res.confirm) {
  148. util.request(api.OrderDelete, {
  149. orderId: orderInfo.id
  150. }, 'POST').then(function(res) {
  151. if (res.errno === 0) {
  152. wx.showToast({
  153. title: '删除订单成功'
  154. });
  155. util.redirect('/pages/ucenter/order/order');
  156. } else {
  157. util.showErrorToast(res.errmsg);
  158. }
  159. });
  160. }
  161. }
  162. });
  163. },
  164. // “待上门”点击效果
  165. confirmOrder: function() {
  166. let that = this;
  167. let orderInfo = that.data.orderInfo;
  168. wx.showModal({
  169. title: '',
  170. content: '确认上门服务?',
  171. success: function(res) {
  172. if (res.confirm) {
  173. util.request(api.OrderConfirm, {
  174. orderId: orderInfo.id
  175. }, 'POST').then(function(res) {
  176. if (res.errno === 0) {
  177. wx.showToast({
  178. title: '确认上门成功!'
  179. });
  180. util.redirect('/pages/ucenter/order/order');
  181. } else {
  182. util.showErrorToast(res.errmsg);
  183. }
  184. });
  185. }
  186. }
  187. });
  188. },
  189. // “申请售后”点击效果
  190. aftersaleOrder: function () {
  191. if(this.data.orderInfo.aftersaleStatus === 0){
  192. util.redirect('/pages/ucenter/aftersale/aftersale?id=' + this.data.orderId );
  193. }
  194. else{
  195. util.redirect('/pages/ucenter/aftersaleDetail/aftersaleDetail?id=' + this.data.orderId);
  196. }
  197. },
  198. viewService(){
  199. wx.navigateTo({
  200. url: '../serviceDetail/serviceDetail?orderId=' + this.data.orderId
  201. })
  202. },
  203. onReady: function() {
  204. // 页面渲染完成
  205. },
  206. onShow: function() {
  207. // 页面显示
  208. },
  209. onHide: function() {
  210. // 页面隐藏
  211. },
  212. onUnload: function() {
  213. // 页面关闭
  214. }
  215. })