apisMixins.js 4.6 KB

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