|
@@ -17,7 +17,8 @@ var vm = new Vue({
|
|
|
ppend: 0,
|
|
|
areanum: 0, // 可调整地区次数
|
|
|
provincenum: 0, // 已购买省份数量
|
|
|
- area: {}
|
|
|
+ area: {},
|
|
|
+ simulatedAmount: false, // 模拟金额(购买时候进入,省份数量不足购买条件,默认展示1个月价格)
|
|
|
},
|
|
|
// 选择的省份数量
|
|
|
areaInfo: '', // 空字符串或者null表示未选择省份,空对象表示全国/provinceMaxCount
|
|
@@ -152,12 +153,16 @@ var vm = new Vue({
|
|
|
}
|
|
|
},
|
|
|
upgradeAreaText: function () {
|
|
|
- return this.upgradeAreaCount + '个省'
|
|
|
+ if (this.upgradeAreaCount === -1) {
|
|
|
+ return '全国'
|
|
|
+ } else {
|
|
|
+ return this.upgradeAreaCount + '个省'
|
|
|
+ }
|
|
|
},
|
|
|
- // 升级数量 = 选中数量 - 已购买数量
|
|
|
+ // 升级数量 = 选中数量 - 已购买数量 - 免费数量
|
|
|
upgradeAreaCount: function () {
|
|
|
var alreadyBuyCount = this.getAlreadyBuyCount()
|
|
|
- return this.selectAreaCount - alreadyBuyCount
|
|
|
+ return this.selectAreaCount - alreadyBuyCount - this.priceInfo.provinceFreeCount
|
|
|
},
|
|
|
// 选中的规格卡片info
|
|
|
selectedSpecItem: function () {
|
|
@@ -247,7 +252,10 @@ var vm = new Vue({
|
|
|
getUrlArea: function () {
|
|
|
var area = utils.getParam('area')
|
|
|
if (area) {
|
|
|
- this.areaInfo = JSON.parse(decodeURIComponent(area))
|
|
|
+ var areaInfo = JSON.parse(decodeURIComponent(area))
|
|
|
+ if (!Array.isArray(areaInfo)) {
|
|
|
+ this.areaInfo = areaInfo
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
getBuyType: function () {
|
|
@@ -463,6 +471,16 @@ var vm = new Vue({
|
|
|
sortPrice: function () {
|
|
|
var priceInfoArr = []
|
|
|
var buyAreaCount = this.buyAreaCount
|
|
|
+
|
|
|
+ if (this.buyType === 'buy') {
|
|
|
+ if (buyAreaCount <= 0) {
|
|
|
+ buyAreaCount = 1
|
|
|
+ this.alreadyBuyInfo.simulatedAmount = true
|
|
|
+ } else {
|
|
|
+ this.alreadyBuyInfo.simulatedAmount = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
this.specList.forEach(function (spec) {
|
|
|
var priceInfo = this.commonGetPrice(buyAreaCount, spec.cycleType)
|
|
|
spec.price = priceInfo.price
|
|
@@ -516,11 +534,12 @@ var vm = new Vue({
|
|
|
},
|
|
|
checkSubmitStatus: function (checkStatus) {
|
|
|
this.bottomConf.checkboxStatus = checkStatus
|
|
|
- return checkStatus && this.validatorPhonePass && this.bottomConf.initPrice
|
|
|
+ return checkStatus && this.validatorPhonePass && this.bottomConf.initPrice && !this.alreadyBuyInfo.simulatedAmount
|
|
|
},
|
|
|
// 保证mounted之后执行
|
|
|
checkConfirmButtonDisabled: function () {
|
|
|
- this.$refs.couponRef.submitStatus = !this.bottomConf.checkboxStatus
|
|
|
+ var status = this.bottomConf.checkboxStatus && this.validatorPhonePass && this.bottomConf.initPrice && !this.alreadyBuyInfo.simulatedAmount
|
|
|
+ this.$refs.couponRef.submitStatus = !status
|
|
|
},
|
|
|
// 调用此方法,即可检测当前页面表单是否满足条件(可计算出提交按钮是否可用)
|
|
|
checkStatus: function () {
|
|
@@ -563,13 +582,29 @@ var vm = new Vue({
|
|
|
data: data,
|
|
|
success: function (res) {
|
|
|
loading && loading.clear()
|
|
|
- if (res.error_code === 0 && res.data) {
|
|
|
- if (utils.isWeiXinBrowser) {
|
|
|
- history.replaceState({}, '', '/weixin/common/areaPack/orderDetail?order_code=' + res.data.orderCode);
|
|
|
- location.href = '/weixin/pay/checkout_areaPack?orderCode=' + res.data.orderCode
|
|
|
+ if (res.error_code === 0) {
|
|
|
+ if (res.data) {
|
|
|
+ if (utils.isWeiXinBrowser) {
|
|
|
+ history.replaceState({}, '', '/weixin/common/areaPack/orderDetail?order_code=' + res.data.orderCode);
|
|
|
+ location.href = '/weixin/pay/checkout_areaPack?orderCode=' + res.data.orderCode
|
|
|
+ } else {
|
|
|
+ history.replaceState({}, '', '/jyapp/common/areaPack/orderDetail?order_code=' + res.data.orderCode);
|
|
|
+ location.href = "/jyapp/pay/checkout_areaPack?orderCode=" + res.data.orderCode + '&from=' + _this.buyType
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ _this.showToast(res.error_msg)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (res.error_msg && res.error_msg.indexOf('超过') !== -1) {
|
|
|
+ var buyInfo = _this.alreadyBuyInfo
|
|
|
+ // 获取剩余周期
|
|
|
+ var lastCycle = getDateSub(buyInfo.ppstart, buyInfo.ppend)
|
|
|
+ var lastArr = []
|
|
|
+ if (lastCycle[0]) lastArr.push(lastCycle[0] + '年')
|
|
|
+ if (lastCycle[1]) lastArr.push(lastCycle[1] + '个月')
|
|
|
+ _this.showToast(`最长周期不可超过3年\n剩余周期:${lastArr.join('')}`)
|
|
|
} else {
|
|
|
- history.replaceState({}, '', '/jyapp/common/areaPack/orderDetail?order_code=' + res.data.orderCode);
|
|
|
- location.href = "/jyapp/pay/checkout_areaPack?orderCode=" + res.data.orderCode + '&from=' + _this.buyType
|
|
|
+ _this.showToast(res.error_msg)
|
|
|
}
|
|
|
}
|
|
|
},
|