apisMixins.js 4.6 KB

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