var vm = new Vue({ el: '#select-meau', components: { dateComponent: dateComponent, areaComponent: areaComponent, industryComponent: industryComponent, cateComponent: cateComponent, keywordComponent: keywordComponent, noticeComponent: noticeComponent, rootComponent: rootComponent }, data () { return { sessStorageKey: '$data-historypush', // 时间参数 time:'', // 选择的时间数据 selectDate: { startDate: '', endDate: '', exact: '' }, // 地区参数 area: '', // 行业参数 subscopeclass: '', // 采购单位 buyerclass: '', // 关键词 key: '', // 公告类型 subtype: '', screenShow: false, tagText: { timeText: '时间', areaText: '地区', industryText: '行业', cateText: '采购单位', keywordText: '关键词', noticeText: '公告类型' }, selectCateList: [], // 选择的采购单位类型列表 selectAreaList: [], // 选择的地区列表 selectIndustryList: [], // 选择的行业列表 selectKeyWordList: [], // 选择的关键词列表 selectNoticeList: [], // 选择的公告类型列表 setTimer: { datetimer: '', areatimer: '', catetimer: '', industrytimer: '', keytimer: '', noticetimer: '' }, iosMeauStyle: false } }, created () { this.getUserRoot() if(this.time) { this.setPushTime(this.time) } var recover = this.recover() if (!recover) { setTimeout(() => { // 如果订阅消息进来时间不清空 if(this.time !== '') { sessionStorage.setItem(this.sessStorageKey, JSON.stringify(this.$data)) this.setPushTime(this.time) this.revorceOtherData() }else{ // 清空筛选数据 this.revorceData() } }) } }, mounted () { utils.iosBackRefresh() }, methods: { recover: function () { let _this = this var excludeKey = ['sessStorageKey'] var $data = sessionStorage.getItem(this.sessStorageKey) if ($data) { $data = JSON.parse($data) for (var key in $data) { if (excludeKey.indexOf(key) !== -1) { continue } this.$data[key] = $data[key] } const res = $data // 时间 console.log(res) if(res.time != '') { this.selectDate.startDate = res.time.split('_')[0] * 1000 this.selectDate.endDate= res.time.split('_')[1] * 1000 } // 地区 if(res.area != '') { setTimeout(() => { $('.areaText').html(res.tagText.areaText) }) this.selectAreaList = res.area.split(',') } // 采购单位类型 if(res.buyerclass != '') { setTimeout(() => { $('.cateText').html(res.tagText.cateText) }) this.selectCateList = res.buyerclass.split(',') } // 行业 if(res.subscopeclass != '') { setTimeout(() => { $('.industryText').html(res.tagText.industryText) }) this.selectIndustryList = res.subscopeclass.split(',') } // 关键词 if(res.key != '') { setTimeout(() => { $('.keywordText').html(res.tagText.keywordText) }) this.selectKeyWordList = res.key.split(',') } // 公告类型 if(res.subtype != '') { setTimeout(() => { $('.noticeText').html(res.tagText.noticeText) }) this.selectNoticeList = res.subtype.split(',') } sessionStorage.removeItem(this.sessStorageKey) } return !!$data }, // 清空筛选数据 revorceData: function() { this.time = '' this.area = '' this.subtype = '' this.subscopeclass = '' this.key = '' this.buyerclass = '' }, revorceOtherData: function() { this.area = '' this.subtype = '' this.subscopeclass = '' this.key = '' this.buyerclass = '' }, open: function() { this.iosMeauStyle = true }, close: function() { this.iosMeauStyle = false }, // 订阅推送消息展示数据 setPushTime: function(time) { let pushtime = { start: parseInt(time.split('_')[0] * 1000), end: parseInt(time.split('_')[0] * 1000), } this.tagText.timeText = new Date(pushtime.start).pattern('yyyy.MM.dd') + '~' + new Date(pushtime.end).pattern('yyyy.MM.dd') this.selectDate.startDate = pushtime.start this.selectDate.endDate= pushtime.end this.selectDate.exact = 'exact' }, // 判断是否是有筛选条件 getUserRoot: function() { let _this = this $.ajax({ url: '/publicapply/bidcoll/power', type: 'POST', success: function(res) { // 如果是商机管理、大会员、超级订阅会员有筛选权限 if(res.data.entniche || res.data.member || res.data.vip > 0) { _this.screenShow = true } else { _this.screenShow = false } } }) }, confirm: function(data){ console.log(data) if(data.name === 'dateItem'){ const timeRange = { start: (data.data.start / 1000).toFixed(0), end: (data.data.end / 1000).toFixed(0) } if (timeRange.start == 0 && timeRange.end == 0) { this.time = '' this.tagText.timeText = '时间' } else if(timeRange.start == 0 && timeRange.end != 0) { this.time = '_' + timeRange.end } else if(timeRange.start != 0 && timeRange.end == 0) { this.time = timeRange.start + '_' } else { this.time = timeRange.start + '_' + timeRange.end } this.selectDate.exact = data.data.exact switch (data.data.exact) { case 'all': { this.tagText.timeText = '时间' break } case 'lately7': { this.tagText.timeText = '最近7天' break } case 'lately30': { this.tagText.timeText = '最近30天' break } case 'lastYear': { this.tagText.timeText = '去年' break } case 'exact': { this.tagText.timeText = new Date(timeRange.start*1000).pattern('yyyy.MM.dd') + '~' + new Date(timeRange.end*1000).pattern('yyyy.MM.dd') break } } this.setToggle() setTimeout(() => { FTAGData(this.time) }, 500) return } else if(data.name === 'areaItem'){ $('.areaText').html(data.t) this.tagText.areaText = data.t this.area = data.data.join(',') } else if(data.name === 'industryItem'){ $('.industryText').html(data.t) this.tagText.industryText = data.t this.subscopeclass = data.data.join(',') } else if(data.name === 'cateItem'){ $('.cateText').html('采购单位' + data.t) this.tagText.cateText = '采购单位' + data.t this.buyerclass = data.data.join(',') } else if(data.name === 'keywordItem'){ $('.keywordText').html(data.t) this.tagText.keywordText = data.t this.key = data.data.join(',') } else if(data.name === 'noticeItem'){ $('.noticeText').html(data.t) this.tagText.noticeText = data.t this.subtype = data.data.join(',') } else if(data.name === 'rootItem'){ topay() } this.setToggle() setTimeout(()=>{ this.getAjaXParams() }, 500) }, cancel: function(data){ console.log(data) if(data.name === 'dateItem'){ this.time = '' this.tagText.timeText = '时间' this.selectDate.start = '' this.selectDate.end = '' this.selectDate.exact = 'all' this.setTimer.datetimer = new Date().getTime() } else if(data.name === 'areaItem'){ this.area = '' $('.areaText').html('地区') this.setTimer.areatimer = new Date().getTime() } else if(data.name === 'industryItem'){ this.subscopeclass = '' $('.industryText').html('行业') this.setTimer.industrytimer = new Date().getTime() } else if(data.name === 'cateItem'){ this.buyerclass = '' $('.cateText').html('采购单位') this.setTimer.catetimer = new Date().getTime() } else if(data.name === 'keywordItem'){ this.key = '' $('.keywordText').html('关键词') this.setTimer.keytimer = new Date().getTime() } else if(data.name === 'noticeItem'){ this.subtype = '' $('.noticeText').html('公告类型') this.setTimer.noticetimer = new Date().getTime() } this.setToggle() setTimeout(()=>{ this.getAjaXParams() }, 500) }, getAjaXParams: function() { ajaxFun(this.time, this.area, this.subscopeclass, this.buyerclass, this.key, this.subtype) }, setToggle: function() { this.$refs.dateItem.toggle(false) this.$refs.areaItem.toggle(false) this.$refs.industryItem.toggle(false) this.$refs.cateItem.toggle(false) this.$refs.keywordItem.toggle(false) this.$refs.noticeItem.toggle(false) } } })