|
@@ -6,6 +6,7 @@
|
|
|
<AreaSelector
|
|
|
ref="areaSelector"
|
|
|
class="vip-sub-list-item"
|
|
|
+ v-show="moduleShow.areaSelector"
|
|
|
:class="{ 'pd-b0': upgradeTipShow }"
|
|
|
:showSearchInput="false"
|
|
|
:onlyProvince="true"
|
|
@@ -16,6 +17,7 @@
|
|
|
</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">
|
|
@@ -92,13 +94,13 @@ import CheckPhone from '@/components/coupon/CheckPhone.vue'
|
|
|
import BuySubmit from '@/components/coupon/BuySubmit.vue'
|
|
|
import Contrast from '@/views/vipsubscribe/components/Contrast.vue'
|
|
|
import { Dialog } from 'element-ui'
|
|
|
+import qs from 'qs'
|
|
|
|
|
|
import {
|
|
|
getGoodsPrice,
|
|
|
getSelectPrice,
|
|
|
getSVIPBuyInfo,
|
|
|
getUserAccountInfo,
|
|
|
- getUserPower,
|
|
|
createCommonOrder
|
|
|
} from '@/api/modules/'
|
|
|
|
|
@@ -119,20 +121,18 @@ export default {
|
|
|
data () {
|
|
|
return {
|
|
|
preTitle: '',
|
|
|
- buyType: 'buy', // buy/upgrade
|
|
|
+ buyType: 'buy', // buy/upgrade/renew
|
|
|
conf: {
|
|
|
selectorType: 'line',
|
|
|
maxAreaCount: 15
|
|
|
},
|
|
|
moduleShow: {
|
|
|
+ areaSelector: false,
|
|
|
specList: true,
|
|
|
coupon: false,
|
|
|
gift: false
|
|
|
},
|
|
|
phoneRegPass: false,
|
|
|
- powerInfo: {
|
|
|
- viper: true
|
|
|
- },
|
|
|
userInfo: {
|
|
|
phone: ''
|
|
|
},
|
|
@@ -181,6 +181,7 @@ export default {
|
|
|
tipText: ''
|
|
|
}
|
|
|
],
|
|
|
+ token: '', // 用于管理后台创建订单
|
|
|
computedPrice: {
|
|
|
total: 0,
|
|
|
discount: 0,
|
|
@@ -190,10 +191,11 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
oldVip () { // 是否是老版本超级订阅
|
|
|
- return !this.powerInfo.viper
|
|
|
+ const { upgrade } = this.buyInfo.buyset
|
|
|
+ return upgrade !== 1
|
|
|
},
|
|
|
upgradeTipShow () {
|
|
|
- if (this.buyType === 'buy') {
|
|
|
+ if (this.buyType === 'buy' || this.buyType === 'renew') {
|
|
|
return false
|
|
|
} else {
|
|
|
return !this.canUpgrade
|
|
@@ -203,7 +205,7 @@ export default {
|
|
|
const buyset = this.buyInfo.buyset
|
|
|
const selectCount = this.selectedCount
|
|
|
console.log(buyset, selectCount, this.oldVip)
|
|
|
- if (this.buyType === 'buy') {
|
|
|
+ if (this.buyType === 'buy' || this.buyType === 'renew') {
|
|
|
return false
|
|
|
} else {
|
|
|
if (buyset.areacount === -1) {
|
|
@@ -233,6 +235,7 @@ export default {
|
|
|
buyTypeText () {
|
|
|
const map = {
|
|
|
buy: '开通',
|
|
|
+ renew: '续费',
|
|
|
upgrade: '升级'
|
|
|
}
|
|
|
return map[this.buyType]
|
|
@@ -242,16 +245,28 @@ export default {
|
|
|
},
|
|
|
selectedCountInfo () {
|
|
|
const area = this.selectInfo.area
|
|
|
+ if (!area) {
|
|
|
+ return {
|
|
|
+ num: 0,
|
|
|
+ text: '',
|
|
|
+ detail: ''
|
|
|
+ }
|
|
|
+ }
|
|
|
const count = Object.keys(area).length
|
|
|
return {
|
|
|
+ num: count === 0 ? -1 : count,
|
|
|
text: (count === 0 || count > this.conf.maxAreaCount) ? '全国' : `${count}个省`,
|
|
|
detail: (count === 0 || count > this.conf.maxAreaCount) ? '全国' : Object.keys(area).join('、')
|
|
|
}
|
|
|
},
|
|
|
+ // 续费状态下,值为已购买的省份数量。
|
|
|
+ // 购买升级下,值为已选的省份数量
|
|
|
selectedCount () {
|
|
|
- const area = this.selectInfo.area
|
|
|
- const length = Object.keys(area).length
|
|
|
- return length === 0 ? -1 : length
|
|
|
+ if (this.buyType === 'renew') {
|
|
|
+ return this.buyInfo.buyset.areacount || 0
|
|
|
+ } else {
|
|
|
+ return this.selectedCountInfo.num
|
|
|
+ }
|
|
|
},
|
|
|
allPass () {
|
|
|
const basicReg = this.phoneRegPass && !this.noSelect
|
|
@@ -263,29 +278,47 @@ export default {
|
|
|
} else {
|
|
|
return basicReg && (this.canUpgrade || this.oldVip)
|
|
|
}
|
|
|
+ } else if (this.buyType === 'renew') {
|
|
|
+ return basicReg && this.computedPrice.pay > 0
|
|
|
} else {
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- created () {
|
|
|
+ async created () {
|
|
|
this.getType()
|
|
|
+ await this.getUserBuyInfo()
|
|
|
this.getGoodsPrice()
|
|
|
- this.getUserPower() // 获取最新的power
|
|
|
- this.getUserAccountInfo()
|
|
|
+ if (!this.token) {
|
|
|
+ // 有token时候可以不用请求getAccountInfo
|
|
|
+ this.getUserAccountInfo()
|
|
|
+ }
|
|
|
},
|
|
|
beforeRouteEnter (to, from, next) {
|
|
|
+ const map = {
|
|
|
+ buy: '开通',
|
|
|
+ renew: '续费',
|
|
|
+ upgrade: '升级'
|
|
|
+ }
|
|
|
const title = document.title
|
|
|
- let buyTypeText = '购买'
|
|
|
- if (to.query && to.query.type === 'upgrade') {
|
|
|
- buyTypeText = '升级'
|
|
|
+ const { type } = to.query || {}
|
|
|
+ if (type && map[type]) {
|
|
|
+ // 修改头部高亮
|
|
|
+ document.title = `${map[type]}超级订阅`
|
|
|
}
|
|
|
- // 修改头部高亮
|
|
|
- document.title = `${buyTypeText}超级订阅`
|
|
|
next(vm => {
|
|
|
vm.preTitle = title
|
|
|
})
|
|
|
},
|
|
|
+ beforeRouteUpdate (to, from, next) {
|
|
|
+ this.$nextTick(async () => {
|
|
|
+ this.getType()
|
|
|
+ await this.getUserBuyInfo()
|
|
|
+ this.getGoodsPrice()
|
|
|
+ this.getUserAccountInfo()
|
|
|
+ })
|
|
|
+ next()
|
|
|
+ },
|
|
|
beforeRouteLeave (to, from, next) {
|
|
|
document.title = this.preTitle
|
|
|
next()
|
|
@@ -298,16 +331,26 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
getType () {
|
|
|
- var type = this.$route.query.type
|
|
|
- var types = ['buy', 'upgrade']
|
|
|
+ var { type, token, phone } = this.$route.query
|
|
|
+ var types = ['buy', 'upgrade', 'renew']
|
|
|
if (types.includes(type)) {
|
|
|
this.buyType = type || types[0]
|
|
|
} else {
|
|
|
this.buyType = types[0]
|
|
|
}
|
|
|
+ if (token) {
|
|
|
+ this.token = token
|
|
|
+ }
|
|
|
+ if (phone) {
|
|
|
+ this.userInfo.phone = phone
|
|
|
+ }
|
|
|
if (this.buyType === 'upgrade') {
|
|
|
+ this.moduleShow.areaSelector = true
|
|
|
this.moduleShow.specList = false
|
|
|
- this.getUserBuyInfo()
|
|
|
+ } else if (this.buyType === 'renew') {
|
|
|
+ this.moduleShow.areaSelector = false
|
|
|
+ } else {
|
|
|
+ this.moduleShow.areaSelector = true
|
|
|
}
|
|
|
},
|
|
|
getInitSpec () {
|
|
@@ -333,18 +376,23 @@ export default {
|
|
|
init () {
|
|
|
if (this.buyType === 'upgrade') {
|
|
|
// this.specChange(this.specList[2])
|
|
|
+ this.getInitSpec()
|
|
|
this.specChange({})
|
|
|
+ } else if (this.buyType === 'renew') {
|
|
|
+ this.getInitSpec()
|
|
|
+ this.calcSpecPrice(this.selectedCount)
|
|
|
+ this.specIdActive = this.specList[0].id
|
|
|
} else {
|
|
|
- // 设置盛世选择器所有不选中
|
|
|
+ // 设置城市选择器所有不选中
|
|
|
this.$refs.areaSelector.content.setAllNoSelected()
|
|
|
// specIdActive改变会触发specChange
|
|
|
+ // 默认选中1年
|
|
|
this.specIdActive = this.specList[2].id
|
|
|
+ this.calcSpecPrice(this.selectedCount || 1)
|
|
|
}
|
|
|
- this.calcSpecPrice(1)
|
|
|
- this.getInitSpec()
|
|
|
},
|
|
|
async getGoodsPrice () {
|
|
|
- const priceInfo = await getGoodsPrice()
|
|
|
+ const priceInfo = await getGoodsPrice({ token: this.token })
|
|
|
const newPriceInfo = priceInfo.new
|
|
|
for (const key in newPriceInfo) {
|
|
|
this.$set(this.priceRules, key, newPriceInfo[key])
|
|
@@ -357,21 +405,86 @@ export default {
|
|
|
Object.assign(this.userInfo, data)
|
|
|
}
|
|
|
},
|
|
|
- async getUserPower () {
|
|
|
- const { data, error_code: code } = await getUserPower()
|
|
|
- if (code === 0) {
|
|
|
- Object.assign(this.powerInfo, data)
|
|
|
- }
|
|
|
- },
|
|
|
async getUserBuyInfo () {
|
|
|
- const { data, success } = await getSVIPBuyInfo()
|
|
|
- if (success && data) {
|
|
|
- Object.assign(this.buyInfo, data)
|
|
|
+ const { data: buyInfo, success } = await getSVIPBuyInfo({ token: this.token })
|
|
|
+ if (success && buyInfo) {
|
|
|
+ Object.assign(this.buyInfo, buyInfo)
|
|
|
this.selectInfo.area = this.buyInfo.area
|
|
|
this.$refs.areaSelector.setCitySelected(this.buyInfo.area)
|
|
|
- this.updatePrice()
|
|
|
+ // 页面重定向
|
|
|
+ this.redirectType(buyInfo)
|
|
|
+ const { buyset } = this.buyInfo
|
|
|
+ // 购买了全国的新超级订阅用户,升级不能再选择省份了
|
|
|
+ if (this.buyType === 'upgrade' && buyset && buyset.areacount === -1 && !this.oldVip) {
|
|
|
+ this.moduleShow.selectArea = false
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
+ showOldVipTip () {
|
|
|
+ // return this.$dialog({
|
|
|
+ // title: '提示',
|
|
|
+ // message: '超级订阅产品全面升级,为享受更多权益,请您先升级到最新版本后再进行续费。',
|
|
|
+ // className: 'j-confirm-dialog',
|
|
|
+ // messageAlign: 'left',
|
|
|
+ // showCancelButton: false,
|
|
|
+ // confirmButtonText: '我知道了'
|
|
|
+ // })
|
|
|
+ return this.$toast('超级订阅产品全面升级,为享受更多权益,请您先升级到最新版本后再进行续费。')
|
|
|
+ },
|
|
|
+ // 页面重定向
|
|
|
+ async redirectType (info) {
|
|
|
+ const { buyset, isvip, startTime: start, endTime: end } = info
|
|
|
+ const { path } = this.$route
|
|
|
+ const { redirected } = this.$route.query
|
|
|
+ if (redirected) return
|
|
|
+
|
|
|
+ const redirect = {
|
|
|
+ enable: false,
|
|
|
+ type: 'buy'
|
|
|
+ }
|
|
|
+
|
|
|
+ if (start && end && isvip) {
|
|
|
+ const nowStamp = Date.now()
|
|
|
+ const endStamp = end * 1000
|
|
|
+ if (endStamp > nowStamp) {
|
|
|
+ // 开通了,未过期
|
|
|
+ if (this.buyType === 'buy') {
|
|
|
+ redirect.enable = true
|
|
|
+ redirect.type = 'renew'
|
|
|
+ }
|
|
|
+ // buyset.upgrade=0为老超级订阅用户,只能升级,不能续费
|
|
|
+ if (buyset && buyset.upgrade !== 1 && this.buyType !== 'upgrade') {
|
|
|
+ redirect.enable = true
|
|
|
+ redirect.type = 'upgrade'
|
|
|
+ await this.showOldVipTip()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 开通了,过期了
|
|
|
+ if (this.buyType !== 'buy') {
|
|
|
+ redirect.enable = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 未开通
|
|
|
+ if (this.buyType !== 'buy') {
|
|
|
+ redirect.enable = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (redirect.enable) {
|
|
|
+ const routerQuery = this.$route.query
|
|
|
+ if (routerQuery.tip) {
|
|
|
+ delete routerQuery.tip
|
|
|
+ }
|
|
|
+ const query = {
|
|
|
+ ...routerQuery,
|
|
|
+ type: redirect.type, // 覆盖routerQuery中的type
|
|
|
+ redirect: 1
|
|
|
+ }
|
|
|
+ const url = `${path}?${qs.stringify(query)}`
|
|
|
+ this.$router.replace(url)
|
|
|
+ } else {}
|
|
|
+ },
|
|
|
onAreaChange (area) {
|
|
|
this.selectInfo.area = area
|
|
|
this.resetCouponList()
|
|
@@ -466,7 +579,10 @@ export default {
|
|
|
},
|
|
|
async updatePrice () {
|
|
|
const params = this.getSubmitParam()
|
|
|
- const { data, success } = await getSelectPrice(params)
|
|
|
+ if (this.token) {
|
|
|
+ params.token = this.token
|
|
|
+ }
|
|
|
+ const { errMsg, data, success } = await getSelectPrice(params)
|
|
|
if (success) {
|
|
|
this.computedPrice.total = data.original_price
|
|
|
this.computedPrice.pay = data.order_price
|
|
@@ -475,6 +591,9 @@ export default {
|
|
|
this.computedPrice.total = 0
|
|
|
this.computedPrice.pay = 0
|
|
|
this.computedPrice.discount = 0
|
|
|
+ if (errMsg && errMsg.includes('订阅周期')) {
|
|
|
+ this.$toast(errMsg)
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
getSubmitParam () {
|
|
@@ -508,6 +627,12 @@ export default {
|
|
|
area: JSON.stringify(selectArea),
|
|
|
orderType: 3
|
|
|
}
|
|
|
+ } else if (this.buyType === 'renew') {
|
|
|
+ return {
|
|
|
+ ...param,
|
|
|
+ time: this.specActiveItem.value,
|
|
|
+ orderType: 2
|
|
|
+ }
|
|
|
} else {
|
|
|
return {}
|
|
|
}
|
|
@@ -530,6 +655,7 @@ export default {
|
|
|
const t = {
|
|
|
product: 'VIP订阅',
|
|
|
productId: this.buyType === 'upgrade' ? 1015 : params.useProduct,
|
|
|
+ token: this.token,
|
|
|
data: {
|
|
|
type: type,
|
|
|
order_phone: this.userInfo.phone,
|
|
@@ -538,16 +664,18 @@ export default {
|
|
|
}
|
|
|
Object.assign(t.data, params)
|
|
|
return createCommonOrder(t)
|
|
|
- // if (this.buyType === 'buy') {
|
|
|
- // return createSVIPOrder(params)
|
|
|
- // } else if (this.buyType === 'upgrade') {
|
|
|
- // return svipUpgrade(params)
|
|
|
- // }
|
|
|
},
|
|
|
async submit () {
|
|
|
// eslint-disable-next-line
|
|
|
const { data, error_msg } = await this.submitXHR()
|
|
|
if (data) {
|
|
|
+ if (this.token) {
|
|
|
+ this.$toast('帮助用户下单成功')
|
|
|
+ setTimeout(() => {
|
|
|
+ history.back()
|
|
|
+ }, 1500)
|
|
|
+ return
|
|
|
+ }
|
|
|
const orderCode = data.order_code
|
|
|
if (data.needPay) {
|
|
|
window.open(`/front/subvip/orderPay/${orderCode}`)
|