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

61 lines
1.2 KiB

7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 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. beforeDestroy() {
  58. this.clearCouponData();
  59. }
  60. }