orderDetail.js 5.9 KB

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