|
@@ -3,6 +3,8 @@ var vm = new Vue({
|
|
|
el: '#app',
|
|
|
data: function () {
|
|
|
return {
|
|
|
+ endTime: '',
|
|
|
+ endDay: -1,
|
|
|
sessKey: '$data-area-pack-buy',
|
|
|
preferentialShow: false,
|
|
|
specTitleShow: false,
|
|
@@ -27,34 +29,38 @@ var vm = new Vue({
|
|
|
provinceMaxCount: 15, // 选择的大于15表示全国
|
|
|
month: {}
|
|
|
},
|
|
|
+ priceMap: {},
|
|
|
specActive: 1,
|
|
|
specList: [
|
|
|
{
|
|
|
cycleType: 1, // 月
|
|
|
- label: '1月',
|
|
|
- value: '1month',
|
|
|
+ label: '5个附件',
|
|
|
+ value: '1',
|
|
|
price: 0,
|
|
|
desc: '',
|
|
|
perDayPrice: 0,
|
|
|
- productId: 1131,
|
|
|
+ productId: 1141,
|
|
|
+ id: 5
|
|
|
},
|
|
|
{
|
|
|
cycleType: 2, // 季
|
|
|
- label: '1季',
|
|
|
- value: '3month',
|
|
|
+ label: '10个附件',
|
|
|
+ value: '2',
|
|
|
price: 0,
|
|
|
desc: '',
|
|
|
perDayPrice: 0,
|
|
|
- productId: 1132,
|
|
|
+ productId: 1142,
|
|
|
+ id: 10
|
|
|
},
|
|
|
{
|
|
|
cycleType: 3, // 年
|
|
|
- label: '1年',
|
|
|
- value: '1year',
|
|
|
+ label: '20个附件',
|
|
|
+ value: '3',
|
|
|
price: 0,
|
|
|
desc: '',
|
|
|
perDayPrice: 0,
|
|
|
- productId: 1133,
|
|
|
+ productId: 1143,
|
|
|
+ id: 20
|
|
|
}
|
|
|
],
|
|
|
bottomConf: {
|
|
@@ -190,7 +196,7 @@ var vm = new Vue({
|
|
|
},
|
|
|
},
|
|
|
created: function () {
|
|
|
- this.getBuyType()
|
|
|
+ this.getVipEndTime()
|
|
|
},
|
|
|
mounted: function () {
|
|
|
var restore = this.restoreState()
|
|
@@ -209,6 +215,56 @@ var vm = new Vue({
|
|
|
// }
|
|
|
},
|
|
|
methods: {
|
|
|
+ getMonthEndTime: function (date) {
|
|
|
+ var tempDate = new Date(date)
|
|
|
+ let month = tempDate.getMonth()
|
|
|
+ var new_year = tempDate.getFullYear(); //取当前的年份
|
|
|
+ var new_month = ++month; //取下一个月的第一天,方便计算(最后一天不固定)
|
|
|
+ if (month > 12) {
|
|
|
+ new_month -= 12; //月份减
|
|
|
+ new_year++; //年份增
|
|
|
+ }
|
|
|
+ var new_date = new Date(new_year, new_month, 1); //取当年当月中的第一天
|
|
|
+ return (new Date(new_date.getTime() - 1000 * 60 * 60 * 24));
|
|
|
+ },
|
|
|
+ getDayDiff: function (date1, date2, unit) {
|
|
|
+ var myDate1 = typeof date1 === 'string' && date1.includes('-') ? date1.replace(/-/g, '/') : date1;
|
|
|
+ var myDate2 = typeof date2 === 'string' && date2.includes('-') ? date2.replace(/-/g, '/') : date2;
|
|
|
+ var map = {
|
|
|
+ day: 1000 * 60 * 60 * 24,
|
|
|
+ hour: 1000 * 60 * 60,
|
|
|
+ minute: 1000 * 60,
|
|
|
+ second: 1000,
|
|
|
+ ms: 1,
|
|
|
+ };
|
|
|
+ return ((new Date(myDate2) - new Date(myDate1)) / (map[unit]));
|
|
|
+ },
|
|
|
+ getEndTime: function (vipEndTime) {
|
|
|
+ var nowDate = new Date().getTime()
|
|
|
+ var monthEndDate = this.getMonthEndTime(nowDate)
|
|
|
+ if (vipEndTime) {
|
|
|
+ var vipEndDate = new Date(vipEndTime)
|
|
|
+ if (vipEndDate.getTime() < monthEndDate.getTime()) {
|
|
|
+ monthEndDate = vipEndDate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var diffDay = this.getDayDiff(nowDate, monthEndDate.getTime(), 'day')
|
|
|
+ const result = Math.ceil(diffDay)
|
|
|
+ this.endTime = monthEndDate.pattern('yyyy.MM.dd')
|
|
|
+ this.endDay = result
|
|
|
+ },
|
|
|
+ getVipEndTime: function () {
|
|
|
+ $.ajax({
|
|
|
+ url: '/subscribepay/vipsubscribe/getSubBuyMsg',
|
|
|
+ type: 'GET',
|
|
|
+ success: function (res) {
|
|
|
+ console.log(res)
|
|
|
+ if (res && res.data && res.data.endTime) {
|
|
|
+ this.getEndTime(res.data.endTime * 1000)
|
|
|
+ }
|
|
|
+ }.bind(this)
|
|
|
+ })
|
|
|
+ },
|
|
|
showLoading: function () {
|
|
|
return this.$toast.loading({
|
|
|
duration: 0,
|
|
@@ -258,22 +314,6 @@ var vm = new Vue({
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- getBuyType: function () {
|
|
|
- var buyTypeList = ['buy', 'renew', 'upgrade']
|
|
|
- var buyType = utils.getParam('type')
|
|
|
- if (buyTypeList.indexOf(buyType) !== -1) {
|
|
|
- this.buyType = buyType
|
|
|
- }
|
|
|
- this.setBuyTypeInfo()
|
|
|
- },
|
|
|
- setBuyTypeInfo: function () {
|
|
|
- // buy购买, renew续费, upgrade升级
|
|
|
- if (this.buyType === 'renew') {
|
|
|
- $('.jy-app-header .header-title').text('续费省份订阅包')
|
|
|
- } else if (this.buyType === 'upgrade') {
|
|
|
- $('.jy-app-header .header-title').text('升级省份订阅包')
|
|
|
- } else {}
|
|
|
- },
|
|
|
getAlreadyBuyCount: function () {
|
|
|
var buyInfo = this.alreadyBuyInfo
|
|
|
if (!buyInfo) return 0
|
|
@@ -297,13 +337,18 @@ var vm = new Vue({
|
|
|
var _this = this
|
|
|
var loading = this.showLoading()
|
|
|
$.ajax({
|
|
|
- url: '/jypay/areaPack/price',
|
|
|
+ url: '/jypay/resourcePack/price',
|
|
|
type: 'POST',
|
|
|
+ data: {
|
|
|
+ 'product': 'attachmentDownPack'
|
|
|
+ },
|
|
|
success: function (res) {
|
|
|
loading && loading.clear()
|
|
|
- if (res) {
|
|
|
- Object.assign(_this.priceInfo, res)
|
|
|
- _this.getBuyInfo()
|
|
|
+ if (res && res.data) {
|
|
|
+
|
|
|
+ Object.assign(_this.priceMap, res.data)
|
|
|
+ // _this.getBuyInfo()
|
|
|
+ _this.getPrice()
|
|
|
}
|
|
|
},
|
|
|
error: function () {
|
|
@@ -470,23 +515,9 @@ 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
|
|
|
- spec.perDayPrice = priceInfo.perDayPrice
|
|
|
- spec.desc = '每天仅需' + priceInfo.perDayPrice + '元'
|
|
|
- priceInfoArr.push(priceInfo)
|
|
|
+ spec.price = this.priceMap[spec.id] / 100
|
|
|
this.renderGiftInfo(spec)
|
|
|
}.bind(this))
|
|
|
return priceInfoArr
|
|
@@ -497,7 +528,7 @@ var vm = new Vue({
|
|
|
if (this.buyType === 'buy' || this.buyType === 'renew') {
|
|
|
// 获取被选中的规格卡片info
|
|
|
var specItem = this.selectedSpecItem
|
|
|
- this.bottomConf.type = 'areaPack-' + specItem.value
|
|
|
+ this.bottomConf.type = 'filePack-' + specItem.value
|
|
|
p = specItem.price
|
|
|
} else {
|
|
|
p = this.getUpgradePrice()
|
|
@@ -557,19 +588,12 @@ var vm = new Vue({
|
|
|
},
|
|
|
submitOrder: function () {
|
|
|
var _this = this
|
|
|
- if (!this.areaInfo) return
|
|
|
var loading = this.showLoading()
|
|
|
- var orderTypeMap = {
|
|
|
- 'buy': 1,
|
|
|
- 'upgrade': 2,
|
|
|
- 'renew': 3
|
|
|
- }
|
|
|
var data = {
|
|
|
- price: this.bottomConf.initPrice * 10000 / 100,
|
|
|
- orderType: orderTypeMap[this.buyType],
|
|
|
- area: JSON.stringify(this.areaInfo),
|
|
|
- num: this.buyAreaCount, // 购买的数量
|
|
|
- unit: this.selectedSpecItem.cycleType, // 单位:1月 2季 3年
|
|
|
+ "product":"attachmentDownPack",
|
|
|
+ "data":{
|
|
|
+ "num": this.selectedSpecItem.id
|
|
|
+ },
|
|
|
order_phone: this.userInfo.phone,
|
|
|
lotteryId: this.$refs.couponRef.coupon.lotteryId,
|
|
|
useProduct: this.$refs.couponRef.getProductId(),
|
|
@@ -577,34 +601,31 @@ var vm = new Vue({
|
|
|
discountId: this.selectedSpecItem.discountId
|
|
|
}
|
|
|
$.ajax({
|
|
|
- url: '/jypay/areaPack/createOrder',
|
|
|
- type: 'POST',
|
|
|
- data: data,
|
|
|
+ url: '/jypay/resourcePack/createOrder',
|
|
|
+ contentType: "application/json;charset=UTF-8",
|
|
|
+ dataType: "json",
|
|
|
+ type: "post",
|
|
|
+ processData: false,
|
|
|
+ data: JSON.stringify(data),
|
|
|
success: function (res) {
|
|
|
loading && loading.clear()
|
|
|
- if (res.error_code === 0) {
|
|
|
- if (res.data) {
|
|
|
+ if (res.status === 1) {
|
|
|
+ if (res.order_code) {
|
|
|
if (utils.isWeiXinBrowser) {
|
|
|
- history.replaceState({}, '', '/weixin/common/areaPack/orderDetail?order_code=' + res.data.orderCode);
|
|
|
- location.href = '/weixin/pay/checkout_areaPack?orderCode=' + res.data.orderCode
|
|
|
+ history.replaceState({}, '', '/weixin/common/filePack/orderDetail?order_code=' + res.order_code);
|
|
|
+ location.href = '/weixin/pay/checkout_filePack?orderCode=' + res.order_code
|
|
|
} 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
|
|
|
+ history.replaceState({}, '', '/jyapp/common/filePack/orderDetail?order_code=' + res.order_code);
|
|
|
+ location.href = "/jyapp/pay/checkout_filePack?orderCode=" + res.order_code + '&from=' + _this.buyType
|
|
|
}
|
|
|
} else {
|
|
|
- _this.showToast(res.error_msg)
|
|
|
+ _this.showToast(res.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('')}`)
|
|
|
+ if (res.msg) {
|
|
|
+ _this.showToast(res.msg)
|
|
|
} else {
|
|
|
- _this.showToast(res.error_msg)
|
|
|
+ _this.showToast('请稍后重试')
|
|
|
}
|
|
|
}
|
|
|
},
|