|
@@ -200,7 +200,9 @@ export default {
|
|
|
},
|
|
|
isActivity: false,
|
|
|
activity: {},
|
|
|
- appointmentStatus: -1 // 预约状态
|
|
|
+ appointmentStatus: -1, // 预约状态
|
|
|
+ curTime: 0,
|
|
|
+ goodsBadge: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -282,6 +284,11 @@ export default {
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
|
+ // 商品规格上是否展示优惠信息、价格是否计算优惠(活动未开始前、库存为0不展示不计算优惠)
|
|
|
+ // isDiscounts () {
|
|
|
+ // console.log(this.goodsBadge, JSON.stringify(this.activity))
|
|
|
+ // return this.goodsBadge && this.activity && this.activity.stockNumber && this.activity.stockNumber > 0
|
|
|
+ // }
|
|
|
},
|
|
|
created () {
|
|
|
this.getType()
|
|
@@ -395,7 +402,15 @@ export default {
|
|
|
this.updatePrice()
|
|
|
},
|
|
|
specChange (spec) {
|
|
|
- this.activity = {}
|
|
|
+ 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 (this.buyType === 'upgrade') {
|
|
|
spec.productionId = 1015
|
|
|
}
|
|
@@ -428,7 +443,6 @@ export default {
|
|
|
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 ? `加赠${gift.giftInfo}` : ''
|
|
@@ -494,13 +508,15 @@ 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)
|
|
|
+ const { reduce, promotionalPrice, discount, stockNumber } = this.activity
|
|
|
+ if (stockNumber > 0) {
|
|
|
+ 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
|
|
@@ -666,17 +682,32 @@ export default {
|
|
|
})
|
|
|
if (data) {
|
|
|
this.appointmentStatus = data?.status
|
|
|
+ this.activity.status = data?.status
|
|
|
} else {
|
|
|
- this.appointmentStatus = -1
|
|
|
+ this.activity.status = -1
|
|
|
}
|
|
|
},
|
|
|
getCurTime (data) {
|
|
|
- if (data > this.activity.startTime && data < this.activity.endTime) {
|
|
|
+ this.curTime = data
|
|
|
+ if (data < this.activity.startTime) {
|
|
|
+ // 活动未开始
|
|
|
+ this.activity.reduce = 0
|
|
|
+ this.activity.promotionalPrice = 0
|
|
|
+ this.activity.discount = 0
|
|
|
+ this.$refs.buySubmitRef.changeBtnText(false)
|
|
|
+ } else if (data > this.activity.startTime && data < this.activity.endTime) {
|
|
|
+ // 活动进行中
|
|
|
+ const { stockNumber } = this.activity
|
|
|
this.$nextTick(() => {
|
|
|
- this.$refs.buySubmitRef.changeBtnText(true)
|
|
|
+ if (stockNumber > 0) {
|
|
|
+ this.$refs.buySubmitRef.changeBtnText(true)
|
|
|
+ } else {
|
|
|
+ this.$refs.buySubmitRef.changeBtnText(false)
|
|
|
+ }
|
|
|
+ this.goodsBadge = true
|
|
|
})
|
|
|
- }
|
|
|
- if (data >= this.activity.endTime) {
|
|
|
+ } else if (data >= this.activity.endTime) {
|
|
|
+ // 活动结束
|
|
|
// 会有毫秒延迟
|
|
|
setTimeout(() => {
|
|
|
this.isActivity = false
|
|
@@ -685,7 +716,10 @@ export default {
|
|
|
this.updatePrice()
|
|
|
this.$refs.buySubmitRef.changeBtnText(false)
|
|
|
}, 300)
|
|
|
+ this.goodsBadge = false
|
|
|
this.$forceUpdate()
|
|
|
+ } else {
|
|
|
+ this.goodsBadge = false
|
|
|
}
|
|
|
}
|
|
|
}
|