var subScribeTemplate = `

按标题匹配

按全文匹配开通

会产生无效信息,请根据需要选择

您的订阅区域尚未设置,为了不影响您的使用,还请您尽快完善哦
去完善
` var subComponent = { name: 'vip-subscribe-set-template', template: subScribeTemplate, props: { 'linkobj': { type: Object, default: function() { return {} } }, "initdata": { type: Object, default: function() { return {} } }, "type": { type: String, default: '' }, vSwitch: { type: String, default: 'f' } }, data: function() { return { info: { area: '请选择区域', industry: '请选择采购单位行业', infoType: '请选择信息类型' }, // 信息类型数据 infoTypeList: [ { title: '拟建项目', value: '拟建', desc: '采集建筑工程、信息化等类项目在招标前由发改委等部门审批的信息,并向用户提供“拟建项目预告”功能。' }, { title: '招标预告', value: '预告', desc: '在正式招标之前发布的公告信息,主要有采购计划、项目预告、采购预告、招标文件预公示、招标方式公示等信息' }, { title: '招标公告', value: '招标', desc: '包括公开招标、邀请招标、询价采购、竞争性谈判、单一来源、公开竞价、电子反拍、变更公告等公告信息' }, { title: '招标结果', value: '结果', desc: '包括中标公示、成交公告、废标公告、流标公告等' }, { title: '其他信息', value: '其它', desc: '包括合同公告、验收公告、违规处理等' }, ], // 匹配方式 active: 1, pushsetShow: true, resultTime: '(近3个月内共条信息)', checkedflag: false, littleShow: false, accStatus: 0, userAreaNum: 1, // 用户修改地区剩余次数 userType: false, // 用户是否为付费用户 userAreaAllNum: 1, // 用户可修改地区总次数 infoTypeMenu: false, // 信息类型弹窗状态 infoTypeData: [], // 信息类型选择列表 conf: {}, // 信息类型数据 noAreaFreeType: false, // 免费用户未设置地区时显示弹窗 backTipShowCount: 0, // 离开页面展示弹窗次数 thisvSwitch: 'f', UserSubscribe: {}, // 免费用户数据 } }, mounted () { let switchpro = sessionStorage.getItem('switch-product') if(switchpro) { if(switchpro == 'bigmember') { this.accStatus = 2 } else if(switchpro == 'supervip') { this.accStatus = 1 } } this.getData() this.$emit('mounted') // this.addBackTip() }, watch: { initdata: function(newVal, oldVal) { if(newVal) { this.getResultView() this.getData() if (this.vSwitch !== 'f') { this.setIosData() } } }, vSwitch: function (val) { if (val === 'f') { this.getUserSubscribe() } } }, methods: { getData: function() { this.setArea() this.setIndustry() this.setKeyword() this.getActionDefault() this.getIndustryType() this.getProjectMatch() this.iosBackRefresh() }, // 判断用户权限 // 设置区域 setArea: function() { let _this = this if(this.initdata.area) { if(_this.accStatus == 2) { sessionStorage.setItem('big-setArea', JSON.stringify(this.initdata.area)) } if(JSON.stringify(this.initdata.area) === '{}') { this.info.area = '全国' } else { let proStr = '' Object.keys(this.initdata.area).forEach(function(item,index) { if(_this.initdata.area[item].length == 0) { proStr += item + '、' } else { let cityStr = '' _this.initdata.area[item].forEach(function(data, i) { cityStr += data + '、' }) if (cityStr.length > 0) { cityStr = cityStr.substr(0,cityStr.length - 1); } proStr += item+ '(' + cityStr + ')' + '、' } }) if(proStr[proStr.length - 1] == '、') { proStr = proStr.substr(0,proStr.length - 1); } _this.info.area = '已选:' + proStr } } else { this.info.area = '请选择区域' } var areaNull = sessionStorage.getItem('areaNull') if(areaNull) { this.initdata.area = {} this.info.area = '请选择区域' } }, // 设置行业 setIndustry: function() { let _this = this if(this.initdata.industry) { // this.initdata.industry = JSON.parse(this.initdata.industry) if(this.accStatus == 2) { sessionStorage.setItem('big-setCate', JSON.stringify(this.initdata.industry)) } if(this.initdata.industry.length == 0) { this.info.industry = '已选:全部' if (this.vSwitch === 'f') { this.info.industry = '请选择采购单位类型' } } else { this.info.industry = '已选:' + this.initdata.industry.join('、') } } else { this.info.industry = '请选择采购单位类型' } var industryNull = sessionStorage.getItem('industryNull') if(industryNull) { this.initdata.industry = [] this.info.industry = '请选择采购单位类型' } }, // 设置关键词 setKeyword: function() { let state = this.initdata if(state) { if(state.items) { if (state.items.length === 0) { $('.body-item.keywords .keywords-text').text('请设置关键词') } else { var arr = [] state.items.forEach(function (item, index) { item.a_key.forEach(function(data,i) { arr.push(data.key[0]) }) }) if(arr.length == 0) { $('.body-item.keywords .keywords-text').text('请设置关键词') } else { $('.body-item.keywords .keywords-text').text('已设置' +arr.length+ '组关键词') } // $('.body-item.keywords .keywords-text').text(arr.join('、')) } } } else { $('.body-item.keywords .keywords-text').text('请设置关键词') } }, // ios关键词重新赋值 setIosData: function () { let _this = this let u = navigator.userAgent; let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端 let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 if (isAndroid == true) { console.log("安卓手机") } else { $.ajax({ type: 'POST', url: '/subscribepay/vipsubscribe/getSubBuyMsg?t=' + Date.now(), success:function(res) { if(res.success) { _this.setKeyword() } } }) } }, // 信息类型 getIndustryType: function() { if(this.initdata) { if(this.initdata.infotype) { if(this.accStatus == 2) { sessionStorage.setItem('big-setInfoType', JSON.stringify(this.initdata.infotype)) } if (this.initdata.infotype.length === 0) { this.info.infoType = '全部类型' } else { this.info.infoType = this.initdata.infotype.join('、') } } else { this.info.infoType = '全部类型' } } }, // 项目匹配 getProjectMatch: function() { if (this.initdata.projectmatch == 1) { $('.switch').addClass('checked') this.checkedflag = true } else { $('.switch').removeClass('checked') this.checkedflag = false } }, switchs: function() { // 用户未购买项目匹配功能 if (this.vSwitch === 'f') { $('.switch').removeClass('checked') this.checkedflag = false if (location.href.indexOf('front') !== -1) { var href = '/front/vipsubscribe/introducePage' } else { var href = '/jyapp/vipsubscribe/introducePage' } location.href = href } else { // switch点击切换 if (!this.checkedflag) { this.checkedflag = !this.checkedflag; this.setprojectmatch('projectMatch', 1); } else { this.checkedflag = !this.checkedflag; this.setprojectmatch('projectMatch', 0); weui.toast('项目匹配已关闭', { duration: 1500, className: 'jy-toast', callback: function () { console.log('close') } }); } } }, setprojectmatch(pagetype,index) { let _this = this let vswitch ='v' if(_this.accStatus == 2) { vswitch = 'm' } else if(_this.accStatus == 1) { vswitch = 'v' } $.post("/publicapply/subscribe/setUserInfo", {pageType: pagetype, pmindex: index, vSwitch:vswitch}, function (r) { if (r.flag) { if(index == 0 || index == 1) { var subVipState = sessionStorage.getItem('sub_vip_state'); var reqData = JSON.parse(subVipState); reqData.projectmatch = index; sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData)) } } }) }, // 关键词匹配方式 getActionDefault: function() { let _this = this let defaultTitle = '' if(this.initdata.matchway == 1 || !this.initdata.matchway) { $('.match-way-value').text('按标题匹配') this.active = 1 } else if(this.initdata.matchway == 2) { $('.match-way-value').text('按全文匹配') this.active = 2 } // $('#iosActionsheet .weui-actionsheet__cell').each(function (index, item) { // var t = $(item).children().text().trim(); // if (t == defaultTitle) { // $(this).addClass('active') // } // }) }, hideActionSheet: function() { var update_renew = $('.update_renew') var $iosMask = $('#iosMask'); var $iosActionsheet = $('#iosActionsheet'); $iosActionsheet.removeClass('weui-actionsheet_toggle'); $('.match-keywords-actionsheet').hide() $iosMask.fadeOut(200); // 免费用户 if (this.thisvSwitch === 'f') { return } // 超级订阅升级提示 if(update_renew) { if(this.accStatus == 2) { update_renew.hide() } else { update_renew.show() } } this.$emit('footershow', 'false') }, iosMask: function() { this.hideActionSheet() }, iosActionsheetCancel: function() { this.hideActionSheet() }, matchWay: function() { var update_renew = $('.update_renew') var $iosMask = $('#iosMask'); var $iosActionsheet = $('#iosActionsheet'); $iosActionsheet.addClass('weui-actionsheet_toggle'); $('.match-keywords-actionsheet').show() $iosMask.fadeIn(200); if(update_renew) { update_renew.hide() } this.$emit('footershow', 'true') }, actionSheet: function(title, index) { let _this = this let vswitch = 'v' var href = '' if (index === 2 && this.vSwitch === 'f') { if (location.href.indexOf('front') !== -1) { href = '/front/vipsubscribe/introducePage' } else { href = '/jyapp/vipsubscribe/introducePage' } location.href = href } else { if (this.vSwitch === 'f') { return this.hideActionSheet() } if(_this.accStatus == 2) { vswitch = 'm' } else if(_this.accStatus == 1) { vswitch = 'v' } var update_renew = $('.update_renew') $.post("/publicapply/subscribe/setUserInfo", {pageType: "saveSeniorset", matchtype: index, vSwitch: vswitch}, function (r) { if (r.flag) { var subVipState = sessionStorage.getItem('sub_vip_state'); var reqData = JSON.parse(subVipState); _this.active = index var $iosMask = $('#iosMask'); var $iosActionsheet = $('#iosActionsheet'); $iosActionsheet.removeClass('weui-actionsheet_toggle'); $('.match-keywords-actionsheet').hide() $iosMask.fadeOut(200); if(update_renew) { if(_this.accStatus == 2) { update_renew.hide() } else { update_renew.show() } } _this.$emit('footershow', 'false') $('.match-way-value').text(title) if(index == 1) { $('.titleMacth').addClass('active') $('.allMacth').removeClass('active') } else { $('.titleMacth').removeClass('active') $('.allMacth').addClass('active') } reqData.matchway = index; sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData)) } else { weui.toast('关键词匹配方式修改失败', { duration: 1500, className: 'jy-toast', callback: function () { console.log('close') } }); } }) // var nowMode = title // var ModeArr = ['按标题匹配', '按全文匹配'] // var nowIndex = ModeArr.indexOf(nowMode) // if (nowIndex !== -1) { // this.setMatchway(ModeArr.indexOf(nowMode) + 1) // } else { // // $(this).removeClass('active').siblings().addClass('active'); // $('.match-way-value').text($(this).siblings().children('.cell_title').text()) // weui.toast('关键词匹配方式修改失败', { // duration: 1500, // className: 'jy-toast', // callback: function () { // console.log('close') // } // }); // } this.getResultView() } }, // 项目匹配问号点击事件 projectNotice: function () { var str = '开启后,系统将根据你订阅的关键词自动匹配出相关联的项目,并将相关联项目的后续动态在超级订阅内一并推送。' weui.alert(str, { title: '项目匹配', className: 'jy-alert', buttons: [{ label: '我知道了' }] }); }, // 用户未购买修改采购单位类型功能 userNoIndustry: function () { if (this.vSwitch !== 'f') { var href = '/jyapp/vipsubscribe/toChangeIndustry?header=save' } else { if (location.href.indexOf('front') !== -1) { var href = '/front/vipsubscribe/introducePage' } else { var href = '/jyapp/vipsubscribe/introducePage' } } this.linkobj.industry = href }, // 修改地区无次数点击事件 userNumOver: function () { var _this = this if (this.vSwitch === 'f' && this.userAreaNum === 0) { this.linkobj.area = 'javascript:;' if (this.userAreaAllNum > 0) { var str = `对不起,您当月修改区域的机会(${this.userAreaAllNum}次)已消耗完毕,无法再次修改~可前往升级省份订阅包增加订阅省份和修改次数` } else { var str = `对不起,您今年修改免费订阅区域的机会(1次)已消耗完毕,无法再次修改~可前往购买省份订阅包增加订阅省份` } weui.alert(str, { title: '', className: 'area-noNum', buttons: [{ label: '取消', type: 'default' },{ label: _this.userType ? '去升级' : '去购买', onClick: function(){ if (_this.userType) { if (location.href.indexOf('front') !== -1) { var href = '/areaPack/wx/page/buy?type=upgrade' } else { var href = '/jyapp/areaPack/page/buy?type=upgrade' } } else { if (location.href.indexOf('front') !== -1) { var href = '/areaPack/wx/page/buy?type=buy' } else { var href = '/jyapp/areaPack/page/buy?type=buy' } } location.href = href } }] }); } else { // this.linkobj.area = '/jyapp/big/page/set_area?callback=setting_save' if (this.vSwitch === 'f') { if (location.href.indexOf('front') !== -1) { this.linkobj.area = '/areaPack/wx/page/set_area' } else { this.linkobj.area = '/jyapp/areaPack/page/set_area' } } } }, // 修改地区剩余次数问号点击事件 amendmentNumNotice: function () { if (this.userAreaAllNum > 0) { var str = '每月可修改次数=可订阅省份数量,即每增加购买1个省份,可增加1次修改机会,次月清零重新计算,购买全国不限制每月修改次数。' } else { var str = '免费用户每年享有 1 次修改区域的机会' } weui.alert(str, { title: '', className: 'area-alert', buttons: [{ label: '我知道了' }] }); }, // 打开信息类型 openInfoType: function () { if (this.vSwitch === 'f') { this.infoTypeMenu = true } else { if (location.href.indexOf('front') !== -1) { location.href = '/front/vipsubscribe/toSetInfoTypePage' } else { location.href = '/jyapp/vipsubscribe/toSetInfoTypePage' } } }, // 重置信息类型 reset: function () { this.infoTypeData = [] }, // 确认信息类型 confirm: function () { this.infoTypeMenu = false this.saveInfoTypeChange() }, saveInfoTypeChange: function () { var _this = this $.ajax({ type:'POST', url:'/publicapply/subscribe/setUserInfo', data: { pageType: 'infoType', infoTypeArr: this.infoTypeData.join(','), vSwitch: this.vSwitch }, success:function(res){ if(res.flag) { location.reload() } else { _this.$toast(res.data.error_msg) } } }) }, // 关闭信息类型菜单 closeInfoType: function () { this.infoTypeMenu = false }, // 点击按钮改变按钮状态 changeBtnType: function (item) { if (item === 'all') { this.infoTypeData = [] } else { let thisIndex = this.infoTypeData.indexOf(item) if (thisIndex !== -1) { this.infoTypeData.splice(thisIndex, 1) } else { this.infoTypeData.push(item) } } }, // 跳转地区选择 gotoArea: function () { if (location.href.indexOf('front') !== -1) { location.href = '/areaPack/wx/page/set_area?type=new' } else { location.href = '/jyapp/areaPack/page/set_area?type=new' } }, // 获取用户权限 getUserSubscribe: function () { let _this = this $.ajax({ url: '/publicapply/free/subscribe', type: 'POST', success: function (res) { let freeArea = JSON.stringify(res.data) sessionStorage.setItem('sub_free_state', freeArea) _this.UserSubscribe = res _this.info.area = res.data.area _this.userAreaNum = res.data.areanum _this.userType = res.data.provincenum === 0 ? false : true _this.userAreaAllNum = res.data.provincenum _this.initdata.infotype = res.data.infotype || [] _this.infoTypeData = res.data.infotype || [] _this.info.infoType = _this.infoTypeData.length === 0 ? '全部类型' : _this.infoTypeData.join('、') // let proStr = '' // Object.keys(res.data.area).forEach(function(item,index) { // if(res.data.area[item].length == 0) { // proStr += item + '、' // } else { // let cityStr = '' // res.data.area[item].forEach(function(data, i) { // cityStr += data + '、' // }) // if (cityStr.length > 0) { // cityStr = cityStr.substr(0,cityStr.length - 1); // } // proStr += item+ '(' + cityStr + ')' + '、' // } // }) // if(proStr[proStr.length - 1] == '、') { // proStr = proStr.substr(0,proStr.length - 1); // } // _this.info.area = '已选:' + proStr let areaArr = [] if (res.data) { if (!res.data.area) { _this.noAreaFreeType = true } else { for (const key in res.data.area) { areaArr.push(key) } } } $('#menuArea').text('已选:'+ areaArr.join('、')) } }) }, // 关闭未选择地区提示 closeNoAreaTips: function () { this.noAreaFreeType = false }, // 页面跳转返回提示 addBackTip: function () { var _this = this var pushContent = { info: '订阅管理返回', url: '#tipover' } if (!history.state && this.backTipShowCount < 1) { history.pushState(pushContent, null, pushContent.url); } $(window).on('popstate', function () { _this.noAreaFreeType = true _this.backTipShowCount++ }) }, // // 最近三个月推送结果预览总数 getResultView: function () { let keyArr = [] let notKeyArr = [] let matchway = this.initdata.matchway let vt = 'v' let switchpro = sessionStorage.getItem('switch-product') if(switchpro) { if(switchpro == 'bigmember') { vt = 'm' } else if(switchpro == 'supervip') { vt = 'v' } } if (this.initdata.items) { this.initdata.items.forEach(function(item) { item.a_key.forEach(function(r) { keyArr.push(r.key[0]) if(r.notkey) { r.notkey.forEach(function(nok) { notKeyArr.push(nok) }) } }) }) } let _this = this $.ajax({ type: 'POST', url: '/publicapply/subscribe/getPushAllCount', data: { item: '', index: -1, vt: vt }, success: function(res) { if(_this.type == 'introduce') { _this.pushsetShow = false _this.resultTime = '(仅限超级订阅用户预览)' _this.linkobj.resultview = 'javascript:;' $('.resultpreview .icon-arrow').hide() } else { if(res.count < 30) { _this.littleShow = true } else { _this.littleShow = false } _this.resultTime = '(近3个月内共' + res.count + '条信息)' } } }) }, // 解决ios返回不刷新页面的问题 iosBackRefresh: function () { var isPageHide = false; window.addEventListener('pageshow', function () { if (isPageHide) { location.reload(); } }); window.addEventListener('pagehide', function () { isPageHide = true; }); }, }, }