123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326 |
- var subNode = new Vue({
- delimiters: ['${', '}'],
- el: '#vip-body',
- components: {
- subComponent: subComponent
- },
- data: function() {
- return {
- linkObj: {
- area: '/front/vipsubscribe/toChangeArea?header=save',
- industry: '/front/vipsubscribe/toChangeIndustry?header=save',
- keyword: '/front/vipsubscribe/toSetKeyWordPage',
- infotype: '/front/vipsubscribe/toSetInfoTypePage',
- resultview: '/front/vipsubscribe/toVIPViewPage',
- pushsetting: '/front/setting/push_detail?header=超级订阅推送设置&type=super_subscribe'
- },
- initData: {},
- userAreaNum: 1, // 用户修改地区剩余次数
- userType: false, // 用户是否为付费用户
- userAreaAllNum: 1, // 用户可修改地区总次数
- subscribeTime: '', // 用户订阅的时间
- vSwitch:'', // 用户版本权限
- }
- },
- created () {
- this.getUserSubscribe()
- this.getUserType()
- },
- methods: {
- superOrderTemplateMounted () {
- $('#pushResultPreview').attr('data-cl-event', 'c_wx_preview_buttonclick')
- },
- // 点击广告跳转超级订阅落地页
- toPaySupSub: function() {
- if (this.vSwitch !== 'v') {
- var href = '/front/vipsubscribe/introducePage'
- location.href = href
- }
-
- },
- // 得到用户是否购买省份包
- getUserSubscribe: function () {
- let _this = this
- $.ajax({
- url: '/publicapply/free/subscribe',
- type: 'POST',
- success: function (res) {
- _this.userAreaNum = res.data.areanum
- _this.userType = res.data.provincenum === 0 ? false : true
- _this.userAreaAllNum = res.data.areanum + res.data.provincenum
- // _this.$emit('UserSubscribe',res)
- _this.subscribeTime = new Date(res.data.ppstart * 1000).pattern('yyyy年MM月dd日') + "-" + new Date(res.data.ppend * 1000).pattern('yyyy年MM月dd日')
- _this.initdata = res.data
- }
- })
- },
- // 省份订阅包续费
- renewBtn: function () {
- location.href = '/areaPack/wx/page/buy?type=renew'
- },
- // 省份订阅包升级
- updateBtn: function () {
- location.href = '/areaPack/wx/page/buy?type=upgrade'
- },
- // 判断用户权限版本
- getUserType: function (data) {
- let _this = this
- $.ajax({
- type: 'POST',
- url: '/publicapply/subscribe/vipSwitch',
- data: {
- vt:data || ''
- },
- success: function(res) {
- if (res.data.vt !== 'v' ) {
- _this.vSwitch = 'f'
- } else {
- _this.vSwitch = 'v'
- }
- }
- })
- }
- }
- })
- function showGiveStatus (t) {
- if (t) {
- $(".banner-ad-box").hide()
- $("#giveTimeBox").attr('data-new-year', 'true')
- if ($(".try-seven").is(':visible')) {
- $(".banner-ad-box.trial").show()
- } else {
- $(".banner-ad-box.update").show()
- }
- // $(".banner-ad-box").css('display', 'flex')
- /*$("#giveTimeBox").addClass('hasDoubleEleven')
- $('.discount-button').show().on('click', function () {
- var details = $('.discount-details')
- if (details.is(':hidden')) {
- $('.discount-details').show()
- $(this).children('.icon-arrow').addClass('up')
- } else {
- $('.discount-details').hide()
- $(this).children('.icon-arrow').removeClass('up')
- }
- })
- $(".j-icon.icon-del-grey.cancel").on('click', function () {
- $('.weui-mask').trigger('click')
- })*/
- } else {
- /*$("#giveTimeBox").removeClass('hasDoubleEleven')
- $(".origin-price").hide()*/
- $(".banner-ad-box").hide()
- }
- }
- // @NewYearMarketing 2021/1/25
- getNewYearMarketing()
- function getNewYearMarketing () {
- $.ajax({
- url: '/getJson/NewYearMarketing?t=' + new Date().getTime(),
- async: false,
- success: function (r) {
- if (r && r.status) {
- showGiveStatus(true)
- }
- }
- })
- }
- // 拦截获取价格接口读取11.11活动信息
- /*$.ajaxSetup({
- complete:function(XMLHttpRequest,textStatus){
- if (this.url.indexOf('/subscribepay/vipsubscribe/getPrice') !== -1) {
- if (textStatus === 'success') {
- var data = XMLHttpRequest.responseJSON
- if (data && data.isActiving && data.isWritten === 0) {
- showGiveStatus(true)
- } else {
- showGiveStatus(false)
- }
- }
- }
- }
- });*/
- $(function () {
- /* vue 代码 start 提交订单 */
- // var coupon = new Vue({
- // el: '#coupon-vue',
- // data: function () {
- // return {
- // type: 'vip-update',
- // initPrice: 0, // 原价
- // realPrice: 0, // 实付价
- // checkboxStatus: false, // checkbox状态
- // submitStatus: true, // 提交按钮状态
- // links: [
- // {
- // text: '《剑鱼标讯线上购买与服务条款》',
- // url: '/front/staticPage/wx-serviceterms.html',
- // event: this.readEvent
- // }
- // ],
- // buttons: {
- // submit: this.submitOrder,
- // cancel: this.cancelEvent
- // },
- // }
- // },
- // mounted () {
- // this.init()
- // },
- // methods: {
- // // 更新价格相关
- // updatePrice: function (before) {
- // console.log( '原价:' + before)
- // this.initPrice = before;
- // // 调用子组件查询最优卡券
- // this.$refs.couponRef.getCoupon();
- // },
- // // 初始化及回显相关
- // init: function () {
- // if (sessionStorage.getItem("vip_index_read") === "true") {
- // this.checkboxStatus = true
- // this.$refs.couponRef.submitStatus = false
- // } else {
- // this.checkboxStatus = false
- // this.$refs.couponRef.submitStatus = true
- // }
- // },
- // // 勾选阅读协议
- // updateS: function(data) {
- // data.callback(this.checkSubmitStatus(data.check))
- // },
- // // 校验checkbox
- // checkSubmitStatus: function (checkStatus) {
- // if(checkStatus) {
- // $('.checkbox').addClass("checked");
- // } else {
- // $('.checkbox').removeClass("checked");
- // }
- // $('.vip-footer.upgrade .confirm').prop('disabled', !checkStatus);
- // sessionStorage.setItem("vip_index_read", checkStatus ? true : false);
- // return sessionStorage.getItem("vip_index_read") == 'true';
- // },
- // // 阅读协议点击事件
- // readEvent: function () {},
- // // 点击优惠券跳转存储当前页面数据
- // savePageData: function () {
- // sessionStorage.setItem('index_read_cache', '0');
- // },
- // cancelEvent: function() {
- // $('.weui-mask').trigger('click')
- // window.history.back();
- // },
- // // 订单提交事件
- // submitOrder: function () {
- // doSubmit()
- // }
- // }
- // })
- // 清除商品规格当前选择
- sessionStorage.removeItem("vip-cur-select-size")
- // 清除商品优惠券当前选择
- sessionStorage.removeItem("vip-cur-select-coupon")
- sessionStorage.removeItem("$select-coupon")
- /* vue 代码 end */
- //项目匹配开关
- var checkedflag = true;
- function setprojectmatch(index) {
- if (checkedflag) {
- checkedflag = false;
- $.post("/subscribepay/afterPay/setUserInfo", {pageType: "projectMatch", pmindex: index}, function (r) {
- if (r.flag) {
- checkedflag = true;
- reqData.projectmatch = index;
- sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData))
- }
- })
- }
- }
- function setMatchway(index) {
- $.post("/subscribepay/afterPay/setUserInfo", {pageType: "saveSeniorset", matchtype: index}, function (r) {
- if (r.flag) {
- reqData.matchway = index;
- sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData))
- }
- })
- }
- var checkedflag_other = true; //其他采购单位开关
- function setotherbuyerclass(index) {
- if (checkedflag_other) {
- checkedflag_other = false;
- $.post("/subscribepay/afterPay/setUserInfo", {pageType: "other_buyerclass", other: index}, function (r) {
- if (r.flag) {
- checkedflag_other = true;
- reqData.otherbuyerclass = index;
- sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData))
- }
- })
- }
- }
- function flushSubtotal(list) {
- var returnHtml = "";
- for (var i = 0; i < list.length; i++) {
- var showTime = new Date(list[i].startTime * 1000).pattern('yyyy年MM月dd日') + "-" + new Date(list[i].endTime * 1000).pattern('yyyy年MM月dd日');
- var typeName = "";
- if (list[i].type === 1) {
- typeName = "续费"
- } else if (list[i].type === 0) {
- typeName = "升级"
- }
- var showArea = "";
- if (list[i].buyset.areacount === -1) {
- showArea = "全国"
- } else {
- if (list[i].buyset.areacount > 0) {
- showArea = list[i].buyset.areacount + "个省";
- }
- if (list[i].buyset.citys.length > 0) {
- var cityCount = 0;
- for (var j = 0; j < list[i].buyset.citys.length; j++) {
- cityCount += list[i].buyset.citys[j];
- }
- if (list[i].buyset.areacount > 0) showArea += "、";
- showArea += cityCount + "个市";
- if (list[i].buyset.citys.length > 1) {
- showArea += "(分布在" + list[i].buyset.citys.length + "个省内)"
- }
- }
- }
- var industryShow = "";
- if (list[i].buyset.buyerclasscount === -1) {
- industryShow = "全行业"
- } else {
- industryShow = list[i].buyset.buyerclasscount + "个行业";
- }
- returnHtml += "<li class=\"list-item\">"
- + "<div class=\"item-top\">"
- + "<div class=\"item-header\">"
- + "<span class=\"header-label\">有效日期:</span>"
- + "<span class=\"header-content ellipsis\">" + showTime + "</span>"
- + "</div>"
- + "<div class=\"item-body\">"
- + "<div class=\"b-item body-area\">"
- + "<div class=\"body-area-title text-title\">区域</div>"
- + "<div class=\"body-area-sub\">" + showArea + "</div>"
- + "</div>"
- + "<div class=\"b-item body-industry\">"
- + "<div class=\"body-industry-title text-title\">采购单位行业</div>"
- + "<div class=\"body-industry-sub\">" + industryShow + "</div>"
- + "</div>";
- if (typeName != "") {
- returnHtml += "<div class=\"vp-type\">"
- + "<div class=\"vp-type-text\">" + typeName + "</div>"
- + "</div>"
- }
- returnHtml += "</div>"
- + "</div>"
- + "<div class=\"item-footer\">"
- + "<span class=\"footer-label\">小计:</span>"
- + "<span class=\"footer-content text-title\">¥" + formatMoney(list[i].price) + "</span>"
- + "</div>"
- + "</li>"
- }
- $(".list-content").html(returnHtml);
- }
- function getDataWitXHR() {
- $DoPost('/subscribepay/vipsubscribe/getSubBuyMsg', {}, function (res) {
- if (!res.success) return;
- if(!res.data.industry) {
- res.data.industry = []
- }
- res.data.oldArea = res.data.area;
- res.data.oldIndustry = res.data.industry;
- var globalStateStr = JSON.stringify(res.data);
- sessionStorage.setItem('sub_vip_state', globalStateStr);
- sessionStorage.setItem('vip_index_read', true);
- globalState = JSON.parse(globalStateStr);
- reqData = JSON.parse(globalStateStr);
- sessionStorage.removeItem('industryNull')
- sessionStorage.removeItem('areaNull')
- subNode.initData = res.data
- init(res.data)
- })
- }
- // 设置已选择的区域和行业
- function setSelectedAreaAndInd(selected) {
- // buySet = {
- // areacount: 2,
- // buyerclasscount: 2,
- // newcitys: []
- // }
- // 设置已选择区域
- var citySum = arrSum(selected.citys);
- var text = {
- 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 {
- 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);
- }
- // 设置已选择行业
- if (selected.buyerclasscount === -1) {
- $('.vip-body .industry .selected-industry').text('全行业')
- } else {
- $('.vip-body .industry .selected-industry').text(selected.buyerclasscount + '个行业')
- }
- }
- // 设置已购买的区域和行业
- function setBuyAreaAndInd(buySet) {
- // 设置已购买区域
- var buySetCitySum = arrSum(buySet.newcitys)
- var text = {
- 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 {
- 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);
- }
- // 设置已选择行业
- if (buySet.buyerclasscount === -1) {
- $('.vip-body .industry .buy-set-industry').text('全行业')
- } else {
- $('.vip-body .industry .buy-set-industry').text(buySet.buyerclasscount + '个行业')
- }
- }
- function showTimeOut(endTime, isTrail) {
- if (!isTrail) {
- $('.vip-header .expire-remind .remind-link').attr('href', '/front/vipsubscribe/vipsubscribe_renew').text('去续费')
- } else {
- $('.vip-header .expire-remind .remind-link').attr('href', '/front/vipsubscribe/vipsubscribe_new').text('去购买')
- }
- var timeSub = endTime * 1000 - new Date().getTime();
- 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) {
- $(".expire-remind .remind-text").text("超级订阅服务还有" + (day + 1) + "天到期,请及时续费!");
- } else {
- $(".expire-remind .remind-text").text("超级订阅服务还有" + (day + 1) + "天到期,请及时购买!");
- }
- } else {
- if (!isTrail) {
- $(".expire-remind .remind-text").text("超级订阅服务今天到期,请及时续费!");
- } else {
- $(".expire-remind .remind-text").text("超级订阅服务今天到期,请及时购买!");
- }
- }
- $(".expire-remind").show();
- }
- }
- function arrSum(arr) {
- var sum = 0
- arr.forEach(function (item, i) {
- sum += item
- })
- return sum
- }
- // picker的显示隐藏
- function pickerShow(selector, f) {
- if (f) {
- // 添加进场动画,并显示
- $(selector).find('.weui-mask').removeClass('weui-animate-fade-out').addClass('weui-animate-fade-in')
- $(selector).find('.weui-picker').removeClass('weui-animate-slide-down').addClass('weui-animate-slide-up')
- $(selector).show(300);
- } else {
- // 添加离场动画,并隐藏
- $(selector).find('.weui-mask').removeClass('weui-animate-fade-in').addClass('weui-animate-fade-out')
- $(selector).find('.weui-picker').removeClass('weui-animate-slide-up').addClass('weui-animate-slide-down')
- $(selector).hide(300);
- }
- }
- // 其他采购单位行业问号点击事件
- $('.other .icon-bangzhu').on('click', function () {
- var str = '每条信息的采购单位行业属性由机器自动识别,会存在少数无法识别的情况,此时将归类为“其它”。(注:当采购单位行业选择为全部时,关闭无效)'
- weui.alert(str, {
- title: '“其它”采购单位',
- className: 'jy-alert',
- buttons: [{
- label: '我知道了'
- }]
- });
- })
- // 计算标准点击事件
- $('.billing-list-btn').on('click', function () {
- pickerShow('.billing-list-container', true)
- })
- // 计算标准隐藏
- $('.billing-list-container .dialog_hd__close').on('click', function () {
- pickerShow('.billing-list-container', false)
- })
- $('.weui-mask').on('click', function () {
- pickerShow('.billing-list-container', false)
- $('.coupon-picker').hide()
- $('.discount-details').hide()
- $('.discount-button .icon-arrow').removeClass('up')
- })
- $('body').on('click', '.jy-dialog .weui-mask', function () {
- pickerShow('.jy-dialog', false)
- })
- $('.close-expire-remind').on("click", function () {
- $(".expire-remind").hide();
- });
- // 阅读并接受协议前的模拟checkbox点击事件
- if (sessionStorage.getItem("vip_index_read") === "true") {
- $('.checkbox').addClass("checked");
- $('.vip-footer.upgrade .confirm').prop('disabled', false);
- }
- $('.checkbox').on('click', function () {
- $(this).toggleClass('checked');
- var state = $(this).hasClass('checked');
- $('.vip-footer.upgrade .confirm').prop('disabled', !state);
- sessionStorage.setItem("vip_index_read", state ? true : false);
- });
- if (sessionStorage.liveActiveCode_new === "jianyu360") {
- $('.coupon-code-tx .keywords-text').text("支付成功赠送30天订阅周期");
- $('.coupon-picker .weui-input').val("jianyu360");
- $('.coupon-code-tx').off('click');
- }
- var $dialog;
- //保存取消提示 module 1 修改 2升级 3续费 4购买
- function cancelTip(module) {
- var content = "";
- var labName = "";
- var title = "";
- if (module === 1) {
- content = "所选订阅设置已做修改,返回后修改的设置将不做保存。";
- labName = "保存修改";
- title = "";
- } else if (module === 2) {
- content = "所选订阅设置已超出购买范围,升级后方才生效,返回后修改的设置将不做保存。";
- labName = "立即升级";
- title = "并升级";
- } else if (module === 3) {
- content = "所选订阅设置已超出购买范围,续费后方才生效,返回后修改的设置将不做保存。";
- labName = "立即续费";
- } else {
- content = "所选订阅设置已超出试用范围,购买后方才生效,返回后修改的设置将不做保存。";
- labName = "立即购买";
- title = "去购买";
- }
- $dialog = weui.dialog({
- title: '保存修改' + title,
- content: content,
- className: 'jy-dialog',
- buttons: [
- {
- label: '不保存',
- type: 'default',
- onClick: function () {
- clearSessionStorage();
- window.history.go(-1);
- window.location.reload();
- }
- },
- {
- label: labName,
- type: 'primary',
- onClick: function () {
- // doSubmit();
- // $('.vip-footer .button-r.confirm').trigger('click')
- // coupon.submitOrder()
- }
- }
- ]
- });
- }
- //展示订阅周期时间
- function flushShowTime(isTrial, changeValue, startValue, endValue) {
- if (isTrial) {
- sessionStorage.removeItem("vip_trial_buy");
- }
- var dEnd;
- if (isTrial && changeValue) {
- // 初始化订阅周期
- endValue = new Date().getTime() / 1000;
- startValue = new Date().getTime() / 1000;
- }
- if (changeValue) {
- var afterEndTime;
- if (isTrial) {
- $(".cycle .tip").text("购买订阅周期" + changeValue).show();
- } else {
- $(".cycle .tip").text("延长订阅周期" + changeValue).show();
- }
- if (changeValue.indexOf("月") > -1) {
- var monthNum = parseInt(changeValue.replace("个月", ""));
- afterEndTime = getVipEndDate(2, monthNum, endValue);
- changeTime = [monthNum, 2]
- } else {
- var yearNum = parseInt(changeValue.replace("年", ""));
- afterEndTime = getVipEndDate(1, yearNum, endValue);
- changeTime = [yearNum, 1]
- }
- dEnd = new Date(afterEndTime * 1000).pattern('yyyy年MM月dd日');
- } else {
- dEnd = new Date(endValue * 1000).pattern('yyyy年MM月dd日')
- }
- var dStart = new Date(startValue * 1000).pattern('yyyy年MM月dd日');
- var sDuration = dStart + ' - ' + dEnd;
- $('.cycle .buy-cycle').text(sDuration);
- }
- function initCycleSelector() {
- $('.vip-body .cycle').on('click', function () {
- pickerShow('#time_cycle', true)
- })
- // 打开dialog
- $('#time_cycle .weui-mask').on('click', function () {
- pickerShow('#time_cycle', false)
- })
- // 关闭dialog
- $('#time_cycle .box_hd .cancel').on('click', function () {
- pickerShow('#time_cycle', false)
- })
- // 选择完成(确定)按钮的点击事件
- $('#enter_period').on('click', function () {
- var checkedValue = $('#time_cycle input:radio[name="time"]:checked').val();
- var result = null
- if (checkedValue == 'month') {
- result = $('#number_box_month .month_number').text() + '个月'
- } else if (checkedValue == 'year') {
- result = $('#number_box_year span.active').attr('data-id') + '年'
- }
- console.log(result)
- $('.vip-body .extend-cycle').show().text('延长订阅周期' + result)
- pickerShow('#time_cycle', false)
- })
- // 1. 对订阅时间选择的input绑定点击事件
- $('#time_cycle input:radio[name="time"]').on('click', function (e) {
- // 解除确认按钮的锁定
- $('#time_cycle .form-btn button').removeAttr('disabled')
- if ($(e.target).hasClass('monthly')) {
- // 按月订阅
- $('#number_box_month').addClass('active');
- $('#number_box_year span').removeClass('active');
- } else {
- // 按年订阅
- $('#number_box_month').removeClass('active');
- // $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active');
- }
- })
- /* --------控制月份number_box的事件 点击加减号触发的事件------- */
- $('#number_box_month').on('click', 'button', function (e) {
- // 点击加减号让input radio选中
- $("#monthly").prop('checked', true);
- $('#yearly').prop('checked', false);
- $('.number_box span').removeClass('active')
- $('#number_box_month').addClass('active');
- var $number = $('#number_box_month span.month_number');
- var $monthlyInput = $('#monthly');
- // 未整理的data数组,里面的值都是字符串
- var preData = e.delegateTarget.dataset
- var currentNum = parseInt($number.text());
- var data = {};
- // 把字符串转换成数字
- for (var i in preData) {
- data[i] = preData[i] - 0
- }
- if (!$monthlyInput.prop('checked')) {
- return
- }
- // 判断是点击的是+ 还是-
- if ($(e.target).hasClass('add') || $(e.currentTarget).hasClass('add')) {
- // 点的+
- // currentNum = currentNum >= 12 ? 12 : currentNum + 1;
- currentNum = currentNum >= data.numboxMax ? data.numboxMax : (currentNum + data
- .numboxStep);
- } else {
- // 点的-
- // currentNum = currentNum <= 1 ? 1 : currentNum - 1;
- currentNum = currentNum <= data.numboxMin ? data.numboxMin : (currentNum - data
- .numboxStep);
- }
- $number.text(currentNum)
- var price = (5.8 * currentNum).toFixed(1);
- $('.computed_price').html(price)
- var firstButton = $('#number_box_month button:first')
- var lastButton = $('#number_box_month button:last')
- if (currentNum >= 10) {
- $('.profit_tips').show()
- } else {
- $('.profit_tips').hide()
- }
- // 如果为操作后的结果为1,则锁定减号按钮
- if (currentNum === data.numboxMin) {
- firstButton.attr('disabled', true)
- } else {
- firstButton.removeAttr('disabled')
- }
- // 如果为操作后的结果为12,则锁定加号按钮
- if (currentNum === data.numboxMax) {
- lastButton.attr('disabled', true)
- } else {
- lastButton.removeAttr('disabled')
- }
- })
- /* -------- 控制年份number_box的事件 点击1年 2年 3年触发的事件------- */
- $('#number_box_year').on('click', 'span', function (e) {
- $('#number_box_month').removeClass('active');
- console.log(e.target.dataset.id)
- var id = e.target.dataset.id;
- $('.profit_tips').hide()
- $(this).addClass('active').siblings().removeClass('active')
- $('#yearly').prop('checked', true);
- $("#monthly").prop('checked', false);
- // 渲染结果 保留一位小数
- var result = (Number(id) * 58).toFixed(1);
- $('.computed_price').html(result)
- })
- /* -------- 选择按月订阅 radio触发的事件------- */
- $('#monthly').on('change', function (e) {
- var isChecked = $(this).is(':checked')
- var val = $('.month_number').text();
- if (val >= 10) {
- $('.profit_tips').show()
- }
- if (!isChecked) {
- $('#number_box_month button').attr('disabled', true)
- } else {
- $('#number_box_month button').removeAttr('disabled')
- }
- if (val === 1) {
- $('#number_box_month button:eq(0)').prop('disabled', true)
- }
- if (val === 12) {
- $('#number_box_month button:eq(1)').prop('disabled', true)
- }
- var result = (Number(val) * 5.8).toFixed(1);
- $('.computed_price').html(result)
- })
- /* -------- 选择按年订阅 radio触发的事件------- */
- $('#yearly').on('change', function (e) {
- $('.profit_tips').hide()
- // console.log($(this).is(':checked'))
- var isChecked = $(this).is(':checked')
- // 按年订阅默认选择1年
- var val = 1;
- $('.computed_price').html(Number(val) * 58);
- 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 changeTime = [];
- var submitPrice = 0;
- var selectTime = "";
- function init(state) {
- checkmerge(state.industry, state.isread)
- // init 已选择的区域和行业
- // var selectedAreaAndInd = getBuySet(state.area, state.industry);
- // 2021-5-21修改
- var selectedAreaAndInd = getSelectBuyset(state.area, state.industry)
- setSelectedAreaAndInd(selectedAreaAndInd);
- // 初始化,已购买的城市和行业
- setBuyAreaAndInd(state.buyset);
- //是否提示即将到期
- showTimeOut(state.endTime, state.isTrial);
- selectTime = sessionStorage.getItem("vip_change_time");
- var endflag = state.endTime;
- var stratFlag = state.startTime;
- //刷新展示周期
- flushShowTime(state.isTrial, selectTime, stratFlag, endflag);
- // 初始化关键词
- // if (state.items.length === 0) {
- // $('.body-item.keywords .keywords-text').text('未分类')
- // } else {
- // var arr = []
- // state.items.forEach(function (item, index) {
- // arr.push(item['s_item'])
- // })
- // $('.body-item.keywords .keywords-text').text(arr.join('、'))
- // }
- if (state.matchway) {
- var ModeArr = ['按标题匹配', '按全文匹配']
- var nowMode = ModeArr[state.matchway - 1] || '按标题匹配'
- $(".body-item.match-way .keywords-text.match-way-value").text(nowMode)
- var popDom = $("#iosActionsheet .weui-actionsheet__cell.active")
- if (popDom.find('.cell_title').text() !== nowMode) {
- popDom.removeClass('active').siblings().addClass('active');
- }
- }
- // 推送设置初始化
- var pushSettingMap = {
- 1: '实时推送',
- 2: '每日推送',
- 3: '每周推送',
- 4: '每月推送',
- }
- $('.body-item.push-setting .push-setting-text').text(pushSettingMap[state.ratemode])
- // 初始化“其他"开关
- console.log(state.otherbuyerclass)
- if (state.otherbuyerclass == 1 || state.otherbuyerclass == null) {
- $('.switch_other').addClass('checked')
- } else {
- $('.switch_other').removeClass('checked')
- }
- //试用不展示续费
- if (!state.isTrial) {
- $('.super-title').show();
- $(".renew").show();
- if ($("#giveTimeBox").is('[data-new-year]')) {
- showGiveStatus(true)
- }
- } else {
- $('.try-seven').show();
- $(".trail").show();
- if ($("#giveTimeBox").is('[data-new-year]')) {
- showGiveStatus(true)
- }
- }
- $('[data-update-tips]').hide()
- // 如果购买的是升级版套餐 不显示升级提示 且如果是全国全行业 则不显示升级按钮
- if (state.buyset.upgrade === 1) {
- $('[data-update-tips]').hide()
- if (state.buyset.areacount == -1) {
- $('*[data-bind-update]').hide()
- $('button[data-bind-renew]').css("margin-right", 0)
- }
- }
- // 清除升级页面的区域选择
- sessionStorage.removeItem('vipSubSelectArea')
- }
- // 给订阅周期栏目绑定点击事件(订阅周期选择框显示与隐藏等各种操作)
- //initCycleSelector()
- var subVipState = sessionStorage.getItem('sub_vip_state');
- var reqData = JSON.parse(subVipState);
- // if (subVipState) {
- // init(reqData);
- // subNode.initData = reqData
- // //判断是否修改
- // var IndustryNoChange = JSON.stringify(reqData.oldIndustry.sort()) === JSON.stringify(reqData.industry.sort());
- // var tmp1 = getAreaClassArr(reqData.oldArea);
- // var tmp2 = getAreaClassArr(reqData.area);
- // var areaNoChange = (JSON.stringify(tmp1[0].sort()) === JSON.stringify(tmp2[0].sort())) && (JSON.stringify(tmp1[1].sort()) === JSON.stringify(tmp2[1].sort()));
- // if (IndustryNoChange && areaNoChange && changeTime.length === 0) {
- // getDataWitXHR()
- // return
- // }
- // //判断是否需要升级
- // var status = getUpgradeFinalStatus(getBuySet(reqData.area, reqData.industry), {
- // "areacount": reqData.buyset.areacount,
- // "buyerclasscount": reqData.buyset.buyerclasscount,
- // "citys": reqData.buyset.newcitys
- // }, changeTime, reqData.endTime, reqData.renewList, reqData.isTrial);
- // // 双11.11活动
- // var giveT = [changeTime[1] === 1 ? 1 :changeTime[0], changeTime[1]]
- // if (!giveT[0] || !giveT[1]) {
- // giveT = []
- // }
- // var giveStatue = getUpgradeFinalStatus(getBuySet(reqData.area, reqData.industry), {
- // "areacount": reqData.buyset.areacount,
- // "buyerclasscount": reqData.buyset.buyerclasscount,
- // "citys": reqData.buyset.newcitys
- // }, giveT, reqData.endTime, reqData.renewList, reqData.isTrial);
- // var givePrice = giveStatue[0]
- // var giveCycle = changeTime[1] === 1 ? ('1年') : ((changeTime[0] ? changeTime[0] : 1) + '个月')
- // if (status[0] === -2) {
- // weui.toast('订单冲突', {
- // duration: 3000,
- // className: 'jy-toast',
- // });
- // return
- // }
- // if (status[0] === -1) {
- // //直接修改
- // $(".vip-footer.modify").show();
- // // doSubmit()
- // // initBack(1);
- // return
- // }
- // //区域需要升级
- // if (status[1]) {
- // if (reqData.isTrial) {
- // $(".area .tip").text("需购买");
- // }
- // $(".area .tip-need-upgrade").show();
- // }
- // //行业需要升级
- // if (status[2]) {
- // if (reqData.isTrial) {
- // $(".industry .tip").text("需购买");
- // }
- // $(".industry .tip-need-upgrade").show()
- // }
- // console.log(status[0],'111111')
- // if (status[0] > 0) {
- // //需要付钱
- // $(".vip-footer.upgrade").show();
- // //价格展示
- // var nowTime = new Date().getTime();
- // var startTime = live20200707.startTime;
- // var endTime = live20200707.endTime;
- // var activeDiscount = parseFloat(live20200707.activeDiscount);
- // var startTimes = parseInt(startTime) * 1000;
- // var endTimes = parseInt(endTime) * 1000;
- // if (nowTime >= startTimes && nowTime < endTimes) {
- // var price = status[0];
- // $(".price-num").text(price);
- // status[0] = parseFloat(price) * activeDiscount;
- // var activePrice = formatMoney(parseFloat(price) - parseFloat(price) * activeDiscount);
- // $(".reduce-price").text(formatMoney(activePrice));
- // // for (var i=0;i<status.length;i++){
- // // if(i===3){
- // // for (var a in status[i]){
- // // status[i][a].price = parseFloat(status[i][a].price) * activeDiscount;
- // // }
- // // }
- // // }
- // }
- // $(".vip-footer.upgrade .billing-price").text(formatMoney(status[0]));
- // submitPrice = status[0] * 10000 / 100
- // // 活动期间,则显示优惠码
- // if ($('.vip-upgrade').hasClass('live-20200707')) {
- // // 优惠码选项
- // $('.coupon-code-tx').show()
- // // 原价现价
- // $('.origin-price').css('display', 'flex')
- // // 优惠提示
- // $('.j-notice-bar.vip-bar').css('display', 'flex')
- // }
- // // coupon.updatePrice(status[0])
- // }
- // if (reqData.isTrial) {//试用购买
- // if ($("#giveTimeBox").hasClass('hasDoubleEleven')) {
- // $(".origin-price").css('display', 'flex')
- // $("#giveTimeBox").show()
- // $("#giveTimeText").text(giveCycle)
- // $('.origin-price .price-num').text(formatMoney(status[0] + givePrice));
- // // 优惠明细
- // $('.discount-price .dis-price').text(formatMoney(givePrice))
- // $('.now-price .dis-price').text(formatMoney(status[0]));
- // }
- // if (changeTime.length === 0) {
- // //刷新展示时间
- // changeTime = [1, 2];//
- // flushShowTime(true, "1个月");
- // sessionStorage.setItem("vip_trial_buy", true);
- // selectTime = "1个月"
- // }
- // initBack(4);
- // $(".vip-footer.upgrade .confirm").text("立即购买");
- // // coupon.$refs.couponRef.btnText = "立即购买"
- // } else if ((!status[1] && !status[2])) {//续费
- // initBack(2);
- // } else {//升级
- // //升级展示计价清单
- // if (!reqData.isTrial) {
- // $(".preview-label").text("需补差价:");
- // $(".billing-list-btn").text("计费清单");
- // $(".va-total-container .total-price").text("共计:¥" + formatMoney(status[0]));
- // flushSubtotal(status[3]);
- // console.log("subtotail", status[3])
- // }
- // // initBack(2);// 升级
- // }
- // } else {
-
- // }
- getDataWitXHR()
- //返回提示使用
- function pushHistory() {
- var state = {
- title: "title",
- url: "#"
- };
- window.history.pushState(state, "title", "#");
- }
- function initBack(module) {
- pushHistory();
- //weui.toast(module);
- $('.vip-footer .button-l.reset').off("click").on("click", function () {
- $('.weui-mask').trigger('click')
- cancelTip(module);
- });
- window.addEventListener("popstate", function (e) {
- // 如果订单计费清单显示,则关闭清单;
- if ($(".billing-list-container").css("display") != "none" && module === 2) {
- pickerShow('.billing-list-container', false);
- pushHistory();
- } else {
- // 提示是否保存
- $('.weui-mask').trigger('click')
- var flagString = location.href.slice(-1)
- if (flagString === '#') return
- if (history.state && history.state.flag === "pay") {
- return
- }
- cancelTip(module);
- }
- }, false);
- }
- //保存 or 升级
- var submited = false;
- function doSubmit() {
- if (submited) {
- return
- }
- submited = true;
- setTimeout(function () {
- submited = false;
- }, 1000);
- //校验是否点击阅读条款
- // if (submitPrice > 0) {
- // if (!$('.checkbox').hasClass("checked")) {
- // weui.toast('请勾选服务条款', {
- // duration: 1500,
- // className: 'jy-toast',
- // });
- // $dialog.hide(function () {
- // });
- // return
- // }
- // }
- //优惠码
- var activeCode = $('.coupon-picker .weui-input').val();
- var activeCodes = "";
- if (activeCode.toLowerCase() === 'jianyu360' && $('.coupon-code-tx .keywords-text').text() === '支付成功赠送30天订阅周期') {
- activeCodes = 'jianyu360';
- }
- weui.loading()
- $DoPost('/subscribepay/vipsubscribe/saveChange', {
- "userLotteryId":coupon.$refs.couponRef.coupon.userLotteryId,
- "lotteryId": coupon.$refs.couponRef.coupon.lotteryId,
- "area": reqData.area["全国"] ? '{}' : JSON.stringify(reqData.area),
- "industry": reqData.industry.join(","),
- "time": selectTime,
- "price": (coupon.initPrice - coupon.$refs.couponRef.coupon.value)* 10000 / 100,
- "activeCode": activeCodes
- }, function (r) {
- if (r.success) {
- if (r.data.needPay) {
- weui.loading().hide()
- //创建支付订单
- clearSessionStorage();
- history.replaceState({"flag": "pay"}, '', '/front/vipsubscribe/toOrderDetailPage?orderCode=' + r.data.code);
- var nextHref = "/weixin/pay/checkout_subvip?orderCode=" + r.data.code
- if (reqData.isTrial) {
- nextHref += "&t=3"
- } else {
- nextHref += "&t=2"
- }
- window.location.href = nextHref
- } else {
- weui.loading().hide()
- //订阅修改
- if (r.data.doSuccess) {
- clearSessionStorage();
- getDataWitXHR()
- // clearSessionStorage();
- // window.location.reload();
- } else {
- weui.toast('修改保存失败', {
- duration: 1500,
- className: 'jy-toast',
- });
- }
- }
- }
- }, false);
- }
- // 活动事件绑定
- var couponInfo = {
- code: 'jianyu360',
- successTip: '支付成功赠送30天订阅周期'
- }
- $('.j-picker').on('click', '.cancel', function () {
- $('.coupon-picker').hide()
- })
- $('.coupon-code-tx').on('click', function () {
- if ($('.vip-upgrade').hasClass('live-20200707')) {
- $('.coupon-picker').show()
- } else {
- return
- }
- var input = $('.coupon-picker .weui-input')
- var confirmButton = $('.coupon-picker .weui-picker__btn')
- var cancelButton = $('.coupon-picker .cancel')
- var value = input.val()
- input.val('').focus().val(value).on('input', function () {
- value = this.value
- confirmButton.prop('disabled', (value === '' || value === undefined))
- })
- confirmButton.on('click', function () {
- if (value.toLowerCase() !== couponInfo.code) {
- weui.toast('优惠码输入错误', {
- className: 'j-toast',
- duration: 1500
- })
- return
- }
- if (value.length === couponInfo.code.length && value.toLowerCase() === couponInfo.code) {
- $('.coupon-code-tx .keywords-text').text(couponInfo.successTip)
- sessionStorage.liveActiveCode_new = "jianyu360"
- $('.coupon-code-tx').off('click')
- cancelButton.trigger('click')
- }
- })
- })
- });
- function clearSessionStorage() {
- sessionStorage.removeItem("sub_vip_state");
- sessionStorage.removeItem("vip_index_read");
- sessionStorage.removeItem("vip_change_time");
- sessionStorage.removeItem("vip_trial_buy");
- //续费页面缓存
- sessionStorage.removeItem("vipSubSelectArea");
- sessionStorage.removeItem("vipSubSelectIndustry");
- sessionStorage.removeItem("vipSubSelectTime");
- sessionStorage.removeItem("endTime");
- sessionStorage.removeItem("liveActiveCode_new");
- sessionStorage.removeItem("liveActiveCode_renew");
- }
- var mergedlist = []
- var merge_industry = ["国土", "林业", "环保", "卫生", "工商", "质监", "食药", "安监", "地震", "公安", "文化", "旅游", "银监", "保监"]
- function checkmerge(state, isread) {
- if (checkindustry(state)) {
- var tips = "<span style='font-size:15px;font-family:PingFang SC;font-weight:bold;color:rgba(29,29,29,1);opacity:1;'>随着政府机构改革和职能转变工作深入推进,部分采购单位行业与现实不一致,为了提高订阅推送数据的准确性,剑鱼标讯需要针对采购单位行业名称进行优化。</span><br><span style='font-size:13px;font-family:PingFang SC;font-weight:400;color:rgba(104,104,104,1);opacity:1;'>采购单位名称的调整不影响所购买的采购单位数量,您仍可按需调整。<br><br>您订阅的:<br></span>"
- var hasMerged = isread
- var s_count = h_count = m_count = p_count = cultural_count = CBRC_count = t_count = 0
- var nature_source = ["国土", "林业"];
- var health_commission = ["卫生"]
- var market_supervision = ["工商", "质监", "食药"]
- var contingency_management = ["安监", "地震", "公安"]
- var cultural_tourism = ["文化", "旅游"]
- var CBRC = ["银监", "保监"]
- var ecological_environment = ["环保"]
- state.forEach(function (item, index) {
- if (merge_industry.indexOf(item) > -1) {
- if (item == "国土" || item == "林业") {
- mergedlist.push("自然资源")
- // hasMerged = true
- nature_source = Highlight(nature_source, item)
- s_count++
- } else if (item == "环保") {
- mergedlist.push("生态环境")
- // hasMerged = true
- ecological_environment = Highlight(ecological_environment, item)
- h_count++
- } else if (item == "卫生") {
- mergedlist.push("卫健委")
- // hasMerged = true
- health_commission = Highlight(health_commission, item)
- p_count++
- } else if (item == "工商" || item == "质监" || item == "食药") {
- mergedlist.push("市场监管")
- // hasMerged = true
- market_supervision = Highlight(market_supervision, item)
- m_count++
- } else if (item == "地震" || item == "安监" || item == "公安") {
- if (item !== "公安") {
- mergedlist.push("应急管理")
- } else {
- mergedlist.push("公安")
- }
- // hasMerged = true
- contingency_management = Highlight(contingency_management, item)
- t_count++
- } else if (item == "文化" || item == "旅游") {
- mergedlist.push("文旅")
- // hasMerged = true
- cultural_tourism = Highlight(cultural_tourism, item)
- cultural_count++
- } else if (item == "银监" || item == "保监") {
- mergedlist.push("银保监")
- // hasMerged = true
- CBRC = Highlight(CBRC, item)
- CBRC_count++
- }
- } else {
- mergedlist.push(item)
- }
- })
- if (s_count >= 1) {
- tips += nature_source.join('、') + " 合并为 【自然资源】<br>"
- }
- if (h_count >= 1) {
- tips += ecological_environment.join('、') + " 整合其他部门部分职能后更改为 【生态环境】<br>"
- }
- if (p_count >= 1) {
- tips += health_commission.join('、') + " 变更为 【卫健委】<br>"
- }
- if (m_count >= 1) {
- tips += market_supervision.join('、') + " 合并为 【市场监管】<br>"
- }
- if (t_count >= 1) {
- tips += contingency_management.join('、') + "中的消防 合并为 【应急管理】<br>"
- }
- if (cultural_count >= 1) {
- tips += cultural_tourism.join('、') + " 合并为 【文旅】<br>"
- }
- if (CBRC_count >= 1) {
- tips += CBRC.join('、') + " 合并为 【银保监】<br>"
- }
- if (!hasMerged) {
- $("#merge_content").html(tips)
- $("#merge_dialog").show()
- }
- }
- }
- function Highlight(a_list, key) {
- a_list.forEach(function (item, index) {
- if (item == key) {
- var m = "<span style='color:red'>" + item + "</span>"
- a_list[index] = m
- }
- })
- return a_list
- }
- function acceptchange() {
- var q = removeDuplicatedItem(mergedlist)
- $.post("/subscribepay/vipsubscribe/mergeIndustry", {"industry": q.toString(), "isread": true}, function (r) {
- if (r.success) {
- sessionStorage.removeItem("sub_vip_state")
- console.log("行业合并成功")
- } else {
- console.log("行业合并失败")
- }
- })
- $("#merge_dialog").hide()
- }
- function removeDuplicatedItem(ar) {
- var ret = [];
- for (var i = 0, j = ar.length; i < j; i++) {
- if (ret.indexOf(ar[i]) === -1) {
- ret.push(ar[i]);
- }
- }
- return ret;
- }
- function checkindustry(industry) {
- var isinclude = false
- industry.forEach(function (item, index) {
- if (merge_industry.indexOf(item) > -1) {
- isinclude = true
- return
- }
- })
- return isinclude
- }
- // 解决ios微信下软键盘收起后,页面留白
- document.body.addEventListener("focusout", function () {
- //软键盘收起的事件处理
- setTimeout(function () {
- const scrollHeight =
- document.documentElement.scrollTop || document.body.scrollTop || 0;
- window.scrollTo(0, Math.max(scrollHeight - 1, 0));
- }, 100);
- });
|