import Vue from 'vue' const apisMixins = { methods: { // 购物车修改SKU规格 async apiUserClubCheckSku(params) { try { await this.ProductService.ShoppingCheckSku(params) setTimeout(() => { this.initGetCartGoodsList() }, 1500) } catch (error) { console.log('error', error) } }, //调用购买优惠券 async apiWeChatCouponRecord(params, coupon) { try { const res = await this.PayService.WeChatCouponRecord(params) this.MiniWxPayFor(coupon, res.data.couponRecordId) setTimeout(() => { this.initGetCartGoodsList() }, 1500) } catch (error) { if (error.code == -1) { //个人机构不能购买 this.contentModalText = '该优惠券仅限医美机构购买,请升级为医美机构后再次购买。' this.modal = true } else if (error.code == -2) { //会员机构不是医美机构不能购买 this.$util.msg('该优惠券仅限医美机构购买', 2000) } } }, async MiniWxPayFor(coupon, couponRecordId) { // 微信支付 const wechatcode = await authorize.getCode('weixin') const params = { userId: this.userId, couponId: coupon.couponId, couponRecordId: couponRecordId, payType: 'XCX', code: wechatcode, source: 1 //支付来源 1 小程序 2 WWW } this.weChatMiniCouponWxPay( params, 'Um_Event_cartCouponPay', '机构购物车', '线上支付优惠券', coupon.couponId, this.userId ) }, //调用采美豆抵扣优惠券 async apiWeChatPayCouponBeans(params) { try { await this.PayService.WeChatPayCouponBeans(params) this.$util.msg('抵扣成功', 1500) setTimeout(() => { this.currentTab = 1 this.couponParam.status = 2 this.queryPopupCoupons() }, 1500) } catch (error) { this.$util.msg(error.msg, 2000) } }, //领取优惠券 async apiReceiveCoupon(params) { try { await this.ProductService.ReceiveCoupon(params) this.$util.msg('领取成功', 1500, true, 'success') setTimeout(() => { this.currentTab = 1 this.couponParam.status = 2 this.queryPopupCoupons() }, 1500) } catch (error) { this.$util.msg(error.msg, 2000) } }, // 获取弹窗优惠券列表 async apiShoppingCartGetCoupon(params) { try { const res = await this.ProductService.ShoppingCartGetCoupon(params) let data = res.data this.navbar[0].num = data.notCouponNum this.navbar[1].num = data.couponNum if (data.couponList && data.couponList.length > 0) { this.productCouponList = data.couponList this.isCouponEmpty = false } else { this.isCouponEmpty = true } } catch (error) { } }, //更新购物车商品 async apiShoppingCartUpdate(params) { try{ await this.ProductService.ShoppingCartUpdate(params) this.isshowDelbtn = false }catch(error){ console.log('更新购物车商品数量失败') } }, // 删除购物车商品 async shoppingCartDelete(params) { try{ await this.ProductService.ShoppingCartDelete(params) this.$util.msg('删除成功', 2000) setTimeout(() => { this.isshowDelbtn = false this.initGetCartGoodsList() }, 2000) }catch(error){ console.log('购物车删除失败') } } } } export default apisMixins