diff --git a/public/static/js/index.js b/public/static/js/index.js index b01cae5..2f20118 100644 --- a/public/static/js/index.js +++ b/public/static/js/index.js @@ -8,7 +8,7 @@ Page.initPhonePage = function () { var local_url = window.location.href; for (var v = 0; v < Agents.length; v++) { if (userAgentInfo.indexOf(Agents[v]) > 0) { - var sURL2 = local_url.replace("/dist/", "/h5/"); + var sURL2 = local_url.replace("/#/", "/h5/#/"); console.log(sURL2); sessionStorage.removeItem('DateIndexH5'); sessionStorage.removeItem('DateIndex'); @@ -88,7 +88,7 @@ function getPaper(m) { var data = {'day': [], 'url': [], 'date': []}; $.ajax({ data:{'date':m}, - url: "http://csdzb.hschool.com.cn/api/dzb/date/index", + url: "https://jinrigushi.gushitv.com/api/dzb/date/index", type: 'POST', dataType: 'json', async: false, @@ -134,10 +134,14 @@ Page.initJump2Date = function () { } if (url != "") { + window.location.href = "https://jinrigushi.gushitv.com/#/?date="+year + '-' + fixNumer(month) + '-' + fixNumer(day); + setTimeout(()=>{ + window.location.reload(); + },100) // sessionStorage.setItem("year", year); // sessionStorage.setItem("month", month); // sessionStorage.setItem("day", day); - window.location.reload(); + //window.location.reload(); } else{ alert("未查询到对应日期的报纸"); @@ -149,7 +153,9 @@ Page.initJump2Date = function () { }; //日历牌-结束 - +var fixNumer = function (num) { + return ('0' + num).slice(-2); +}; /** * ============================================================================= * Dom Ready diff --git a/public/static/js/jquery.datepicker.js b/public/static/js/jquery.datepicker.js index df5b5dd..8e2db64 100644 --- a/public/static/js/jquery.datepicker.js +++ b/public/static/js/jquery.datepicker.js @@ -240,12 +240,16 @@ var curDay = $this.text(); - sessionStorage.setItem("year", year); - sessionStorage.setItem("month", month); - sessionStorage.setItem("day", curDay); + //sessionStorage.setItem("year", year); + //sessionStorage.setItem("month", fixNumer(month)); + //sessionStorage.setItem("day", fixNumer(curDay)); //var dddd=sessionStorage.getItem("DateList"); options.onSelect && options.onSelect(year + '-' + fixNumer(month) + '-' + fixNumer(curDay), $this); - window.location.reload(); + + window.location.href = "https://jinrigushi.gushitv.com/#/?date="+year + '-' + fixNumer(month) + '-' + fixNumer(curDay); + setTimeout(()=>{ + window.location.reload(); + },100) } }); }; diff --git a/src/view/home/index.vue b/src/view/home/index.vue index b65b23e..f2721a3 100644 --- a/src/view/home/index.vue +++ b/src/view/home/index.vue @@ -40,10 +40,10 @@
- - - - + + + +
@@ -82,6 +82,9 @@

{{ targetInfo.new_name }}

+

+ {{ targetInfo.subtitle }} +

{{ targetInfo.reporter }}


@@ -177,11 +180,13 @@ export default { }; }, mounted() { - var index = sessionStorage.getItem("index"); this.dataIndex = index ? index : 0; - - this.getCurrentDateMaxDay(); + this.getCurrentDateMaxDay(); + console.log(this.$route.query.id) + if(typeof (this.$route.query.id)!='undefined'){ + this.getInfo(this.$route.query.id); + } //document.title =this.data.list[this.dataIndex].editionName; // var newInfo = sessionStorage.getItem("newInfo"); // if (newInfo) { @@ -193,7 +198,7 @@ export default { }, methods: { - openType(item){ + openType(item) { console.log(item); this.typeId = item.id; this.getCurrentDateMaxDay(); @@ -261,28 +266,50 @@ export default { } }, getTypeList() { - axios.post("http://csdzb.hschool.com.cn/api/dzb/type/index") + axios.post("https://jinrigushi.gushitv.com/api/dzb/type/index") .then(response => { console.log(response); this.typeList = response.data.data; var typeId = sessionStorage.getItem("typeId"); - if(typeId){ - this.typeId=typeId; - }else{ + if (typeId) { + this.typeId = typeId; + } else { this.typeId = response.data.data[0].id; } this.getCurrentDateMaxDay(); }) .catch(error => console.error('Error loading the JSON file:', error)) }, + getInfo(item) { + axios.post("https://jinrigushi.gushitv.com/api/h5/news/find", {id: item}) + .then(response => { + // 使用导入的数据 + //activeDate.value = response.data; + var info = response.data.data; + //info.content = info.content.replace(/href="\/dist\//g, 'href="/h5/'); + //console.log(item.time); + //const targetData = response.data.list.find(data => data.numberDate == item.time); + //activeDate.value = info; + //console.log(activeDate.value) + this.targetInfo = info; + sessionStorage.setItem("newInfo", JSON.stringify(info)); + this.showInfo = true; + }) + .catch(error => console.error('Error loading the JSON file:', error)) + }, openBm(d) { this.dataIndex = d; sessionStorage.setItem("index", d); sessionStorage.removeItem("newInfo"); this.showInfo = false; - console.log(); - document.title = '固始电子报-' + this.data[d].bm_name; - window.location.reload(); + //document.title = '固始电子报-' + this.data[d].bm_name; + let url = window.location.href; + url = url.replace(/&id=\d+/, ''); + url = url.replace(/\?id=\d+/, ''); + window.location.href = url; + setTimeout(()=>{ + window.location.reload(); + },100) //var img=this.data.list[d].imageSrc; //$('#BantuTop').attr("src",img) //BantuTop @@ -296,54 +323,89 @@ export default { }, getCurrentDateMaxDay() { var activeDate = $('input[name="activeDate"]').val(); + var querySatus=''; var storageTimeYear = sessionStorage.getItem("year"); var storageTimeMonth = sessionStorage.getItem("month"); var storageTimeDay = sessionStorage.getItem("day"); if (storageTimeYear && storageTimeMonth && storageTimeDay) { activeDate = storageTimeYear + "-" + storageTimeMonth; } + console.log(this.$route.query.date); + if (typeof (this.$route.query.date) != 'undefined') { + activeDate = this.$route.query.date; + activeDate = activeDate.substring(0, 7); // + } + if (typeof (this.$route.query.status) != 'undefined') { + querySatus=this.$route.query.status; + } console.log(activeDate); - axios.post("http://csdzb.hschool.com.cn/api/dzb/date/index", {date: activeDate}) + axios.post("https://jinrigushi.gushitv.com/api/dzb/date/index", {date: activeDate,status:querySatus}) .then(response => { console.log(response); - if(response.data.data.length==0){ - alert('该分类没有数据'); + if (response.data.data.length == 0) { + alert('本月没有数据'); sessionStorage.removeItem("typeId"); sessionStorage.removeItem("DateIndex"); sessionStorage.removeItem("newInfo"); sessionStorage.removeItem("DateList"); - window.location.reload(); + window.location.href = "https://jinrigushi.gushitv.com/"; return; } // 使用导入的数据 var resIndex = response.data.data.length - 1; console.log('********', resIndex); sessionStorage.setItem('DateList', JSON.stringify(response.data.data)); + sessionStorage.setItem('DateIndex', resIndex); $('input[name="activeDate"]').val(response.data.data[resIndex].datetime); this.datetime = this.getCurrentDateFormatted(response.data.data[resIndex].datetime); + document.title = '《今日固始》电子版-' + this.datetime; this.getBm(); }) .catch(error => console.error('Error loading the JSON file:', error)) }, getBm() { - var list = JSON.parse(sessionStorage.getItem('DateList')); + + var seList=sessionStorage.getItem('DateList') + console.log('********',seList); + var list = JSON.parse(seList); + console.log('********',this.$route.query.date); var storageTimeYear = sessionStorage.getItem("year"); var storageTimeMonth = sessionStorage.getItem("month"); var storageTimeDay = sessionStorage.getItem("day"); - if (storageTimeYear && storageTimeMonth && storageTimeDay) { - var activeDate = storageTimeYear + "-" + storageTimeMonth + '-' + storageTimeDay; - const targetData = list.find(item => item.datetime == activeDate); + if (typeof (this.$route.query.date) != 'undefined') { + const targetData = list.find(item => item.datetime == this.$route.query.date); + console.log(targetData) + if(typeof (targetData)=='undefined'){ + alert('当日没有报纸!'); + sessionStorage.removeItem("typeId"); + sessionStorage.removeItem("DateIndex"); + sessionStorage.removeItem("newInfo"); + sessionStorage.removeItem("DateList"); + sessionStorage.removeItem("year"); + sessionStorage.removeItem("month"); + sessionStorage.removeItem("day"); + window.location.href = "https://jinrigushi.gushitv.com/"; + return; + } var id = targetData.id; - } else { - var index = sessionStorage.getItem('DateIndex'); - var id = list[index].id; + }else{ + if (storageTimeYear && storageTimeMonth && storageTimeDay) { + var activeDate = storageTimeYear + "-" + storageTimeMonth + '-' + storageTimeDay; + console.log(activeDate) + const targetData = list.find(item => item.datetime == activeDate); + console.log(targetData) + var id = targetData.id; + } else { + var index = sessionStorage.getItem('DateIndex'); + var id = list[index].id; + } } - axios.post("http://csdzb.hschool.com.cn/api/dzb/bm/index", {date_id: id}) + axios.post("https://jinrigushi.gushitv.com/api/dzb/bm/index", {date_id: id}) .then(response => { console.log(response); this.data = response.data.data; - document.title = '固始电子报-' + this.data[this.dataIndex].bm_name; + this.loadScripts([ '/dist/public/static/js/jquery.min.js', '/dist/public/static/js/jquery-ui.js', @@ -373,13 +435,36 @@ export default { }, Promise.resolve()); }, openNews(area) { - var info = this.data[this.dataIndex].news; - var targetInfo = info.find(item => item.id === area.id); - this.targetInfo = targetInfo; - sessionStorage.setItem("newInfo", JSON.stringify(targetInfo)); - this.showInfo = true; + //var info = this.data[this.dataIndex].news; + //var targetInfo = info.find(item => item.id === area.id); + //this.targetInfo = targetInfo; + //sessionStorage.setItem("newInfo", JSON.stringify(targetInfo)); + //this.getInfo(area.id); + //this.showInfo = true; // 实现日期搜索逻辑 + //this.showInfo = true; + let url = window.location.href; + //console.log(url) + if (url.indexOf("?") === -1) { + url += "?id=" + area.id; + } else { + // 检查是否已经包含了相同的参数 + if (url.indexOf("id=") === -1) { + //修改ID后面的参数 + url += "&id=" + area.id; + } else { + + // 如果已经包含了相同的参数,我们不做任何操作 + url = url.replace(/id=\d+/, 'id=' + area.id); + } + } + window.location.href = url; + console.log(url) + setTimeout(()=>{ + window.location.reload(); + },100) }, + goHome() { sessionStorage.removeItem("year"); sessionStorage.removeItem("month"); @@ -387,7 +472,13 @@ export default { sessionStorage.removeItem("index"); sessionStorage.removeItem("newInfo"); this.showInfo = false; - window.location.reload(); + let url = window.location.href; + url = url.replace(/&id=\d+/, ''); + url = url.replace(/\?id=\d+/, ''); + window.location.href = url; + setTimeout(()=>{ + window.location.reload(); + },100) }, } }; diff --git a/src/view/home/knowledge.vue b/src/view/home/knowledge.vue index d01929c..2d3fba8 100644 --- a/src/view/home/knowledge.vue +++ b/src/view/home/knowledge.vue @@ -132,7 +132,7 @@ onMounted(() => { }); const getInfo = () => { - axios.post("http://csdzb.hschool.com.cn/api/dzb/zsk/find", {id: infoId.value}) + axios.post("https://jinrigushi.gushitv.com/api/dzb/zsk/find", {id: infoId.value}) .then(response => { console.log(response) aiInfo.value=response.data.data;