orderDetail.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. if(that.data.orderInfo.orderChannel=='102'){
  71. //视频号支付
  72. wx.requestOrderPayment({
  73. 'timeStamp': payParam.timeStamp,
  74. 'nonceStr': payParam.nonceStr,
  75. 'package': payParam.packageValue,
  76. 'signType': payParam.signType,
  77. 'paySign': payParam.paySign,
  78. 'success': function(res) {
  79. console.log("支付过程成功");
  80. util.redirect('/pages/ucenter/order/order');
  81. },
  82. 'fail': function(res) {
  83. console.log("支付过程失败");
  84. util.showErrorToast('支付失败');
  85. },
  86. 'complete': function(res) {
  87. console.log("支付过程结束")
  88. }
  89. });
  90. }else{
  91. wx.requestPayment({
  92. 'timeStamp': payParam.timeStamp,
  93. 'nonceStr': payParam.nonceStr,
  94. 'package': payParam.packageValue,
  95. 'signType': payParam.signType,
  96. 'paySign': payParam.paySign,
  97. 'success': function(res) {
  98. console.log("支付过程成功");
  99. util.redirect('/pages/ucenter/order/order');
  100. },
  101. 'fail': function(res) {
  102. console.log("支付过程失败");
  103. util.showErrorToast('支付失败');
  104. },
  105. 'complete': function(res) {
  106. console.log("支付过程结束")
  107. }
  108. });
  109. }
  110. }
  111. });
  112. },
  113. // “取消订单”点击效果
  114. cancelOrder: function() {
  115. let that = this;
  116. let orderInfo = that.data.orderInfo;
  117. wx.showModal({
  118. title: '',
  119. content: '确定要取消此订单?',
  120. success: function(res) {
  121. if (res.confirm) {
  122. util.request(api.OrderCancel, {
  123. orderId: orderInfo.id
  124. }, 'POST').then(function(res) {
  125. if (res.errno === 0) {
  126. wx.showToast({
  127. title: '取消订单成功'
  128. });
  129. util.redirect('/pages/ucenter/order/order');
  130. } else {
  131. util.showErrorToast(res.errmsg);
  132. }
  133. });
  134. }
  135. }
  136. });
  137. },
  138. // “取消订单并退款”点击效果
  139. refundOrder: function() {
  140. let that = this;
  141. let orderInfo = that.data.orderInfo;
  142. wx.showModal({
  143. title: '',
  144. content: '确定要取消此订单?',
  145. success: function(res) {
  146. if (res.confirm) {
  147. util.request(api.OrderRefund, {
  148. orderId: orderInfo.id
  149. }, 'POST').then(function(res) {
  150. if (res.errno === 0) {
  151. wx.showToast({
  152. title: '取消订单成功'
  153. });
  154. util.redirect('/pages/ucenter/order/order');
  155. } else {
  156. util.showErrorToast(res.errmsg);
  157. }
  158. });
  159. }
  160. }
  161. });
  162. },
  163. // “删除”点击效果
  164. deleteOrder: function() {
  165. let that = this;
  166. let orderInfo = that.data.orderInfo;
  167. wx.showModal({
  168. title: '',
  169. content: '确定要删除此订单?',
  170. success: function(res) {
  171. if (res.confirm) {
  172. util.request(api.OrderDelete, {
  173. orderId: orderInfo.id
  174. }, 'POST').then(function(res) {
  175. if (res.errno === 0) {
  176. wx.showToast({
  177. title: '删除订单成功'
  178. });
  179. util.redirect('/pages/ucenter/order/order');
  180. } else {
  181. util.showErrorToast(res.errmsg);
  182. }
  183. });
  184. }
  185. }
  186. });
  187. },
  188. // “待上门”点击效果
  189. confirmOrder: function() {
  190. let that = this;
  191. let orderInfo = that.data.orderInfo;
  192. wx.showModal({
  193. title: '',
  194. content: '确认上门服务?',
  195. success: function(res) {
  196. if (res.confirm) {
  197. util.request(api.OrderConfirm, {
  198. orderId: orderInfo.id
  199. }, 'POST').then(function(res) {
  200. if (res.errno === 0) {
  201. wx.showToast({
  202. title: '确认上门成功!'
  203. });
  204. util.redirect('/pages/ucenter/order/order');
  205. } else {
  206. util.showErrorToast(res.errmsg);
  207. }
  208. });
  209. }
  210. }
  211. });
  212. },
  213. // “申请售后”点击效果
  214. aftersaleOrder: function () {
  215. if(this.data.orderInfo.aftersaleStatus === 0){
  216. util.redirect('/pages/ucenter/aftersale/aftersale?id=' + this.data.orderId );
  217. }
  218. else{
  219. util.redirect('/pages/ucenter/aftersaleDetail/aftersaleDetail?id=' + this.data.orderId);
  220. }
  221. },
  222. viewService(){
  223. wx.navigateTo({
  224. url: '../serviceDetail/serviceDetail?orderId=' + this.data.orderId
  225. })
  226. },
  227. onReady: function() {
  228. // 页面渲染完成
  229. },
  230. onShow: function() {
  231. // 页面显示
  232. },
  233. onHide: function() {
  234. // 页面隐藏
  235. },
  236. onUnload: function() {
  237. // 页面关闭
  238. }
  239. })