|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <LimitedBanner></LimitedBanner>
|
|
|
+ <LimitedBanner v-if="isActivity" v-bind="activity" @sub="onSubscribe" @curTime="getCurTime"></LimitedBanner>
|
|
|
<Layout class="vip-subscribe-buy" contentWithState="full" :needAd="false">
|
|
|
<div class="vip-subscribe-title">{{ buyTypeText }}超级订阅</div>
|
|
|
<div class="vip-subscribe-content">
|
|
@@ -54,6 +54,7 @@
|
|
|
<div slot="header" class="vip-sub-item-title">赠品</div>
|
|
|
<div class="vip-sub-item-content">
|
|
|
<CouponGiftList
|
|
|
+ :parentProductId="parentProductId"
|
|
|
:productionId="specActiveItem.productionId"
|
|
|
@loaded="giftListLoaded" />
|
|
|
</div>
|
|
@@ -68,6 +69,7 @@
|
|
|
</SelectorCard>
|
|
|
</div>
|
|
|
<BuySubmit
|
|
|
+ ref="buySubmitRef"
|
|
|
:pass="allPass"
|
|
|
:productionTotal="computedPrice.total / 100"
|
|
|
:productionDiscount="computedPrice.discount / 100"
|
|
@@ -96,6 +98,7 @@ import BuySubmit from '@/components/coupon/BuySubmit.vue'
|
|
|
import Contrast from '@/views/vipsubscribe/components/Contrast.vue'
|
|
|
import LimitedBanner from '@/components/limited-banner/index.vue'
|
|
|
import { Dialog } from 'element-ui'
|
|
|
+import { fen2Yuan } from '@/utils/'
|
|
|
|
|
|
import {
|
|
|
getGoodsPrice,
|
|
@@ -103,7 +106,10 @@ import {
|
|
|
getSVIPBuyInfo,
|
|
|
getUserAccountInfo,
|
|
|
getUserPower,
|
|
|
- createCommonOrder
|
|
|
+ createCommonOrder,
|
|
|
+ getGiftList,
|
|
|
+ appointmentAdd,
|
|
|
+ getIsAppointment
|
|
|
} from '@/api/modules/'
|
|
|
|
|
|
export default {
|
|
@@ -186,11 +192,15 @@ export default {
|
|
|
tipText: ''
|
|
|
}
|
|
|
],
|
|
|
+ parentProductId: 101,
|
|
|
computedPrice: {
|
|
|
total: 0,
|
|
|
discount: 0,
|
|
|
pay: 0
|
|
|
- }
|
|
|
+ },
|
|
|
+ isActivity: false,
|
|
|
+ activity: {},
|
|
|
+ appointmentStatus: -1 // 预约状态
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -278,6 +288,7 @@ export default {
|
|
|
this.getGoodsPrice()
|
|
|
this.getUserPower() // 获取最新的power
|
|
|
this.getUserAccountInfo()
|
|
|
+ this.getAllGiftList()
|
|
|
},
|
|
|
beforeRouteEnter (to, from, next) {
|
|
|
const title = document.title
|
|
@@ -384,12 +395,13 @@ export default {
|
|
|
this.updatePrice()
|
|
|
},
|
|
|
specChange (spec) {
|
|
|
+ this.activity = {}
|
|
|
if (this.buyType === 'upgrade') {
|
|
|
spec.productionId = 1015
|
|
|
}
|
|
|
this.specActiveItem = spec
|
|
|
this.resetCouponList()
|
|
|
- this.resetGiftInfo()
|
|
|
+ // this.resetGiftInfo()
|
|
|
this.updatePrice()
|
|
|
},
|
|
|
resetGiftInfo () {
|
|
@@ -409,13 +421,22 @@ export default {
|
|
|
this.couponActiveItem = coupon
|
|
|
this.updatePrice()
|
|
|
},
|
|
|
- giftListLoaded ({ list }) {
|
|
|
- if (Array.isArray(list) && list.length) {
|
|
|
+ async giftListLoaded ({ list }) {
|
|
|
+ if (Array.isArray(list) && list.length > 0) {
|
|
|
+ this.isActivity = true
|
|
|
+ const activity = list[0]
|
|
|
+ for (const key in activity) {
|
|
|
+ this.activity[key] = activity[key]
|
|
|
+ }
|
|
|
+ this.activity.status = this.appointmentStatus
|
|
|
+ this.updatePrice()
|
|
|
const gift = list[0]
|
|
|
- this.specActiveItem.tipText = `加赠${gift.giftInfo}`
|
|
|
+ // this.specActiveItem.tipText = gift.giftInfo ? `加赠${gift.giftInfo}` : ''
|
|
|
this.$set(this.specActiveItem, 'discountId', gift.discountId)
|
|
|
} else {
|
|
|
- this.specActiveItem.tipText = ''
|
|
|
+ this.isActivity = false
|
|
|
+ this.activity = {}
|
|
|
+ // this.specActiveItem.tipText = ''
|
|
|
this.$set(this.specActiveItem, 'discountId', '')
|
|
|
}
|
|
|
},
|
|
@@ -473,6 +494,14 @@ export default {
|
|
|
const params = this.getSubmitParam()
|
|
|
const { data, success } = await getSelectPrice(params)
|
|
|
if (success) {
|
|
|
+ const { reduce, promotionalPrice, discount } = this.activity
|
|
|
+ if (reduce) {
|
|
|
+ data.order_price = data.order_price - reduce
|
|
|
+ } else if (promotionalPrice) {
|
|
|
+ data.order_price = promotionalPrice
|
|
|
+ } else if (discount) {
|
|
|
+ data.order_price = data.order_price * (discount / 10)
|
|
|
+ }
|
|
|
this.computedPrice.total = data.original_price
|
|
|
this.computedPrice.pay = data.order_price
|
|
|
this.computedPrice.discount = data.original_price - data.order_price
|
|
@@ -562,6 +591,102 @@ export default {
|
|
|
} else {
|
|
|
this.$toast(error_msg)
|
|
|
}
|
|
|
+ },
|
|
|
+ async onSubscribe () {
|
|
|
+ const { error_msg: msg, data } = await appointmentAdd({
|
|
|
+ productId: this.activity.productCode,
|
|
|
+ useProductType: 0
|
|
|
+ })
|
|
|
+ if (data) {
|
|
|
+ if (data.status === 1) {
|
|
|
+ this.$toast('预约成功,活动开始前10分钟,将通过站内信再次通知您,请注意查收')
|
|
|
+ } else {
|
|
|
+ this.$toast(msg)
|
|
|
+ }
|
|
|
+ this.activity.status = data.status
|
|
|
+ this.$forceUpdate()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 查所有规格商品下的特惠信息
|
|
|
+ async getAllGiftList () {
|
|
|
+ var info = {
|
|
|
+ useProduct: this.parentProductId,
|
|
|
+ useProductType: 0
|
|
|
+ }
|
|
|
+ const { data } = await getGiftList(info)
|
|
|
+ if (data && data.length > 0) {
|
|
|
+ this.getActivityStatus(data[0].activityId)
|
|
|
+ this.specList.forEach(v => {
|
|
|
+ data.forEach(s => {
|
|
|
+ if (v.productionId === s.productCode) {
|
|
|
+ if (s.time) {
|
|
|
+ // 赠周期
|
|
|
+ v.tipText = this.sortGiftInfo(s)
|
|
|
+ } else {
|
|
|
+ // 折扣、满减、特惠
|
|
|
+ v.tipText = this.sortActivityInfo(s)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.specList.forEach(v => {
|
|
|
+ v.tipText = ''
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sortActivityInfo (item) {
|
|
|
+ if (item.reduce) {
|
|
|
+ return `立减${fen2Yuan(item.reduce)}元`
|
|
|
+ } else if (item.promotionalPrice) {
|
|
|
+ return `特惠价${fen2Yuan(item.promotionalPrice)}元`
|
|
|
+ } else if (item.discount) {
|
|
|
+ return `${item.discount}折`
|
|
|
+ } else {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sortGiftInfo (gift) {
|
|
|
+ const info = gift
|
|
|
+ let timeType = ''
|
|
|
+ if (info.timeType === 1) {
|
|
|
+ timeType = '天'
|
|
|
+ return `${info.time}${timeType}`
|
|
|
+ } else if (info.timeType === 2) {
|
|
|
+ timeType = '月'
|
|
|
+ return `${info.time}个${timeType}`
|
|
|
+ }
|
|
|
+ return ''
|
|
|
+ },
|
|
|
+ // 获取活动是否已预约
|
|
|
+ async getActivityStatus (id) {
|
|
|
+ if (!id) return
|
|
|
+ const { data } = await getIsAppointment({
|
|
|
+ activityId: id
|
|
|
+ })
|
|
|
+ if (data) {
|
|
|
+ this.appointmentStatus = data?.status
|
|
|
+ } else {
|
|
|
+ this.appointmentStatus = -1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getCurTime (data) {
|
|
|
+ if (data > this.activity.startTime && data < this.activity.endTime) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.buySubmitRef.changeBtnText(true)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (data >= this.activity.endTime) {
|
|
|
+ // 会有毫秒延迟
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isActivity = false
|
|
|
+ this.activity = {}
|
|
|
+ this.getAllGiftList()
|
|
|
+ this.updatePrice()
|
|
|
+ this.$refs.buySubmitRef.changeBtnText(false)
|
|
|
+ }, 300)
|
|
|
+ this.$forceUpdate()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|