敢为人鲜小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.4 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. import { mapMutations } from 'vuex'
  2. export default {
  3. data() {
  4. return {
  5. }
  6. },
  7. computed: {
  8. },
  9. methods: {
  10. ...mapMutations(['clearCouponData']),
  11. // 支付接口
  12. handlePay(orderParams) {
  13. uni.showLoading({
  14. title: '支付处理中...'
  15. })
  16. if (!orderParams.userCouponId) {
  17. // 没有优惠卷 则不传
  18. delete orderParams.userCouponId
  19. }
  20. if (orderParams.remark == '') {
  21. delete orderParams.remark
  22. }
  23. this.$api('createOrder', {
  24. ...orderParams
  25. }, res => {
  26. uni.hideLoading()
  27. if (res.code === 200) {
  28. if (orderParams.payType == '0') {
  29. uni.requestPaymentWxPay(res)
  30. .then(n => {
  31. setTimeout(uni.redirectTo, 700, {
  32. url: '/pages/index/order?tabIndex=1'
  33. })
  34. })
  35. .catch(err => {
  36. uni.showToast({
  37. title: '支付失败',
  38. icon: 'error'
  39. })
  40. setTimeout(uni.redirectTo, 700, {
  41. url: '/pages/index/order?tabIndex=0'
  42. })
  43. })
  44. } else {
  45. uni.showToast({
  46. title: '下单成功',
  47. icon: 'success'
  48. })
  49. setTimeout(uni.redirectTo, 700, {
  50. url: '/pages/index/order?tabIndex=1'
  51. })
  52. }
  53. }
  54. })
  55. },
  56. // 立即支付
  57. // toPayOrder(item){
  58. // let api = ''
  59. // // if([0, 1].includes(item.shopState)){
  60. // // api = 'createOrderTwo'
  61. // // }else{
  62. // api = 'createSumOrderAgain'
  63. // // }
  64. // this.$api(api, {
  65. // orderId : item.id,
  66. // addressId : item.addressId
  67. // }, res => {
  68. // if(res.code == 200){
  69. // uni.requestPaymentWxPay(res)
  70. // .then(res => {
  71. // uni.showToast({
  72. // title: '支付成功',
  73. // icon: 'none'
  74. // })
  75. // this.getData()
  76. // }).catch(n => {
  77. // this.getData()
  78. // })
  79. // }
  80. // })
  81. // },
  82. // 确认收货
  83. // confirmOrder(item){
  84. // uni.showModal({
  85. // title: '您收到货了吗?',
  86. // success : e => {
  87. // if(e.confirm){
  88. // this.$api('confirmOrder', {
  89. // orderId : item.id,
  90. // }, res => {
  91. // this.getData()
  92. // })
  93. // }
  94. // }
  95. // })
  96. // },
  97. // // 取消订单
  98. // cancelOrder(item){
  99. // uni.showModal({
  100. // title: '确认取消订单吗?',
  101. // success : e => {
  102. // if(e.confirm){
  103. // this.$api('cancelOrder', {
  104. // orderId : item.id,
  105. // }, res => {
  106. // this.getData()
  107. // })
  108. // }
  109. // }
  110. // })
  111. // },
  112. },
  113. beforeDestroy() {
  114. this.clearCouponData();
  115. }
  116. }