|
@@ -1,6 +1,6 @@
|
|
<template>
|
|
<template>
|
|
<div>
|
|
<div>
|
|
- <LimitedBanner v-if="isActivity" v-bind="activity" @sub="onSubscribe" @curTime="getCurTime"></LimitedBanner>
|
|
|
|
|
|
+ <LimitedBanner v-if="isActivity" v-bind="activity" :status="activity.status" @sub="onSubscribe" @curTime="getCurTime"></LimitedBanner>
|
|
<Layout class="vip-subscribe-buy" contentWithState="full" :needAd="false">
|
|
<Layout class="vip-subscribe-buy" contentWithState="full" :needAd="false">
|
|
<div class="vip-subscribe-title">{{ buyTypeText }}超级订阅</div>
|
|
<div class="vip-subscribe-title">{{ buyTypeText }}超级订阅</div>
|
|
<div class="vip-subscribe-content">
|
|
<div class="vip-subscribe-content">
|
|
@@ -109,7 +109,8 @@ import {
|
|
createCommonOrder,
|
|
createCommonOrder,
|
|
getGiftList,
|
|
getGiftList,
|
|
appointmentAdd,
|
|
appointmentAdd,
|
|
- getIsAppointment
|
|
|
|
|
|
+ getIsAppointment,
|
|
|
|
+ getServerInitTime
|
|
} from '@/api/modules/'
|
|
} from '@/api/modules/'
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -202,7 +203,8 @@ export default {
|
|
activity: {},
|
|
activity: {},
|
|
appointmentStatus: -1, // 预约状态
|
|
appointmentStatus: -1, // 预约状态
|
|
curTime: 0,
|
|
curTime: 0,
|
|
- goodsBadge: false
|
|
|
|
|
|
+ serverInitTime: 0,
|
|
|
|
+ allActivityData: [] // 所有活动信息
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -283,19 +285,19 @@ export default {
|
|
} else {
|
|
} else {
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
// 商品规格上是否展示优惠信息、价格是否计算优惠(活动未开始前、库存为0不展示不计算优惠)
|
|
// 商品规格上是否展示优惠信息、价格是否计算优惠(活动未开始前、库存为0不展示不计算优惠)
|
|
- // isDiscounts () {
|
|
|
|
- // console.log(this.goodsBadge, JSON.stringify(this.activity))
|
|
|
|
- // return this.goodsBadge && this.activity && this.activity.stockNumber && this.activity.stockNumber > 0
|
|
|
|
- // }
|
|
|
|
|
|
+ isDiscounts () {
|
|
|
|
+ console.log(JSON.stringify(this.activity))
|
|
|
|
+ return this.activity && this.activity.stockNumber && this.activity.stockNumber > 0
|
|
|
|
+ }
|
|
},
|
|
},
|
|
- created () {
|
|
|
|
|
|
+ async created () {
|
|
this.getType()
|
|
this.getType()
|
|
|
|
+ await this.getAllGiftList()
|
|
this.getGoodsPrice()
|
|
this.getGoodsPrice()
|
|
this.getUserPower() // 获取最新的power
|
|
this.getUserPower() // 获取最新的power
|
|
this.getUserAccountInfo()
|
|
this.getUserAccountInfo()
|
|
- this.getAllGiftList()
|
|
|
|
},
|
|
},
|
|
beforeRouteEnter (to, from, next) {
|
|
beforeRouteEnter (to, from, next) {
|
|
const title = document.title
|
|
const title = document.title
|
|
@@ -402,15 +404,15 @@ export default {
|
|
this.updatePrice()
|
|
this.updatePrice()
|
|
},
|
|
},
|
|
specChange (spec) {
|
|
specChange (spec) {
|
|
- if (Object.keys(this.activity).length > 0) {
|
|
|
|
- this.activity.reduce = 0
|
|
|
|
- this.activity.promotionalPrice = 0
|
|
|
|
- this.activity.discount = 0
|
|
|
|
- this.activity.stockNumber = 0
|
|
|
|
- this.activity.status = this.appointmentStatus
|
|
|
|
- } else {
|
|
|
|
- this.activity.stockNumber = 0
|
|
|
|
- }
|
|
|
|
|
|
+ // if (Object.keys(this.activity).length > 0) {
|
|
|
|
+ // this.activity.reduce = 0
|
|
|
|
+ // this.activity.promotionalPrice = 0
|
|
|
|
+ // this.activity.discount = 0
|
|
|
|
+ // this.activity.activityName = ''
|
|
|
|
+ // this.activity.stockNumber = ''
|
|
|
|
+ // this.activity.status = ''
|
|
|
|
+ // }
|
|
|
|
+ this.activity.status = this.appointmentStatus
|
|
if (this.buyType === 'upgrade') {
|
|
if (this.buyType === 'upgrade') {
|
|
spec.productionId = 1015
|
|
spec.productionId = 1015
|
|
}
|
|
}
|
|
@@ -443,6 +445,7 @@ export default {
|
|
for (const key in activity) {
|
|
for (const key in activity) {
|
|
this.activity[key] = activity[key]
|
|
this.activity[key] = activity[key]
|
|
}
|
|
}
|
|
|
|
+ // this.changGoodsBadge()
|
|
this.updatePrice()
|
|
this.updatePrice()
|
|
const gift = list[0]
|
|
const gift = list[0]
|
|
// this.specActiveItem.tipText = gift.giftInfo ? `加赠${gift.giftInfo}` : ''
|
|
// this.specActiveItem.tipText = gift.giftInfo ? `加赠${gift.giftInfo}` : ''
|
|
@@ -507,9 +510,13 @@ export default {
|
|
async updatePrice () {
|
|
async updatePrice () {
|
|
const params = this.getSubmitParam()
|
|
const params = this.getSubmitParam()
|
|
const { data, success } = await getSelectPrice(params)
|
|
const { data, success } = await getSelectPrice(params)
|
|
|
|
+ await this.initAdjustTime()
|
|
if (success) {
|
|
if (success) {
|
|
- const { reduce, promotionalPrice, discount, stockNumber } = this.activity
|
|
|
|
- if (stockNumber > 0) {
|
|
|
|
|
|
+ const { reduce, promotionalPrice, discount, stockNumber, beginDate, endDate } = this.activity
|
|
|
|
+ const beginTime = beginDate && beginDate.toString().length === 10 ? beginDate * 1000 : beginDate
|
|
|
|
+ const endTime = endDate && endDate.toString().length === 10 ? endDate * 1000 : endDate
|
|
|
|
+ const nowTime = this.serverInitTime
|
|
|
|
+ if (stockNumber > 0 && nowTime > beginTime && nowTime < endTime) {
|
|
if (reduce) {
|
|
if (reduce) {
|
|
data.order_price = data.order_price - reduce
|
|
data.order_price = data.order_price - reduce
|
|
} else if (promotionalPrice) {
|
|
} else if (promotionalPrice) {
|
|
@@ -619,6 +626,7 @@ export default {
|
|
} else {
|
|
} else {
|
|
this.$toast(msg)
|
|
this.$toast(msg)
|
|
}
|
|
}
|
|
|
|
+ this.appointmentStatus = data.status
|
|
this.activity.status = data.status
|
|
this.activity.status = data.status
|
|
this.$forceUpdate()
|
|
this.$forceUpdate()
|
|
}
|
|
}
|
|
@@ -631,21 +639,10 @@ export default {
|
|
}
|
|
}
|
|
const { data } = await getGiftList(info)
|
|
const { data } = await getGiftList(info)
|
|
if (data && data.length > 0) {
|
|
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)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
|
|
+ await this.getActivityStatus(data[0].activityId)
|
|
|
|
+ this.allActivityData = data
|
|
} else {
|
|
} else {
|
|
|
|
+ this.allActivityData = []
|
|
this.specList.forEach(v => {
|
|
this.specList.forEach(v => {
|
|
v.tipText = ''
|
|
v.tipText = ''
|
|
})
|
|
})
|
|
@@ -695,8 +692,12 @@ export default {
|
|
this.activity.promotionalPrice = 0
|
|
this.activity.promotionalPrice = 0
|
|
this.activity.discount = 0
|
|
this.activity.discount = 0
|
|
this.$refs.buySubmitRef.changeBtnText(false)
|
|
this.$refs.buySubmitRef.changeBtnText(false)
|
|
|
|
+ } else if (data === this.activity.startTime) {
|
|
|
|
+ this.changGoodsBadge(true)
|
|
|
|
+ this.updatePrice()
|
|
} else if (data > this.activity.startTime && data < this.activity.endTime) {
|
|
} else if (data > this.activity.startTime && data < this.activity.endTime) {
|
|
// 活动进行中
|
|
// 活动进行中
|
|
|
|
+ this.changGoodsBadge(true)
|
|
const { stockNumber } = this.activity
|
|
const { stockNumber } = this.activity
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
if (stockNumber > 0) {
|
|
if (stockNumber > 0) {
|
|
@@ -704,7 +705,6 @@ export default {
|
|
} else {
|
|
} else {
|
|
this.$refs.buySubmitRef.changeBtnText(false)
|
|
this.$refs.buySubmitRef.changeBtnText(false)
|
|
}
|
|
}
|
|
- this.goodsBadge = true
|
|
|
|
})
|
|
})
|
|
} else if (data >= this.activity.endTime) {
|
|
} else if (data >= this.activity.endTime) {
|
|
// 活动结束
|
|
// 活动结束
|
|
@@ -716,10 +716,42 @@ export default {
|
|
this.updatePrice()
|
|
this.updatePrice()
|
|
this.$refs.buySubmitRef.changeBtnText(false)
|
|
this.$refs.buySubmitRef.changeBtnText(false)
|
|
}, 300)
|
|
}, 300)
|
|
- this.goodsBadge = false
|
|
|
|
this.$forceUpdate()
|
|
this.$forceUpdate()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ async initAdjustTime () {
|
|
|
|
+ // 接口响应时服务端的本地时间
|
|
|
|
+ const { data } = await getServerInitTime()
|
|
|
|
+ if (data) {
|
|
|
|
+ this.serverInitTime = data?.time.toString().length === 10 ? data?.time * 1000 : data?.time
|
|
} else {
|
|
} else {
|
|
- this.goodsBadge = false
|
|
|
|
|
|
+ this.serverInitTime = Date.now()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ changGoodsBadge (isShow) {
|
|
|
|
+ if (isShow) {
|
|
|
|
+ const data = this.allActivityData
|
|
|
|
+ this.specList.forEach(v => {
|
|
|
|
+ data.forEach(s => {
|
|
|
|
+ if (!s.stockNumber) {
|
|
|
|
+ s.stockNumber = 0
|
|
|
|
+ }
|
|
|
|
+ if (v.productionId === s.productCode) {
|
|
|
|
+ if (s.time) {
|
|
|
|
+ // 赠周期
|
|
|
|
+ v.tipText = '加赠' + this.sortGiftInfo(s)
|
|
|
|
+ } else {
|
|
|
|
+ // 折扣、满减、特惠
|
|
|
|
+ // 库存大于0限时活动标签
|
|
|
|
+ v.tipText = s.stockNumber > 0 ? this.sortActivityInfo(s) : ''
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ this.specList.forEach(v => {
|
|
|
|
+ v.tipText = ''
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|