document.write(""); document.write(""); // 以下参数根据需求进行配置 var BMListModeType = 2; // 版面列表显示类型。1:左侧弹出 2:居中显示 var calendarMode = 1; //1:传统日历 2:列表日历需要配合自定义json日历数据 var ifMaxShowDate = false;//是否开启过滤日期(开启:true,关闭:false) var MaxshowData = 10; //最多能看7天 var pageDirection = "horizontal"; // 版面图滑动 horizontal横向滚动,vertical竖向滚动 var layoutStyle = "festival" //版面图样式 routine:常规, festival:节日,solemn:庄严 var HaiBaoType = "multi"; //single:单版模板 multi:多版模式,多版面时:需要加载:document.write(""); @import url("../js20/poster/posterShare.css"); // 主程序 var month = getDate("month");//获取当前月份 $(function () { $('body').css('opacity',1); if (!DateMaxDiff(1)) { alert("对不起,只能查看最新七天数据!"); location.href = "../../../paperindex.htm"; return; } // 模式2初始化年份日历 if (calendarMode == 2) { initYearList(); } //日历实例化 $('.form_date').datetimepicker({ pickerPosition: "top-right", bootcssVer: 3, format: "yyyy-mm-dd", language: "zh-CN", weekStart: 1, autoclose: 1, startView: 2, minView: 2, forceParse: 0, viewSelect: "month", initialDate: getDate("day"), }).on("show", function (ev) { console.log(month); displayDate(month); //$(".datetimepicker-days th.switch").addClass("disabled"); }).on('changeDate', function (ev) { var date = new Date(ev.date.valueOf()); var year = date.getFullYear(); var month = date.getMonth() + 1; month = month < 10 ? ("0" + month) : month; var day = date.getDate(); day = day < 10 ? ("0" + day) : day; var url = "#"; //var curDate = year+""+appendZero(month)+""+appendZero(day); //if (curDate<=20191231){ // location.href = "https://epaper.guanhai.com.cn/qdrb/"+curDate; //} var isUseful = checkUrl(url); if (isUseful) { location.href = url; } hideAll(); //$('.mask').removeClass('active'); }); //导航栏日期显示 // $('body .datetimeBtn').text(getDate("day")); // 底部按钮切换 $('.footerWrap').on('click', '.item', function () { //$(this).toggleClass('active'); //$(this).parent('.item').siblings('.item').find('.text').removeClass('active'); $('.mask').toggleClass('active'); // 版面列表显示 var btn=$(this).children()[1]; if (btn.classList.contains('layoutBtn')) { if (BMListModeType == 1) { $('.layoutStyleOne').toggleClass('active'); } else if (BMListModeType == 2) { $('.layoutStyleTwo').toggleClass('active'); $(".cancelBox").show() } } // 版面文章目录显示 if (btn.classList.contains('articleBtn')) { $('.articleList').toggleClass('active'); $(".cancelBox").show(); } //日历显示 if (btn.classList.contains('datetimeBtn')) { showDate(); } // 跳转下载页面 if (btn.classList.contains('synthesis')) { // window.location.href='synthesis.html'; // $('.mask').removeClass('active'); $('.synthPage').addClass('active'); synthBox(); } //更多显示的弹层 if (btn.classList.contains('more')) { $(this).siblings('.exareBox').toggleClass('active'); } }) // 点击遮罩 $('.mask').on('click', function () { hideAll(); }) // 点击取消按钮 $('.cancelBox').on('click', function () { hideAll(); }) //监听切换月份 var i = 0; $(".datetimepicker-days tbody").bind("DOMNodeInserted", function () { if (i == 5) { var date = $(".datetimepicker-days thead th.switch").text().split(" "); console.log('2222222222222222',date) switch (date[0]) { case "一月": month = date[1] + "-01"; break; case "二月": month = date[1] + "-02"; break; case "三月": month = date[1] + "-03"; break; case "四月": month = date[1] + "-04"; break; case "五月": month = date[1] + "-05"; break; case "六月": month = date[1] + "-06"; break; case "七月": month = date[1] + "-07"; break; case "八月": month = date[1] + "-08"; break; case "九月": month = date[1] + "-09"; break; case "十月": month = date[1] + "-10"; break; case "十一月": month = date[1] + "-11"; break; case "十二月": month = date[1] + "-12"; break; } console.log('111111111111',month) displayDate(month); i = -1; } i++; }); //点击分享按钮 $('.synthesis').on('click', function () { if(HaiBaoType=="single"){//单版分享 $('.mask').toggleClass('active'); $('.synthPage').addClass('active'); synthBox(); }else if (HaiBaoType=="multi"){ //多版分享 var poster = POSTER('paperImg').show(''); } }); //关闭下载图片的弹层 $('.synthPage').on('click', '.closeBtn', function () { $('.synthPage').html(''); $('.synthPage,.mask,.synthesis').removeClass('active'); }); }) // 日历相关设置 //显示日期 function showDate() { if (calendarMode == 1) { $('.form_date').datetimepicker('update'); $(".form_date").datetimepicker("show"); $(".cancelBox").show() } else if (calendarMode == 2) { $("#Datefour").animate({ bottom: "48" }, "normal"); } } //隐藏日期 function hideDate() { if (calendarMode == 1) { $(".form_date").val(getDate("day")); $(".form_date").datetimepicker("hide"); } else if (calendarMode == 2) { $("#Datefour").animate({ bottom: "-100%" }, "normal"); } } //获取当前页日期 function getDate(str) { var activeDate = $('#activeDate').val(); console.log(activeDate); activeDate = new Date(activeDate); var initYear = activeDate.getFullYear(); var initMonth = activeDate.getMonth() + 1; var initDay = activeDate.getDate(); // var url = location.href; // var re = /(\d{4})\-(\d{2})\/(\d{2})/; // var r = url.match(re); //精确到日 if (str == "day") { var date = initYear + "-" + initMonth + "-" + initDay; //精确到月 } else if (str == "month") { var date = initYear + "-" + initMonth; } console.log(date); return date } //获取当前月份报纸xml数据 function getPaper(date) { var myXmlUrl = `/public/static/data/${date}.json`; var data = { 'day': [], 'url': [] }; $.ajax({ url: myXmlUrl, type: 'GET', dataType: 'xml', async: false, timeout: 1000, error: function (xml) { }, success: function (xml) { var date = new Array(); var day = new Array(); var url = new Array(); $(xml).find("date").each(function () { date.push($(this).text()); day.push(parseInt($(this).text().split("-")[2])) }); $(xml).find("url").each(function () { url.push($(this).text()); }); data = { "day": day, "url": url } } }); console.log('获取当前月份报纸xml数据:',date) return data } //需要黑色显示的日期数组 function displayDate(date) { console.log('需要黑色显示的日期数组:',date) var data = getPaper(date); var day = 1, count = 0, count2 = 0; $(".datetimepicker-days .day").each(function (i) { if (parseInt($(this).text()) > day) { $(this).html(""); count++ } else { day = parseInt($(this).text()) + 1; if ((i > 20) && (parseInt($(this).text()) < 14)) { $(this).html("").removeClass("active"); count2++; } } }); if (count == 7) { $(".datetimepicker-days tr:eq(2)").hide(); } if (count2 >= 7) { $(".datetimepicker-days tr:eq(7)").hide(); } $(".datetimepicker-days .day").each(function () { var index = data["day"].indexOf(parseInt($(this).text())) if (index == -1) { //var curDate = date.replace("-","")+appendZero(parseInt($(this).text())); //if (curDate<=20191231){ // $(this).attr('url',""); //}else{ $(this).addClass('old'); $(this).addClass('disabled'); //} } else { if (!ifMaxShowDate) { $(this).attr('url', data["url"][index]); } else { var temp = date.split("-"); temp = temp[0] + "/" + temp[1] + "/" + parseInt($(this).text()); if (DateMaxDiff(2, temp)) { $(this).attr('url', data["url"][index]); } else { $(this).addClass('old'); $(this).addClass('disabled'); } } } }); } function appendZero(n) { return (("00" + n).substr(("00" + n).length - 2)); } // 隐藏首页所有的弹层 function hideAll() { $('.layoutList').removeClass('active'); $('.footerWrap .item .text').removeClass('active') $('.mask').removeClass('active'); $('.articleList').removeClass('active'); $('.exareBox').removeClass('active') hideDate(); $(".cancelBox").hide() } //检查链接是否有效 function checkUrl(url) { isUseful = false; $.ajax({ url: url, type: 'GET', async: false, success: function (xml) { isUseful = true; } }); return isUseful } //取版面的ID function getCaption(obj) { var index = obj.lastIndexOf("_"); obj = obj.substring(index + 1, obj.length); obj=obj?obj.split('.')[0]:'' // console.log(obj); return obj; } //下载弹层 function synthBox() { var imgUrl = $('.thumbnail-left-left a img').attr('src') + '?=v1'; var date = window.location.href.match(/(\d{4})-(\d{2})\/(\d{2})/im)[0].replace("-", "年").replace("/", "月") + '日'; //日期 var week = getWeek(window.location.href.match(/(\d{4})-(\d{2})\/(\d{2})/im)[0].replace("/", "-")); //星期 // var html = '