|
@@ -115,24 +115,17 @@ var renew = {
|
|
|
this.price = price
|
|
|
coupon.updatePrice(this.price / 100)
|
|
|
},
|
|
|
- // 根据选中结果得到一个时间段的时间戳
|
|
|
+ // 根据选中结果得到续费了多长时间的字符串
|
|
|
getDuration: function (timeSelect) {
|
|
|
- var dStamp = 0
|
|
|
- var s = ''
|
|
|
- var perMonthStamp = 1000 * 60 * 60 * 24 * 30
|
|
|
+ var durationStr = ''
|
|
|
if (timeSelect[1] === 1) {
|
|
|
// 年
|
|
|
- dStamp = timeSelect[0] * 12 * perMonthStamp
|
|
|
- s = timeSelect[0] + '年'
|
|
|
+ durationStr = timeSelect[0] + '年'
|
|
|
} else if (timeSelect[1] === 2) {
|
|
|
// 月
|
|
|
- dStamp = timeSelect[0] * perMonthStamp
|
|
|
- s = timeSelect[0] + '个月'
|
|
|
- }
|
|
|
- return {
|
|
|
- stamp: dStamp,
|
|
|
- s: s
|
|
|
+ durationStr = timeSelect[0] + '个月'
|
|
|
}
|
|
|
+ return durationStr
|
|
|
},
|
|
|
// 计算续费后的日期区间
|
|
|
calcDuration: function (needSet) {
|
|
@@ -142,11 +135,10 @@ var renew = {
|
|
|
$('.select_cycle .duration').hide()
|
|
|
return
|
|
|
}
|
|
|
- var durationInfo = this.getDuration(this.timeSelect)
|
|
|
- var durationStamp = durationInfo.stamp // 续费时间段时间戳
|
|
|
- var durationStr = durationInfo.s // 续费时间段字符串
|
|
|
+ var durationStamp = getVipEndDate(this.timeSelect[1], this.timeSelect[0], endTime) - endTime // 续费时间段时间戳
|
|
|
+ var durationStr = this.getDuration(this.timeSelect) // 续费时间段字符串
|
|
|
var buyEndTimeString = new Date(endTime * 1000).pattern('yyyy年MM月dd日') // svip到期时间
|
|
|
- var renewEndTimeString = new Date(endTime * 1000 + durationStamp).pattern('yyyy年MM月dd日') //续费后到期时间
|
|
|
+ var renewEndTimeString = new Date((endTime + durationStamp) * 1000).pattern('yyyy年MM月dd日') //续费后到期时间
|
|
|
|
|
|
if (needSet) {
|
|
|
$('.select_cycle .month').text(durationStr)
|
|
@@ -183,17 +175,16 @@ var renew = {
|
|
|
return
|
|
|
}
|
|
|
var maxEndMonth = 36 // 最大续费36个月
|
|
|
- var durationInfo = this.getDuration(timeSelect)
|
|
|
- var durationStamp = durationInfo.stamp // 续费时间段时间戳
|
|
|
+ var durationStamp = getVipEndDate(timeSelect[1], timeSelect[0], endTime) - endTime // 续费时间段时间戳
|
|
|
|
|
|
// 最长订阅周期不可超过3年 ------------
|
|
|
var nowStamp = Math.floor(Date.now() / 1000)
|
|
|
// 已购买的套餐剩余月数
|
|
|
var lastMonthStamp = endTime - nowStamp
|
|
|
- var lastMonth = Math.ceil(lastMonthStamp / (60 * 60 * 24 * 30))
|
|
|
+ var lastMonth = Math.round(lastMonthStamp / (60 * 60 * 24 * 30))
|
|
|
// 续费后套餐剩余月数(需要加上原剩余月数lastMonth)
|
|
|
- var renewMonthTotalStamp = lastMonthStamp + (durationStamp / 1000)
|
|
|
- var renewMonthTotal = Math.ceil(renewMonthTotalStamp / (60 * 60 * 24 * 30))
|
|
|
+ var renewMonthTotalStamp = lastMonthStamp + durationStamp
|
|
|
+ var renewMonthTotal = Math.round(renewMonthTotalStamp / (60 * 60 * 24 * 30))
|
|
|
|
|
|
if (renewMonthTotal > maxEndMonth) {
|
|
|
var showTipText = '<div style="white-space: nowrap;">最长订阅周期不可超过3年</div>剩余周期:' + this.monthToYear(lastMonth).str
|
|
@@ -297,7 +288,7 @@ var renew = {
|
|
|
var data = {
|
|
|
userLotteryId :coupon.$refs.couponRef.coupon.userLotteryId,
|
|
|
lotteryId : coupon.$refs.couponRef.coupon.lotteryId,
|
|
|
- time : _this.getDuration(_this.timeSelect).s.trim(),
|
|
|
+ time : _this.getDuration(_this.timeSelect).trim(),
|
|
|
orderType: 5,
|
|
|
disWord :GetQueryString('disWord'),
|
|
|
price: _this.price
|