apisMixins.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import Vue from 'vue'
  2. const apisMixins = {
  3. methods: {
  4. // 购物车修改SKU规格
  5. async apiUserClubCheckSku(params) {
  6. try {
  7. await this.ProductService.ShoppingCheckSku(params)
  8. setTimeout(() => {
  9. this.initGetCartGoodsList()
  10. }, 1500)
  11. } catch (error) {
  12. console.log('error', error)
  13. }
  14. },
  15. //调用购买优惠券
  16. async apiWeChatCouponRecord(params, coupon) {
  17. try {
  18. const res = await this.PayService.WeChatCouponRecord(params)
  19. this.MiniWxPayFor(coupon, res.data.couponRecordId)
  20. setTimeout(() => {
  21. this.initGetCartGoodsList()
  22. }, 1500)
  23. } catch (error) {
  24. if (error.code == -1) {
  25. //个人机构不能购买
  26. this.contentModalText = '该优惠券仅限医美机构购买,请升级为医美机构后再次购买。'
  27. this.modal = true
  28. } else if (error.code == -2) {
  29. //会员机构不是医美机构不能购买
  30. this.$util.msg('该优惠券仅限医美机构购买', 2000)
  31. }
  32. }
  33. },
  34. async MiniWxPayFor(coupon, couponRecordId) {
  35. // 微信支付
  36. const wechatcode = await authorize.getCode('weixin')
  37. const params = {
  38. userId: this.userId,
  39. couponId: coupon.couponId,
  40. couponRecordId: couponRecordId,
  41. payType: 'XCX',
  42. code: wechatcode,
  43. source: 1 //支付来源 1 小程序 2 WWW
  44. }
  45. this.weChatMiniCouponWxPay(
  46. params,
  47. 'Um_Event_cartCouponPay',
  48. '机构购物车',
  49. '线上支付优惠券',
  50. coupon.couponId,
  51. this.userId
  52. )
  53. },
  54. //调用采美豆抵扣优惠券
  55. async apiWeChatPayCouponBeans(params) {
  56. try {
  57. await this.PayService.WeChatPayCouponBeans(params)
  58. this.$util.msg('抵扣成功', 1500)
  59. setTimeout(() => {
  60. this.currentTab = 1
  61. this.couponParam.status = 2
  62. this.queryPopupCoupons()
  63. }, 1500)
  64. } catch (error) {
  65. this.$util.msg(error.msg, 2000)
  66. }
  67. },
  68. //领取优惠券
  69. async apiReceiveCoupon(params) {
  70. try {
  71. await this.ProductService.ReceiveCoupon(params)
  72. this.$util.msg('领取成功', 1500, true, 'success')
  73. setTimeout(() => {
  74. this.currentTab = 1
  75. this.couponParam.status = 2
  76. this.queryPopupCoupons()
  77. }, 1500)
  78. } catch (error) {
  79. this.$util.msg(error.msg, 2000)
  80. }
  81. },
  82. // 获取弹窗优惠券列表
  83. async apiShoppingCartGetCoupon(params) {
  84. try {
  85. const res = await this.ProductService.ShoppingCartGetCoupon(params)
  86. let data = res.data
  87. this.navbar[0].num = data.notCouponNum
  88. this.navbar[1].num = data.couponNum
  89. if (data.couponList && data.couponList.length > 0) {
  90. this.productCouponList = data.couponList
  91. this.isCouponEmpty = false
  92. } else {
  93. this.isCouponEmpty = true
  94. }
  95. } catch (error) {
  96. }
  97. },
  98. //更新购物车商品
  99. async apiShoppingCartUpdate(params) {
  100. try{
  101. await this.ProductService.ShoppingCartUpdate(params)
  102. this.isshowDelbtn = false
  103. }catch(error){
  104. console.log('更新购物车商品数量失败')
  105. }
  106. },
  107. // 删除购物车商品
  108. async shoppingCartDelete(params) {
  109. try{
  110. await this.ProductService.ShoppingCartDelete(params)
  111. this.$util.msg('删除成功', 2000)
  112. setTimeout(() => {
  113. this.isshowDelbtn = false
  114. this.initGetCartGoodsList()
  115. }, 2000)
  116. }catch(error){
  117. console.log('购物车删除失败')
  118. }
  119. }
  120. }
  121. }
  122. export default apisMixins