|
@@ -1,86 +1,91 @@
|
|
<template>
|
|
<template>
|
|
- <Layout class="vip-subscribe-buy" contentWithState="full" :needAd="false">
|
|
|
|
- <div class="vip-subscribe-title">{{ buyTypeText }}超级订阅</div>
|
|
|
|
- <div class="vip-subscribe-content">
|
|
|
|
- <div class="vip-sub-list">
|
|
|
|
- <AreaSelector
|
|
|
|
- ref="areaSelector"
|
|
|
|
- class="vip-sub-list-item"
|
|
|
|
- v-show="moduleShow.areaSelector"
|
|
|
|
- :class="{ 'pd-b0': upgradeTipShow }"
|
|
|
|
- :showSearchInput="false"
|
|
|
|
- :onlyProvince="true"
|
|
|
|
- :showSelectResult="true"
|
|
|
|
- selectorType="line"
|
|
|
|
- @onChange="onAreaChange">
|
|
|
|
- <div slot="header" class="vip-sub-item-title">购买区域</div>
|
|
|
|
- </AreaSelector>
|
|
|
|
- <SelectorCard
|
|
|
|
- class="vip-sub-tip"
|
|
|
|
- v-if="moduleShow.areaSelector"
|
|
|
|
- :cardType="conf.selectorType">
|
|
|
|
- <div slot="header" class="vip-sub-item-title"></div>
|
|
|
|
- <div class="tip-content font-red" v-show="upgradeTipShow">
|
|
|
|
- 请增加购买区域进行升级,当前选择省份数量未高于原套餐数,无法升级
|
|
|
|
- </div>
|
|
|
|
- </SelectorCard>
|
|
|
|
- <SelectorCard
|
|
|
|
- class="vip-sub-list-item"
|
|
|
|
- v-if="moduleShow.specList"
|
|
|
|
- :cardType="conf.selectorType">
|
|
|
|
- <div slot="header" class="vip-sub-item-title">选择购买周期</div>
|
|
|
|
- <div class="vip-sub-item-content">
|
|
|
|
- <SpecList :list="specList" v-model="specIdActive" @change="specChange" />
|
|
|
|
- </div>
|
|
|
|
- </SelectorCard>
|
|
|
|
- <SelectorCard
|
|
|
|
- class="vip-sub-list-item"
|
|
|
|
- v-show="moduleShow.coupon"
|
|
|
|
- :cardType="conf.selectorType">
|
|
|
|
- <div slot="header" class="vip-sub-item-title">选择优惠券</div>
|
|
|
|
- <div class="vip-sub-item-content">
|
|
|
|
- <CouponCardList
|
|
|
|
- ref="couponRef"
|
|
|
|
- :productionId="specActiveItem.productionId"
|
|
|
|
- :price="computedPrice.total"
|
|
|
|
- @loaded="couponCardLoaded"
|
|
|
|
- @change="couponCardChange" />
|
|
|
|
- </div>
|
|
|
|
- </SelectorCard>
|
|
|
|
- <SelectorCard
|
|
|
|
- class="vip-sub-list-item"
|
|
|
|
- v-show="moduleShow.gift"
|
|
|
|
- :cardType="conf.selectorType">
|
|
|
|
- <div slot="header" class="vip-sub-item-title">赠品</div>
|
|
|
|
- <div class="vip-sub-item-content">
|
|
|
|
- <CouponGiftList
|
|
|
|
- :productionId="specActiveItem.productionId"
|
|
|
|
- @loaded="giftListLoaded" />
|
|
|
|
- </div>
|
|
|
|
- </SelectorCard>
|
|
|
|
- <SelectorCard
|
|
|
|
- class="vip-sub-list-item"
|
|
|
|
- :cardType="conf.selectorType">
|
|
|
|
- <div slot="header" class="vip-sub-item-title">手机号码</div>
|
|
|
|
- <div class="vip-sub-item-content">
|
|
|
|
- <CheckPhone v-model="userInfo.phone" :pass.sync="phoneRegPass" />
|
|
|
|
- </div>
|
|
|
|
- </SelectorCard>
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <LimitedBanner v-if="isActivity" v-bind="activity" :status="activity.status" @sub="onSubscribe"></LimitedBanner>
|
|
|
|
+ <Layout class="vip-subscribe-buy" contentWithState="full" :needAd="false">
|
|
|
|
+ <div class="vip-subscribe-title">{{ buyTypeText }}超级订阅</div>
|
|
|
|
+ <div class="vip-subscribe-content">
|
|
|
|
+ <div class="vip-sub-list">
|
|
|
|
+ <AreaSelector
|
|
|
|
+ ref="areaSelector"
|
|
|
|
+ class="vip-sub-list-item"
|
|
|
|
+ :class="{ 'pd-b0': upgradeTipShow }"
|
|
|
|
+ v-show="moduleShow.areaSelector"
|
|
|
|
+ :showSearchInput="false"
|
|
|
|
+ :onlyProvince="true"
|
|
|
|
+ :showSelectResult="true"
|
|
|
|
+ selectorType="line"
|
|
|
|
+ @onChange="onAreaChange">
|
|
|
|
+ <div slot="header" class="vip-sub-item-title">购买区域</div>
|
|
|
|
+ </AreaSelector>
|
|
|
|
+ <SelectorCard
|
|
|
|
+ class="vip-sub-tip"
|
|
|
|
+ v-if="moduleShow.areaSelector"
|
|
|
|
+ :cardType="conf.selectorType">
|
|
|
|
+ <div slot="header" class="vip-sub-item-title"></div>
|
|
|
|
+ <div class="tip-content font-red" v-show="upgradeTipShow">
|
|
|
|
+ 请增加购买区域进行升级,当前选择省份数量未高于原套餐数,无法升级
|
|
|
|
+ </div>
|
|
|
|
+ </SelectorCard>
|
|
|
|
+ <SelectorCard
|
|
|
|
+ class="vip-sub-list-item"
|
|
|
|
+ v-if="moduleShow.specList"
|
|
|
|
+ :cardType="conf.selectorType">
|
|
|
|
+ <div slot="header" class="vip-sub-item-title">选择购买周期</div>
|
|
|
|
+ <div class="vip-sub-item-content">
|
|
|
|
+ <SpecList :list="specList" v-model="specIdActive" @change="specChange" />
|
|
|
|
+ </div>
|
|
|
|
+ </SelectorCard>
|
|
|
|
+ <SelectorCard
|
|
|
|
+ class="vip-sub-list-item"
|
|
|
|
+ v-show="moduleShow.coupon"
|
|
|
|
+ :cardType="conf.selectorType">
|
|
|
|
+ <div slot="header" class="vip-sub-item-title">选择优惠券</div>
|
|
|
|
+ <div class="vip-sub-item-content">
|
|
|
|
+ <CouponCardList
|
|
|
|
+ ref="couponRef"
|
|
|
|
+ :productionId="specActiveItem.productionId"
|
|
|
|
+ :price="computedPrice.total"
|
|
|
|
+ @loaded="couponCardLoaded"
|
|
|
|
+ @change="couponCardChange" />
|
|
|
|
+ </div>
|
|
|
|
+ </SelectorCard>
|
|
|
|
+ <SelectorCard
|
|
|
|
+ class="vip-sub-list-item"
|
|
|
|
+ v-show="moduleShow.gift"
|
|
|
|
+ :cardType="conf.selectorType">
|
|
|
|
+ <div slot="header" class="vip-sub-item-title">赠品</div>
|
|
|
|
+ <div class="vip-sub-item-content">
|
|
|
|
+ <CouponGiftList
|
|
|
|
+ :parentProductId="parentProductId"
|
|
|
|
+ :productionId="specActiveItem.productionId"
|
|
|
|
+ @loaded="giftListLoaded" />
|
|
|
|
+ </div>
|
|
|
|
+ </SelectorCard>
|
|
|
|
+ <SelectorCard
|
|
|
|
+ class="vip-sub-list-item"
|
|
|
|
+ :cardType="conf.selectorType">
|
|
|
|
+ <div slot="header" class="vip-sub-item-title">手机号码</div>
|
|
|
|
+ <div class="vip-sub-item-content">
|
|
|
|
+ <CheckPhone v-model="userInfo.phone" :pass.sync="phoneRegPass" />
|
|
|
|
+ </div>
|
|
|
|
+ </SelectorCard>
|
|
|
|
+ </div>
|
|
|
|
+ <BuySubmit
|
|
|
|
+ ref="buySubmitRef"
|
|
|
|
+ :pass="allPass"
|
|
|
|
+ :productionTotal="computedPrice.total / 100"
|
|
|
|
+ :productionDiscount="computedPrice.discount / 100"
|
|
|
|
+ :productionPay="computedPrice.pay / 100"
|
|
|
|
+ @submit="submit"
|
|
|
|
+ ></BuySubmit>
|
|
</div>
|
|
</div>
|
|
- <BuySubmit
|
|
|
|
- :pass="allPass"
|
|
|
|
- :productionTotal="computedPrice.total / 100"
|
|
|
|
- :productionDiscount="computedPrice.discount / 100"
|
|
|
|
- :productionPay="computedPrice.pay / 100"
|
|
|
|
- @submit="submit"
|
|
|
|
- ></BuySubmit>
|
|
|
|
- </div>
|
|
|
|
- <div class="vip-subscribe-desc">
|
|
|
|
- <Contrast></Contrast>
|
|
|
|
- </div>
|
|
|
|
- <!-- <div style="height: 800px;background: green"></div>
|
|
|
|
- <div class="j-bottom" style="height: 300px;background: red"></div> -->
|
|
|
|
- </Layout>
|
|
|
|
|
|
+ <div class="vip-subscribe-desc">
|
|
|
|
+ <Contrast></Contrast>
|
|
|
|
+ </div>
|
|
|
|
+ <!-- <div style="height: 800px;background: green"></div>
|
|
|
|
+ <div class="j-bottom" style="height: 300px;background: red"></div> -->
|
|
|
|
+ </Layout>
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
@@ -93,7 +98,9 @@ import CouponGiftList from '@/components/coupon/CouponGiftList.vue'
|
|
import CheckPhone from '@/components/coupon/CheckPhone.vue'
|
|
import CheckPhone from '@/components/coupon/CheckPhone.vue'
|
|
import BuySubmit from '@/components/coupon/BuySubmit.vue'
|
|
import BuySubmit from '@/components/coupon/BuySubmit.vue'
|
|
import Contrast from '@/views/vipsubscribe/components/Contrast.vue'
|
|
import Contrast from '@/views/vipsubscribe/components/Contrast.vue'
|
|
|
|
+import LimitedBanner from '@/components/limited-banner/index.vue'
|
|
import { Dialog } from 'element-ui'
|
|
import { Dialog } from 'element-ui'
|
|
|
|
+import { fen2Yuan } from '@/utils/'
|
|
import qs from 'qs'
|
|
import qs from 'qs'
|
|
|
|
|
|
import {
|
|
import {
|
|
@@ -101,7 +108,11 @@ import {
|
|
getSelectPrice,
|
|
getSelectPrice,
|
|
getSVIPBuyInfo,
|
|
getSVIPBuyInfo,
|
|
getUserAccountInfo,
|
|
getUserAccountInfo,
|
|
- createCommonOrder
|
|
|
|
|
|
+ createCommonOrder,
|
|
|
|
+ getGiftList,
|
|
|
|
+ appointmentAdd,
|
|
|
|
+ getIsAppointment,
|
|
|
|
+ getServerInitTime
|
|
} from '@/api/modules/'
|
|
} from '@/api/modules/'
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -116,7 +127,8 @@ export default {
|
|
CheckPhone,
|
|
CheckPhone,
|
|
BuySubmit,
|
|
BuySubmit,
|
|
Contrast,
|
|
Contrast,
|
|
- [Dialog.name]: Dialog
|
|
|
|
|
|
+ [Dialog.name]: Dialog,
|
|
|
|
+ LimitedBanner
|
|
},
|
|
},
|
|
data () {
|
|
data () {
|
|
return {
|
|
return {
|
|
@@ -132,6 +144,7 @@ export default {
|
|
coupon: false,
|
|
coupon: false,
|
|
gift: false
|
|
gift: false
|
|
},
|
|
},
|
|
|
|
+ autoPass: true, // 模拟变量-用于提交订单修改按钮的禁用状态(allPass为计算属性不能直接修改)
|
|
phoneRegPass: false,
|
|
phoneRegPass: false,
|
|
userInfo: {
|
|
userInfo: {
|
|
phone: ''
|
|
phone: ''
|
|
@@ -181,12 +194,20 @@ export default {
|
|
tipText: ''
|
|
tipText: ''
|
|
}
|
|
}
|
|
],
|
|
],
|
|
|
|
+ parentProductId: 101,
|
|
token: '', // 用于管理后台创建订单
|
|
token: '', // 用于管理后台创建订单
|
|
computedPrice: {
|
|
computedPrice: {
|
|
total: 0,
|
|
total: 0,
|
|
discount: 0,
|
|
discount: 0,
|
|
pay: 0
|
|
pay: 0
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ isActivity: false,
|
|
|
|
+ activity: {},
|
|
|
|
+ appointmentStatus: -1, // 预约状态
|
|
|
|
+ curTime: 0,
|
|
|
|
+ serverInitTime: 0,
|
|
|
|
+ allActivityData: [], // 所有活动信息
|
|
|
|
+ timerId: null
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -269,7 +290,7 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
allPass () {
|
|
allPass () {
|
|
- const basicReg = this.phoneRegPass && !this.noSelect
|
|
|
|
|
|
+ const basicReg = this.phoneRegPass && !this.noSelect && this.autoPass
|
|
if (this.buyType === 'buy') {
|
|
if (this.buyType === 'buy') {
|
|
return basicReg
|
|
return basicReg
|
|
} else if (this.buyType === 'upgrade') {
|
|
} else if (this.buyType === 'upgrade') {
|
|
@@ -283,11 +304,23 @@ export default {
|
|
} else {
|
|
} else {
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
|
|
+ },
|
|
|
|
+ // 商品规格上是否展示优惠信息、价格是否计算优惠(活动未开始前、库存为0不展示不计算优惠)
|
|
|
|
+ isDiscounts () {
|
|
|
|
+ console.log(JSON.stringify(this.activity))
|
|
|
|
+ return this.activity && this.activity.stockNumber && this.activity.stockNumber > 0
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ destroyed () {
|
|
|
|
+ clearInterval(this.timerId)
|
|
|
|
+ },
|
|
async created () {
|
|
async created () {
|
|
|
|
+ this.initAdjustTime()
|
|
this.getType()
|
|
this.getType()
|
|
await this.getUserBuyInfo()
|
|
await this.getUserBuyInfo()
|
|
|
|
+ try {
|
|
|
|
+ await this.getAllGiftList()
|
|
|
|
+ } catch (error) {}
|
|
this.getGoodsPrice()
|
|
this.getGoodsPrice()
|
|
if (!this.token) {
|
|
if (!this.token) {
|
|
// 有token时候可以不用请求getAccountInfo
|
|
// 有token时候可以不用请求getAccountInfo
|
|
@@ -384,7 +417,9 @@ export default {
|
|
this.specIdActive = this.specList[0].id
|
|
this.specIdActive = this.specList[0].id
|
|
} else {
|
|
} else {
|
|
// 设置城市选择器所有不选中
|
|
// 设置城市选择器所有不选中
|
|
- this.$refs.areaSelector.content.setAllNoSelected()
|
|
|
|
|
|
+ if (!this.selectInfo.area) {
|
|
|
|
+ this.$refs.areaSelector.content.setAllNoSelected()
|
|
|
|
+ }
|
|
// specIdActive改变会触发specChange
|
|
// specIdActive改变会触发specChange
|
|
// 默认选中1年
|
|
// 默认选中1年
|
|
this.specIdActive = this.specList[2].id
|
|
this.specIdActive = this.specList[2].id
|
|
@@ -492,12 +527,13 @@ export default {
|
|
this.updatePrice()
|
|
this.updatePrice()
|
|
},
|
|
},
|
|
specChange (spec) {
|
|
specChange (spec) {
|
|
|
|
+ this.activity.status = this.appointmentStatus
|
|
if (this.buyType === 'upgrade') {
|
|
if (this.buyType === 'upgrade') {
|
|
spec.productionId = 1015
|
|
spec.productionId = 1015
|
|
}
|
|
}
|
|
this.specActiveItem = spec
|
|
this.specActiveItem = spec
|
|
this.resetCouponList()
|
|
this.resetCouponList()
|
|
- this.resetGiftInfo()
|
|
|
|
|
|
+ // this.resetGiftInfo()
|
|
this.updatePrice()
|
|
this.updatePrice()
|
|
},
|
|
},
|
|
resetGiftInfo () {
|
|
resetGiftInfo () {
|
|
@@ -517,13 +553,25 @@ export default {
|
|
this.couponActiveItem = coupon
|
|
this.couponActiveItem = coupon
|
|
this.updatePrice()
|
|
this.updatePrice()
|
|
},
|
|
},
|
|
- giftListLoaded ({ list }) {
|
|
|
|
- if (Array.isArray(list) && list.length) {
|
|
|
|
|
|
+ async giftListLoaded ({ list }) {
|
|
|
|
+ this.activity.reduce = 0
|
|
|
|
+ this.activity.promotionalPrice = 0
|
|
|
|
+ this.activity.discount = 0
|
|
|
|
+ if (Array.isArray(list) && list.length > 0) {
|
|
|
|
+ const activity = list[0]
|
|
|
|
+ for (const key in activity) {
|
|
|
|
+ this.activity[key] = activity[key]
|
|
|
|
+ }
|
|
|
|
+ this.isActivity = this.activity.activityType > 2 // 活动类型大于2是秒杀活动
|
|
|
|
+ this.updatePrice()
|
|
const gift = list[0]
|
|
const gift = list[0]
|
|
- this.specActiveItem.tipText = `加赠${gift.giftInfo}`
|
|
|
|
|
|
+ // this.specActiveItem.tipText = gift.giftInfo ? `加赠${gift.giftInfo}` : ''
|
|
this.$set(this.specActiveItem, 'discountId', gift.discountId)
|
|
this.$set(this.specActiveItem, 'discountId', gift.discountId)
|
|
} else {
|
|
} else {
|
|
- this.specActiveItem.tipText = ''
|
|
|
|
|
|
+ this.isActivity = false
|
|
|
|
+ // this.specActiveItem.tipText = ''
|
|
|
|
+ this.activity = {}
|
|
|
|
+ this.updatePrice()
|
|
this.$set(this.specActiveItem, 'discountId', '')
|
|
this.$set(this.specActiveItem, 'discountId', '')
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -578,12 +626,23 @@ export default {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
async updatePrice () {
|
|
async updatePrice () {
|
|
|
|
+ const { reduce, promotionalPrice, discount, stockNumber } = this.activity
|
|
|
|
+ // console.log(reduce, promotionalPrice, discount, stockNumber)
|
|
const params = this.getSubmitParam()
|
|
const params = this.getSubmitParam()
|
|
if (this.token) {
|
|
if (this.token) {
|
|
params.token = this.token
|
|
params.token = this.token
|
|
}
|
|
}
|
|
const { errMsg, data, success } = await getSelectPrice(params)
|
|
const { errMsg, data, success } = await getSelectPrice(params)
|
|
if (success) {
|
|
if (success) {
|
|
|
|
+ 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.total = data.original_price
|
|
this.computedPrice.pay = data.order_price
|
|
this.computedPrice.pay = data.order_price
|
|
this.computedPrice.discount = data.original_price - data.order_price
|
|
this.computedPrice.discount = data.original_price - data.order_price
|
|
@@ -668,6 +727,19 @@ export default {
|
|
async submit () {
|
|
async submit () {
|
|
// eslint-disable-next-line
|
|
// eslint-disable-next-line
|
|
const { data, error_msg } = await this.submitXHR()
|
|
const { data, error_msg } = await this.submitXHR()
|
|
|
|
+ let duration = 0
|
|
|
|
+ if (this.activity && Object.keys(this.activity).length > 0) {
|
|
|
|
+ const { stockNumber, isReceive } = this.activity
|
|
|
|
+ if (stockNumber === 0) {
|
|
|
|
+ this.autoPass = false
|
|
|
|
+ duration = 2000
|
|
|
|
+ this.$toast('限时特惠机会已被抢完,需按照原价购买', 3000)
|
|
|
|
+ } else if (!isReceive) {
|
|
|
|
+ duration = 2000
|
|
|
|
+ this.autoPass = false
|
|
|
|
+ this.$toast('您的特惠购买机会已经用完,需按照原价购买', 3000)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if (data) {
|
|
if (data) {
|
|
if (this.token) {
|
|
if (this.token) {
|
|
this.$toast('帮助用户下单成功')
|
|
this.$toast('帮助用户下单成功')
|
|
@@ -677,13 +749,177 @@ export default {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
const orderCode = data.order_code
|
|
const orderCode = data.order_code
|
|
- if (data.needPay) {
|
|
|
|
- window.open(`/front/subvip/orderPay/${orderCode}`)
|
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.autoPass = true
|
|
|
|
+ if (data.needPay) {
|
|
|
|
+ window.open(`/front/subvip/orderPay/${orderCode}`)
|
|
|
|
+ } else {
|
|
|
|
+ window.open(`/front/subvip/paySuccess/${orderCode}?payTime=${parseInt(Date.now() / 1000)}&from=vipUPgrade`)
|
|
|
|
+ }
|
|
|
|
+ }, duration)
|
|
|
|
+ } 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.appointmentStatus = data.status
|
|
|
|
+ // 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) {
|
|
|
|
+ await this.getActivityStatus(data[0].activityId)
|
|
|
|
+ data.forEach(v => {
|
|
|
|
+ v.beginDate = v.beginDate && v.beginDate.toString().length === 10 ? v.beginDate * 1000 : v.beginDate
|
|
|
|
+ v.endDate = v.endDate && v.endDate.toString().length === 10 ? v.endDate * 1000 : v.endDate
|
|
|
|
+ v.preheatingTime = v.preheatingTime && v.preheatingTime.toString().length === 10 ? v.preheatingTime * 1000 : v.preheatingTime
|
|
|
|
+ })
|
|
|
|
+ this.allActivityData = data
|
|
|
|
+ } else {
|
|
|
|
+ this.allActivityData = []
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ async initAdjustTime () {
|
|
|
|
+ // 接口响应时服务端的本地时间
|
|
|
|
+ const { data } = await getServerInitTime()
|
|
|
|
+ if (data) {
|
|
|
|
+ this.serverInitTime = data?.time.toString().length === 10 ? data?.time * 1000 : data?.time
|
|
|
|
+ } else {
|
|
|
|
+ this.serverInitTime = Date.now()
|
|
|
|
+ }
|
|
|
|
+ this.setIntervalFn()
|
|
|
|
+ },
|
|
|
|
+ setIntervalFn () {
|
|
|
|
+ this.timerId = setInterval(() => {
|
|
|
|
+ this.serverInitTime = this.serverInitTime + 1000
|
|
|
|
+ if (this.allActivityData && this.allActivityData.length > 0) {
|
|
|
|
+ const startTime = this.allActivityData[0].beginDate
|
|
|
|
+ const endTime = this.allActivityData[0].endDate
|
|
|
|
+ if (this.serverInitTime < startTime) {
|
|
|
|
+ // 活动未开始
|
|
|
|
+ // console.log('活动未开始')
|
|
|
|
+ this.changGoodsBadge(false)
|
|
|
|
+ try {
|
|
|
|
+ this.$refs.buySubmitRef.changeBtnText(false)
|
|
|
|
+ } catch (error) {}
|
|
|
|
+ } else if (this.serverInitTime === startTime) {
|
|
|
|
+ this.updatePrice()
|
|
|
|
+ } else if (this.serverInitTime >= startTime && this.serverInitTime < endTime) {
|
|
|
|
+ // 活动开始
|
|
|
|
+ // console.log('活动开始')
|
|
|
|
+ this.activity.status = -1
|
|
|
|
+ this.changGoodsBadge(true)
|
|
|
|
+ const { stockNumber } = this.activity
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ if (stockNumber && stockNumber > 0) {
|
|
|
|
+ try {
|
|
|
|
+ this.$refs.buySubmitRef.changeBtnText(true)
|
|
|
|
+ } catch (error) {}
|
|
|
|
+ } else {
|
|
|
|
+ try {
|
|
|
|
+ this.$refs.buySubmitRef.changeBtnText(false)
|
|
|
|
+ } catch (error) {}
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else if (this.serverInitTime >= endTime) {
|
|
|
|
+ // 活动结束
|
|
|
|
+ this.changGoodsBadge(false)
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.isActivity = false
|
|
|
|
+ this.activity = {}
|
|
|
|
+ this.getAllGiftList()
|
|
|
|
+ this.updatePrice()
|
|
|
|
+ try {
|
|
|
|
+ this.$refs.buySubmitRef.changeBtnText(false)
|
|
|
|
+ } catch (error) {}
|
|
|
|
+ }, 300)
|
|
|
|
+ clearInterval(this.timerId)
|
|
|
|
+ this.$forceUpdate()
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- window.open(`/front/subvip/paySuccess/${orderCode}?payTime=${parseInt(Date.now() / 1000)}&from=vipUPgrade`)
|
|
|
|
|
|
+ clearInterval(this.timerId)
|
|
}
|
|
}
|
|
|
|
+ }, 1000)
|
|
|
|
+ },
|
|
|
|
+ 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 {
|
|
} else {
|
|
- this.$toast(error_msg)
|
|
|
|
|
|
+ this.specList.forEach(v => {
|
|
|
|
+ v.tipText = ''
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|