|
@@ -88,69 +88,28 @@ $(function () {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- //获取选择
|
|
|
- function getCount(area, industry) {
|
|
|
- if (industry[0] === "全部行业") industry = [];
|
|
|
- if (area["全国"]) area = {};
|
|
|
- //计算地区数量
|
|
|
- var count = {
|
|
|
- "areacount": -1, //省份数量
|
|
|
- "buyerclasscount": -1,
|
|
|
- "citys": [] //购买省份中城市数量
|
|
|
- };
|
|
|
- //行业
|
|
|
- if (industry.length != 0) {
|
|
|
- count.buyerclasscount = industry.length
|
|
|
- }
|
|
|
- //地区
|
|
|
- if (!$.isEmptyObject(area)) {
|
|
|
- count.areacount = 0;
|
|
|
- for (var i in area) {
|
|
|
- var citys = area[i];
|
|
|
- var thisLen = citys.length;
|
|
|
- if (thisLen === 0) {
|
|
|
- count.areacount++
|
|
|
- } else {
|
|
|
- count.citys.push(thisLen)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return count
|
|
|
- }
|
|
|
|
|
|
// 设置已选择的区域和行业
|
|
|
- /**
|
|
|
- * selected = {
|
|
|
- * areacount: 2,
|
|
|
- * buyerclasscount: 2,
|
|
|
- * citys: [1, 2, 3]
|
|
|
- * }
|
|
|
- */
|
|
|
function setSelectedAreaAndInd(selected) {
|
|
|
- // selected = {
|
|
|
- // areacount: 2,
|
|
|
- // buyerclasscount: 2,
|
|
|
- // citys: [1, 2, 3]
|
|
|
- // }
|
|
|
-
|
|
|
// 设置已选择区域
|
|
|
- var citySum = arrSum(selected.citys)
|
|
|
+ var citySum = arrSum(selected.citys);
|
|
|
var text = {
|
|
|
- p: selected.areacount + '个省',
|
|
|
- c: citySum + '个市',
|
|
|
- s: '分布在' + selected.citys.length + '个省内'
|
|
|
- }
|
|
|
+ p: selected.areacount === 0 ? '' : selected.areacount + '个省',
|
|
|
+ c: citySum === 0 ? '' : citySum + '个市',
|
|
|
+ s: selected.citys.length === 1 ? '' : '(分布在' + selected.citys.length + '个省内)'
|
|
|
+ };
|
|
|
|
|
|
if (selected.areacount === -1) {
|
|
|
$('.vip-body .area .selected-area').text('全国')
|
|
|
} else {
|
|
|
- if (selected.areacount === 0) {
|
|
|
- $('.vip-body .area .selected-area').text(text.c + '(' + text.s + ')')
|
|
|
- } else if (selected.citys.length === 0) {
|
|
|
- $('.vip-body .area .selected-area').text(text.p)
|
|
|
- } else {
|
|
|
- $('.vip-body .area .selected-area').text(text.p + '、' + text.c + '(' + text.s + ')')
|
|
|
+ var dunhao = '';
|
|
|
+ if (citySum !== 0 && selected.areacount !== 0) {
|
|
|
+ dunhao = '、'
|
|
|
+ }
|
|
|
+ if (citySum === 0 || citySum === 1) {
|
|
|
+ text.s = ''
|
|
|
}
|
|
|
+ $('.vip-body .area .selected-area').text(text.p + dunhao + text.c + text.s);
|
|
|
}
|
|
|
|
|
|
// 设置已选择行业
|
|
@@ -163,32 +122,28 @@ $(function () {
|
|
|
|
|
|
|
|
|
// 设置已购买的区域和行业
|
|
|
- /**
|
|
|
- * buyset = {
|
|
|
- * areacount: 2,
|
|
|
- * buyerclasscount: 2,
|
|
|
- * newcitys: [1, 2, 3]
|
|
|
- * }
|
|
|
- */
|
|
|
function setBuyAreaAndInd(buySet) {
|
|
|
// 设置已购买区域
|
|
|
var buySetCitySum = arrSum(buySet.newcitys)
|
|
|
var text = {
|
|
|
- p: buySet.areacount + '个省',
|
|
|
- c: buySetCitySum + '个市',
|
|
|
- s: '分布在' + buySet.newcitys.length + '个省内'
|
|
|
+ p: buySet.areacount === 0 ? '' : buySet.areacount + '个省',
|
|
|
+ c: buySetCitySum === 0 ? '' : buySetCitySum + '个市',
|
|
|
+ s: buySet.newcitys.length === 1 ? '' : '(分布在' + buySet.newcitys.length + '个省内)'
|
|
|
}
|
|
|
|
|
|
if (buySet.areacount === -1) {
|
|
|
$('.vip-body .area .buy-set-area').text('全国')
|
|
|
} else {
|
|
|
- if (buySet.areacount === 0) {
|
|
|
- $('.vip-body .area .buy-set-area').text(text.c + '(' + text.s + ')')
|
|
|
- } else if (buySet.newcitys.length === 0) {
|
|
|
- $('.vip-body .area .buy-set-area').text(text.p)
|
|
|
- } else {
|
|
|
- $('.vip-body .area .buy-set-area').text(text.p + '、' + text.c + '(' + text.s + ')')
|
|
|
+ var dunhao = '';
|
|
|
+ // 如果省或者市都不为0,则添加顿号
|
|
|
+ if (buySetCitySum !== 0 && buySet.areacount !== 0) {
|
|
|
+ dunhao = '、'
|
|
|
+ }
|
|
|
+ // 如果市等于0或者1,text.s不需要显示
|
|
|
+ if (buySetCitySum === 0 || buySetCitySum === 1) {
|
|
|
+ text.s = ''
|
|
|
}
|
|
|
+ $('.vip-body .area .buy-set-area').text(text.p + dunhao + text.c + text.s);
|
|
|
}
|
|
|
|
|
|
// 设置已选择行业
|
|
@@ -199,6 +154,29 @@ $(function () {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function showTimeOut(endTime, isTrail) {
|
|
|
+ var timeSub = endTime * 1000 - new Date().getTime();
|
|
|
+ console.log("timeSub", timeSub);
|
|
|
+ if (timeSub > 0 && timeSub < 60 * 60 * 24 * 1000 * 3) {
|
|
|
+ var hours = Math.floor(timeSub / (60 * 60 * 1000));
|
|
|
+ var day = Math.floor(hours / 24);
|
|
|
+ if (day > 0) {
|
|
|
+ if (!isTrail) {
|
|
|
+ $(".vip-header .expire-remind .remind-text").text("VIP订阅服务还有" + (day) + "天到期,请及时续费!");
|
|
|
+ } else {
|
|
|
+ $(".vip-header .expire-remind .remind-text").text("VIP订阅服务还有" + (day) + "天到期,请及时购买!");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!isTrail) {
|
|
|
+ $(".vip-header .expire-remind .remind-text").text("VIP订阅服务今天到期,请及时续费!");
|
|
|
+ } else {
|
|
|
+ $(".vip-header .expire-remind .remind-text").text("VIP订阅服务今天到期,请及时购买!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $(".vip-header .expire-remind").show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function clearSession() {
|
|
|
sessionStorage.removeItem("vip_index_read");
|
|
|
sessionStorage.removeItem('sub_vip_state');
|
|
@@ -251,6 +229,9 @@ $(function () {
|
|
|
pickerShow('.billing-list-container', false)
|
|
|
})
|
|
|
|
|
|
+ $('.close-expire-remind').on("click", function () {
|
|
|
+ $(".expire-remind").hide();
|
|
|
+ });
|
|
|
// 阅读并接受协议前的模拟checkbox点击事件
|
|
|
if (sessionStorage.getItem("vip_index_read") == "1") {
|
|
|
$('.checkbox').addClass("checked")
|
|
@@ -463,22 +444,30 @@ $(function () {
|
|
|
if (isChecked) {
|
|
|
$('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active')
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ //提交请求
|
|
|
+ $('.vip-footer .button-r.confirm').on('click', function () {
|
|
|
+ $(this).attr("disabled", "disabled");
|
|
|
+ doSubmit();
|
|
|
+ $(this).removeAttr("disabled");
|
|
|
+ });
|
|
|
// 以下数据交互 -------------------
|
|
|
// 定义全部变量state
|
|
|
- var globalState = {}
|
|
|
+ var globalState = {};
|
|
|
var changeTime = [];
|
|
|
var submitPrice = 0;
|
|
|
|
|
|
function init(state) {
|
|
|
// init 已选择的区域和行业
|
|
|
- var selectedAreaAndInd = getCount(state.area, state.industry);
|
|
|
+ var selectedAreaAndInd = getBuySet(state.area, state.industry);
|
|
|
setSelectedAreaAndInd(selectedAreaAndInd);
|
|
|
// 初始化,已购买的城市和行业
|
|
|
setBuyAreaAndInd(state.buyset);
|
|
|
-
|
|
|
+ //是否提示即将到期
|
|
|
+ showTimeOut(state.endTime, state.isTrial);
|
|
|
var dEnd;
|
|
|
var change = sessionStorage.getItem("vip_change_time");
|
|
|
var endflag = state.endTime;
|
|
@@ -511,7 +500,7 @@ $(function () {
|
|
|
$('.body-item.cycle .buy-cycle').text(sDuration);
|
|
|
|
|
|
// 初始化关键词
|
|
|
- if (state.items.lenght === 0) {
|
|
|
+ if (state.items.length === 0) {
|
|
|
$('.body-item.keywords .keywords-text').text('未分类')
|
|
|
} else {
|
|
|
var arr = []
|
|
@@ -546,7 +535,9 @@ $(function () {
|
|
|
|
|
|
//试用不展示续费
|
|
|
if (!state.isTrial) {
|
|
|
- $(".vip-header").show();
|
|
|
+ $(".vip-header .renew").show();
|
|
|
+ } else {
|
|
|
+ $(".vip-header .trail").show();
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -642,16 +633,8 @@ $(function () {
|
|
|
})
|
|
|
} else {
|
|
|
getDataWitXHR()
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- //提交请求
|
|
|
- $('.vip-footer .button-r.confirm').on('click', function () {
|
|
|
- $(this).attr("disabled", "disabled");
|
|
|
- doSubmit();
|
|
|
- $(this).removeAttr("disabled");
|
|
|
- })
|
|
|
-
|
|
|
|
|
|
//保存 or 升级
|
|
|
var submited = false;
|
|
@@ -673,7 +656,20 @@ $(function () {
|
|
|
"price": submitPrice
|
|
|
}, function (r) {
|
|
|
if (r.success) {
|
|
|
- onBridgeReady(JSON.parse(r.data.res), r.data.code);
|
|
|
+ if (r.data.needPay) {
|
|
|
+ //创建支付订单
|
|
|
+ onBridgeReady(JSON.parse(r.data.res), r.data.code);
|
|
|
+ } else {
|
|
|
+ //订阅修改
|
|
|
+ if (r.data.doSuccess) {
|
|
|
+ window.history.go(-1);
|
|
|
+ } else {
|
|
|
+ weui.toast('修改保存失败', {
|
|
|
+ duration: 1500,
|
|
|
+ className: 'jy-toast',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}, false);
|
|
|
}
|