orderDetail.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. // console.log(that.data.orderInfo.orderBizType)
  76. if (that.data.orderInfo.orderBizType == '10') {
  77. //校验获取用户id上次活体人脸核身时间是否在可调用范围内
  78. util.request(api.CheckFaceTimeByUserId, {
  79. userId: wx.getStorageSync('userId'),
  80. storeId: wx.getStorageSync('storeId')
  81. }, 'POST').then(function (checkRes) {
  82. if (checkRes.errno === 0) {
  83. //根据用户上次活体人脸核身时间判断出,该用户可以调起人脸接口
  84. if (checkRes.data === true) {
  85. //根据订单号获取是否认证成功,认证成功则调起支付,否则提示
  86. that.checkFace();
  87. } else {
  88. //调起支付
  89. wx.redirectTo({
  90. url: '/pages/pay/pay?orderIds=' + that.data.orderId
  91. + '&actualPrice=' + that.data.orderInfo.actual_price + '&isMergePay=0&orderBizType10=true'
  92. })
  93. }
  94. }
  95. });
  96. } else {
  97. wx.redirectTo({
  98. url: '/pages/pay/pay?orderIds=' + that.data.orderId
  99. + '&actualPrice=' + that.data.orderInfo.actual_price + '&isMergePay=0'
  100. })
  101. }
  102. },
  103. checkFace(){
  104. var that = this;
  105. util.request(api.GetIsFaceCheckByOrderId, {
  106. orderIds: that.data.orderId
  107. }).then(function (res) {
  108. if (res.errno === 0) {
  109. if (res.data.isFaceCheck === '1') {
  110. wx.redirectTo({
  111. url: '/pages/pay/pay?orderIds=' + that.data.orderId
  112. + '&actualPrice=' + that.data.orderInfo.actual_price + '&isMergePay=0&orderBizType10=true'
  113. })
  114. } else {
  115. wx.showToast({
  116. title: '现场速递商品购买需先认证身份信息再进行支付',
  117. icon: 'none',
  118. duration: 1500
  119. })
  120. }
  121. }
  122. });
  123. },
  124. onReady: function () {
  125. // 页面渲染完成
  126. },
  127. onShow: function () {
  128. // 页面显示
  129. this.getOrderDetail();
  130. this.setData({
  131. currentStoreId: wx.getStorageSync('storeId')
  132. });
  133. },
  134. onHide: function () {
  135. // 页面隐藏
  136. },
  137. onUnload: function () {
  138. // 页面关闭
  139. },
  140. postComment() {
  141. let that = this;
  142. wx.navigateTo({
  143. url: '/pages/commentPost/commentPost?typeId=0'+ '&orderId='+that.data.orderId,
  144. })
  145. },
  146. lookComment() {
  147. let that = this;
  148. wx.navigateTo({
  149. url: '/pages/comment/comment?typeId=0' + '&orderId=' + that.data.orderId,
  150. })
  151. },
  152. cancelOrder() {
  153. let that = this;
  154. util.request(api.OrderCancel, {
  155. orderId: that.data.orderId
  156. }).then(function (res) {
  157. if (res.errno === 0) {
  158. wx.showToast({
  159. title: '取消成功',
  160. duration: 1500,
  161. success: function () {
  162. setTimeout(function () {
  163. wx.navigateBack({
  164. delta: 1
  165. });
  166. },1500);
  167. }
  168. })
  169. }else {
  170. wx.showToast({
  171. title: res.errmsg,
  172. duration: 1500
  173. })
  174. }
  175. });
  176. },
  177. confirmOrder() {
  178. let that = this;
  179. util.request(api.OrderConfirm, {
  180. orderId: that.data.orderId
  181. }).then(function (res) {
  182. if (res.errno === 0) {
  183. wx.showToast({
  184. title: '订单完成',
  185. duration: 2000,
  186. complete: function () {
  187. wx.redirectTo({
  188. url: '/pages/ucenter/order/order',
  189. });
  190. }
  191. })
  192. }
  193. });
  194. },
  195. refund(){
  196. let that = this;
  197. util.request(api.refund, {
  198. orderId: that.data.orderId
  199. }).then(function (res) {
  200. if (res.errno === 0) {
  201. wx.showToast({
  202. title: '成功退款',
  203. duration: 2000,
  204. complete: function () {
  205. wx.redirectTo({
  206. url: '/pages/ucenter/order/order',
  207. });
  208. }
  209. })
  210. }else{
  211. wx.showModal({
  212. title: '',
  213. confirmColor: '#b4282d',
  214. content: res.errmsg,
  215. showCancel:false
  216. })
  217. }
  218. });
  219. }
  220. })