敢为人鲜小程序前端代码仓库
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.

113 lines
2.2 KiB

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