//通过相关链接跳转到详情页 function jumpLink(link,zlflag) { var url = zlflag == '8'?'fwtz/detail':'sscx/toDetail'; location.href = './detailall.html?id='+link.substring(10)+'&url='+url+'&app_token=&rooter='; } var detailallLogInfo = { module : '', id : '', tag: '', title : '' } $.noConflict();//jquery 放弃 $ // jQuery('.emwpic').qrcode({ // render: "img", //也可以替换为table // width: 200, // height: 200, // text: self.location.href.replace('.html','Share.html')/*可以通过ajax请求动态设置*/ // }) jQuery('.dialog_ewm').qrcode({ render: "img", //也可以替换为table width: 500, height: 500, text: self.location.href.replace('.html','Share.html')/*可以通过ajax请求动态设置*/ }) var to_speak = window.speechSynthesis;//语音对象 $('.iconvp_read').on('click', playVoice); $('.iconvp_stop').on('click', pause); $('.iconvp_play').on('click', resume); $('.iconvp_end').on('click', cancel); function playVoice() { loadLogScript(jslog + "/js/arlog.js?time=" + new Date().getTime(), "arlogAnchor", { "data-module": detailallLogInfo.module + '_yybf', "data-id": detailallLogInfo.id, "data-tag": detailallLogInfo.tag, "data-title": detailallLogInfo.title }); if(window.sessionStorage.getItem("rooter") == 'android'){ window.android.audioPlay($('.bd').text()); showVoiceBtn(0,1,0,1); return; } if(!window.speechSynthesis){ $.toast("对不起,您的浏览器不支持文字转语音"); return; } var voices = window.speechSynthesis.getVoices(); var flag = false; if(voices){ var lang = ""; for (var i = 0; i < voices.length&&!flag; i++) { lang = voices[i].lang; if(lang == 'zh-CN' || lang == 'zh_CN'){ to_speak.voice = voices[i]; flag = true; } } } if (!flag) { $.toast("对不起,您的浏览器不支持中文语音"); return; } if (window.sessionStorage.getItem("rooter") == 'android') { window.android.playVoiceAndroid(); } window.speechSynthesis.cancel(); to_speak = new SpeechSynthesisUtterance($('.bd').text()); to_speak.onend = function (){ showVoiceBtn(1,0,0,0); } window.speechSynthesis.speak(to_speak); showVoiceBtn(0,1,0,1); } //暂停 function pause() { if(window.sessionStorage.getItem("rooter") == 'android'){ window.android.audioStop(); } else { window.speechSynthesis.pause(); } showVoiceBtn(0,0,1,1); } //继续 function resume() { if(window.sessionStorage.getItem("rooter") == 'android'){ window.android.audioResume(); } else { window.speechSynthesis.resume(); //继续 } showVoiceBtn(0,1,0,1); } //停止语音 function cancel(){ if(window.sessionStorage.getItem("rooter") == 'android'){ window.android.audioEnd(); } else { window.speechSynthesis.cancel(); } showVoiceBtn(1,0,0,0); } //根据参数显示语音按钮 function showVoiceBtn(read, stop, play, end){ if(read == 1)$('.iconvp_read').show(); else $('.iconvp_read').hide(); if(stop == 1)$('.iconvp_stop').show(); else $('.iconvp_stop').hide(); if(play == 1)$('.iconvp_play').show(); else $('.iconvp_play').hide(); if(end == 1)$('.iconvp_end').show(); else $('.iconvp_end').hide(); } /*页面跳转或者回退刷新时,处理语音未关闭bug*/ window.onbeforeunload = function (event){ cancel(); }; window.addEventListener('pagehide', function(event) { cancel(); }); $(document).on("pageInit", "#detaillAll", function(e, id, page) { // if (window.sessionStorage.getItem("rooter") == null || window.sessionStorage.getItem("rooter") == '') { // $('#fjList').find('h3').text('附件下载(iOS系统请使用Chrome或UC)'); // } else { // $('#fjList').find('h3').text('附件下载'); // } // 回退绑定 $(".go2back").off("click"); CommonUtil.go2Back(); //绑定回退事件 $('.go2back').click(function () { cancel(); }); // 弹出分享层 $('#shareA').click(function () { var rooter = window.sessionStorage.getItem("rooter");//判断是app还是wap if (rooter != null && rooter != '') { if (rooter == 'android') { window.android.shareToAndroid(self.location.href.replace('.html', 'Share.html'), $('#shareTitle').text().substring(0, 100)); } else if (rooter == 'ios') { window.webkit.messageHandlers.shareToIOS.postMessage({ 'url': self.location.href.replace('.html', 'Share.html'), 'ms': $('#shareTitle').text().substring(0, 100) }); } loadLogScript(jslog + "/js/arlog.js?time=" + new Date().getTime(), "arlogAnchor", { "data-module": detailallLogInfo.module + '_fx', "data-id": detailallLogInfo.id, "data-tag": detailallLogInfo.tag, "data-title": detailallLogInfo.title }); } else { $('.mask,.dialog_share').show(); } }); // 字体大小 $('.bar-nav .icon_more').click(function () { $('.mask,.dialog.dialog_confirm.dialog_fontsize').toggle(); }); $('.mask').click(function () { $('.mask,.dialog.dialog_confirm.dialog_fontsize').hide(); }); $('.dialog.dialog_confirm.dialog_fontsize .btn_cancel').click(function () { $('.mask,.dialog.dialog_confirm.dialog_fontsize').hide(); }); $('.dialog.dialog_confirm.dialog_fontsize .dialog_bd .alink').click(function () { let fontList = $('.dialog.dialog_confirm.dialog_fontsize .dialog_bd .alink'); for (let i = 0; i < fontList.length; i++) { $(fontList[i]).removeClass('curr'); } $(this).addClass('curr'); var fontSize = ''; if ($(this).text().indexOf("小") != -1) { fontSize = 'smaller'; } else if ($(this).text().indexOf("中") != -1) { fontSize = 'medium'; } else if ($(this).text().indexOf("大") != -1 && $(this).text().indexOf("超大") == -1) { fontSize = 'large'; } else if ($(this).text().indexOf("超大") != -1) { fontSize = 'x-large'; } saveFontSize(fontSize); $('.bd').css('font-size', fontSize); $('.bd p').css('font-size', fontSize); $('.bd span').css('font-size', fontSize); $('.bd font').attr('size', fontSize); }); //关闭分享层 $('.dialog_share .btn_cancel,.mask').click(function () { $('.mask,.dialog_share,.mask,.dialog_ewm').hide(); }) //显示二维码 $('.ewmfixed').click(function () { $('.mask,.dialog_ewm').show(); }); // 收藏事件全局toast $('.bar-tool #detaill-coll').click(function(){ var url = "userCollection/cache/saveCollection"; /*if ($(".icon_like").length > 0) {//页面上显示的是未收藏图标 url = "userCollection/saveCollection/redis"; } else { return; }*/ var id = queryString('id'); var detailUrl = queryString('url'); var ywid = id; var lmmc; var lmbh; var sclink; var zlflag = $("#zlflag").val(); if ("sscx/toDetail" == detailUrl) { if (zlflag == '1') { lmmc = "法规"; } else if (zlflag == '2') { lmmc = "问答"; } else if (zlflag == '3') { lmmc = "指南"; } sclink = "/sscx/toDetail?id=" + id; lmbh = 'sscx'; } else if ('fwtz/detail' == detailUrl) { lmmc = "通知"; sclink = "/fwtz/detail?id=" + id; lmbh = 'fwtz'; } else if ('sscx/rdDetail' == detailUrl) { lmmc = "热点"; sclink = ""; lmbh = "rdwt"; }else if('bszn/getOneBszn' == detailUrl){ lmmc = "办税指南"; sclink = "/bszn/getOneBszn?id="+id; lmbh = "bszn"; } var scbt = $('.article-title').html().replace('“', '').replace('”', ''); if ("sscx/toDetail" == detailUrl || 'fwtz/detail' == detailUrl || 'sscx/rdDetail' == detailUrl||'bszn/getOneBszn' == detailUrl) { request({ type: 'post', url: url, data: { "lmbh": Base64.encode(lmbh), "ywid": ywid, "lmmc": Base64.encode(lmmc), "scbt": Base64.encode(scbt), "sclink": sclink } }, function (response) { var results = JSON.parse(response); if (results.code == '1') { var like = $('.bar-tool #detaill-coll'); //查找未收藏图标 if (results.data == 0) { like.removeClass("icon_like"); like.addClass("icon_liked");//调整为收藏图标 like.html('已收藏'); $('.toast_unlike').hide(); $('.toast_like').show(); setTimeout(function() { $('.toast_like').hide() }, 2000); } else { like.removeClass("icon_liked"); like.addClass("icon_like");//调整为收藏图标 like.html('收藏'); $('.toast_like').hide(); $('.toast_unlike').show(); setTimeout(function() { $('.toast_unlike').hide() }, 2000); } } else{ $.toast(results.msg); } }) } }); /*获取页面url中特定参数*/ function queryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } function Detail() { this.id = queryString('id'); this.url = queryString('url'); this.dom = $('.hd'); this.keys = { 'service/train/detail': 'id', 'bsznBLH/getOneBszn': 'bh', 'fwtz/detail': 'bh', 'sscx/toDetail': 'zlcode', 'zbhz/detail/data': 'id', 'video/getVideoDetail': 'bh', 'sscx/rdDetail': 'bh', 'bszn/getOneBszn':'bh' }; this.to_speak;//语音对象 this.voiceStart = $('.iconvp_read'); //语音播放、启动按钮 this.voiceController = $('.iconvp_stop');//语音操作块, 暂停和继续 this.voiceEnd = $('.iconvp_end');//语音停止按钮 } /** * 自动补0的方法 * */ function PrefixInteger(num, length) { return (Array(length).join('0') + num).slice(-length); } /*获取详情数据*/ Detail.prototype.getData = function () { var that = this; var tag = ""; var title = ""; request({ type: 'get', url: this.url, data: { [this.keys[this.url]]: this.id } }, function (response) { var results = JSON.parse(response); /** * 通知详情 * */ if (that.url === 'fwtz/detail') { // 获取埋点类型 tag = results.data.lb; title = results.data.bt; item = results.data; $("header .title").html("通知详情"); that.dom.find('.article-title').html(item.bt); $('.bd').html(item.nr); //机构 that.dom.find('.l_icon_from').html("" + item.cjjgmc); //时间 if (item.cjsj != null && item.cjsj != '') { var date = new Date(Date.parse(item.cjsj.replace('年','-').replace('月','-').replace('日','').replace(/-/g, "/"))); that.dom.find('.l_icon_time').html("" + date.getFullYear()+'-'+PrefixInteger((date.getMonth() + 1),2)+'-'+PrefixInteger(date.getDate(),2)); } showFjList(item.fileList, 0); } else if (that.url === 'sscx/toDetail') { // 获取埋点类型 tag = results.bean.ZLTYPE; title = results.bean.ZLTITLE; item = results.bean; that.dom.find('.article-title').html(item.ZLTITLE); var zlnrObj = $('
' + item.ZLCLJNR + '
'); var linkInfo = zlnrObj.find('a'); var codes = ""; var zlCode = []; if (linkInfo.length > 0) { for (var i = 0; i < linkInfo.length; i++) { var $this = $(linkInfo[i]); var zlFunc = $this.attr("onclick"); if (zlFunc) { var code = zlFunc.substring(zlFunc.indexOf("'") + 1, zlFunc.lastIndexOf("'")); $this.attr("class", code); codes = codes + code + ","; zlCode.push(code); } } } if (codes.length > 0) { codes = codes.substring(0, codes.length - 1); //得到附件列表 request({ type: 'post', url: 'sscx/getSfyx', data: {code: codes}, async: false, }, function(response) { res = JSON.parse(response); if (res && res.data && res.code == '1') { for(var k in res.data){ var sfyx=res.data[k]; if (sfyx != '0') { var zlLinkObj = zlnrObj.find('.' + k); if (zlLinkObj.length > 0) { for (var j = 0; j < zlLinkObj.length; j++) { var $this = $(zlLinkObj[j]); $this.removeAttr("onclick"); $this.removeAttr("style"); $this.html($this.find('strong').html()); $this.css('cursor','unset'); $this.removeClass('hover'); $this.css('color', '#000'); } } } } } }) } if (zlnrObj.length > 0) { for (var i = 0; i < zlnrObj.length; i++) { if (i == 0) { $('.bd').html(zlnrObj[i].innerHTML); } else { $('.bd').append(zlnrObj[i].innerHTML); } } } // $('.bd').html(item.ZLCLJNR); var zlwh = item.ZLWH; //需要这个值,用来判断栏目 $("#zlflag").val(item.ZLFLAG); var jg; var time=item.ZLFBRQ; if (item.ZLFLAG == '1') { // 法规使用发文日期 time = item.ZLBFRQ; } if (item.ZLFLAG == '3' || item.ZLFLAG == '2') { if(zlwh){ that.dom.find('#wenhao').show(); that.dom.find('#wenhao').html(zlwh); }else{ that.dom.find('.wenhao').hide(); } $('.l_icon_from').hide(); if(item.ZLFLAG == '3'){ $("header .title").html("指南详情"); } else { $("header .title").html("问答详情"); } } else { // 法规数据 that.dom.find('#detail_oth').hide(); that.dom.find('#detail_fg').show(); if(zlwh){ that.dom.find('#wenhao1').show(); that.dom.find('#wenhao1').html('' + zlwh); }else{ that.dom.find('#wenhao1').hide(); } jg = item.ZLFWDW?item.ZLFWDW:'发布机构'; //机构 that.dom.find('.l_icon_from').html("" + jg); $("header .title").html("法规详情"); } //时间 if (time != null && time != '') { var date = new Date(Date.parse(time.replace('年','-').replace('月','-').replace('日','').replace(/-/g, "/"))); that.dom.find('.l_icon_time').html("" + date.getFullYear()+'-'+PrefixInteger((date.getMonth() + 1),2)+'-'+PrefixInteger(date.getDate(),2)); } //得到附件列表 request({ type : 'get', url : 'sscx/getFileList', data: { "ywid": queryString("id") } }, function(response) { response = JSON.parse(response); showFjList(response.data, 1); }) } else if (that.url === 'bszn/getOneBszn') { // 获取埋点类型 // tag = results.data.ZLTYPE; title = results.data.BT; //办税指南 item = results.data; that.dom.find('.article-title').html(item.BT); $('.bd').html(item.NR); that.dom.find('.l_icon_from').hide(); that.dom.find('.l_icon_time').html("" + item.CJSJ.substr(0,10)); //得到附件列表 request({ type : 'get', url : 'sscx/getFileList', data: { "ywid": queryString("id") } }, function(response) { response = JSON.parse(response); showFjList(response.data, 1); }) } else if (that.url === 'sscx/rdDetail') { // 获取埋点类型 tag = results.data.lbbm; title = results.data.rdwtbt; item = results.data; that.dom.find('.article-title').html(item.rdwtbt); $('.bd').html(item.rdwtnr); that.dom.find('.wenhao').hide(); $('.l_icon_from').hide(); $("header .title").html("热点问题"); var time=item.fbsj; //时间 if (time != null && time != '') { var date = new Date(Date.parse(time.replace('年','-').replace('月','-').replace('日','').replace(/-/g, "/"))); that.dom.find('.l_icon_time').html("" + date.getFullYear()+'-'+PrefixInteger((date.getMonth() + 1),2)+'-'+PrefixInteger(date.getDate(),2)); } //得到附件列表 request({ type : 'get', url : 'sscx/toFjList', data: { "code": queryString("id") } }, function(response) { response = JSON.parse(response); showFjList(response); }) } //显示二维码 $('.ewmfixed').show(); // 日志埋点 rdata-module="栏目编号" data-tag="类别编码" data-id="数据id" data-title="数据标题" var id = queryString('id'); var detailUrl = queryString('url'); var lmbh; if ("sscx/toDetail" == detailUrl) { lmbh = 'sscx'; } else if ('fwtz/detail' == detailUrl) { lmbh = 'fwtz'; } else if ('sscx/toDetail' == detailUrl) { lmbh = 'rdwt'; } else if ('sscx/rdDetail' == detailUrl) { lmbh = 'rdzs'; } // 判断类别是否转换 var tagList = tag.split('“'); if (tagList.length >3) { // 未转换 tag = tagList[2]; } else if (tagList.length !== 1) { // 出错 tag = ""; } detailallLogInfo.module = lmbh; detailallLogInfo.id = id; detailallLogInfo.tag = tag; detailallLogInfo.title = title; // 办税指南去除特殊符号导致埋点失败 detailallLogInfo.title = detailallLogInfo.title.replace("—", " "); title = detailallLogInfo.title.replace("—", " "); loadLogScript(jslog+"/js/arlog.js?time="+new Date().getTime(),"arlogAnchor",{"data-module":lmbh,"data-id":id,"data-tag":tag,"data-title":title}); loadFontSize(); }) }; /** * 检测是否已经被收藏 */ Detail.prototype.checkCollect = function () { var that = this; var id = this.id; request({ type: 'get', url: 'userCollection/cache/check', data: { "ywid":id } }, function (response) { var results = JSON.parse(response); if (results.code == '1') { var like = $('.icon_like'); //查找未收藏图标 if(like) { like.removeClass("icon_like"); like.addClass("icon_liked");//调整为收藏图标 like.html('已收藏'); } } else { var liked = $('.icon_liked'); //查找已经收藏图标 if(liked) { liked.removeClass("icon_liked"); liked.addClass("icon_like");//调整为收藏图标 liked.html('收藏'); } } }) }; /** * 获取相关链接 */ Detail.prototype.checkLink = function () { var id = this.id; request({ type: 'get', url: 'sscx/toXgzsList', data: { "code":id } }, function (response) { var data = JSON.parse(response).data; if (data && data.length > 0) { $('.bdlist').show(); var ul = $('.bdlist ul'); ul.empty(); for (var i = 0; i < data.length; i++) { var code = 'zrarString' + data[i].ZLCODE; ul.append('