filesbox/web/dist/design/designstatic/front/js/caseshow.js
2024-07-26 14:10:54 +08:00

2 lines
5.6 KiB
JavaScript

var wapurl=window.location.origin+"/pages/wap/newslist.html";if(/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)&&(window.location.href=wapurl+"?busType=7"),!cdnPath)var cdnPath="";var peIde=getPar("typeId")?getPar("typeId"):"",infoValue=getPar("infoValue")?getPar("infoValue"):"1",infoValuePeIde=getPar("typeId")?getPar("typeId"):"",peId,peId2,peId3,peId4,peId5,item,item2,item3,item4,item5;function resetImgSrc(a){var t=a.replace(/([^.]*).([^.]*)$/g,"$1!medium.$2");return t}function coverError(a){var t=event.target;parseInt(t.dataset.errorcount)==0?(t.setAttribute("data-errorcount",1),t.src=a):parseInt(t.dataset.errorcount)==1&&(t.setAttribute("data-errorcount",2),t.src="/static/common/image/information/defult.jpg")}function list(a,t,r){$.ajax({type:"GET",headers:{token:getCookie("token")},url:"/api/common/getHomepageList?projectid=41",contentType:"application/json",dataType:"json",data:{infoTypeId:a,currentPage:t,pageSize:20,keywords:r,infoType:"7"},async:!0,success:function(e){for(var i=e.data.list,n="",o=0,s=i.length;o<s;o++){var c=i[o].commonHomepageInfoId,u=getTimeZhCN(i[o].gmtModified),p=i[o].computerPicPath,d=i[o].infoType=="1",l=p?JSON.parse(p):[],h=l&&l.length?l[0].sourcePath:"/static/common/image/information/defult.jpg",v=location.port=="81"?"/pages/information.html?aid="+c:"/information/"+c+".shtml",I=i[o].introduce.replace(/<[^>]+>/g,"");n+="<li>",n+=' <a href="'+v+'" target="_blank">',n+=" <img src="+(cdnPath+resetImgSrc(h))+' data-errorcount="0" onerror="coverError(&quot'+cdnPath+h+'&quot)" >',n+=' <div class="detail" >',n+=" <h2>",n+=i[o].title,n+=" </h2>",n+=" <p>",n+=u,n+=" </p>",n+=" </div>",n+=" </a>",n+="</li>"}$("#pagination2").pagination({currentPage:t,totalPage:Math.ceil(e.data.total/20),isShow:!1,count:20,prevPageText:"<",nextPageText:">",callback:function(f){list(a,f)}}),i.length==0?$(".plate-navcm").html("<div class='nodata'></div>"):$(".plate-navcm").html(n)}})}list(peIde,1),function(a,t){var r={init:function(){this.getListHomepageSetting()},getListHomepageSetting:function(){var e=this;a.ajax({type:"GET",url:"/api/common/listHomepageSetting",contentType:"application/json",dataType:"json",data:{busType:"7"},async:!0,success:function(i){window.classifyData=i.data;var n=i.data,o=n;parseInt(infoValue)==0&&(o=e.getParentObj(n,peIde,!0)),e.renderNav(o,peIde),e.filterrigEvent(o)}})},renderNav:function(e,i){for(var n=this,o="",s=e,c=e,u=1,p=n.getParentObj(e,i),d=parseInt(u)==1,l=0,h=p.length;l<h;l++){var v=p[l-1]||0,I=p[l];if(s=c,parseInt(u)==0&&p[l]==infoValuePeIde&&(d=!0),s&&d){I?o+='<div class="plate-nav"> <a class="pid" tabs="'+v+'" href="javascript:void(0);">\u5168\u90E8</a>':o+='<div class="plate-nav"> <a class="pid curs" tabs="0" href="javascript:void(0);">\u5168\u90E8</a>';for(var f=0,m=s.length;f<m;f++){var g=s[f];parseInt(I)==parseInt(g.commonHomepageInfoTypeId)?(c=g.children,o+='<a class="pid curs" tabs="'+g.commonHomepageInfoTypeId+'" href="javascript:void(0);">'+g.typeName+"</a>"):o+='<a class="pid" tabs="'+g.commonHomepageInfoTypeId+'" href="javascript:void(0);">'+g.typeName+"</a>"}o+="</div>"}else if(s)for(var f=0,m=s.length;f<m;f++){var g=s[f];parseInt(I)==parseInt(g.commonHomepageInfoTypeId)&&(c=g.children)}}a(".filterrig .plate-nav").html(o)},getParentObj:function(e,i,n){var o="",s=e;function c(u,p,d){for(var l=0,h=u.length;l<h;l++){var v=u[l];if(parseInt(v.commonHomepageInfoTypeId)==parseInt(p))s=u,o=d+v.commonHomepageInfoTypeId+",";else if(v.children){var I=d+v.commonHomepageInfoTypeId+",";c(v.children,p,I)}}}return c(e,i,[]),n?s:o.split(",")},filterrigEvent:function(e){var i=this;a(".searchtxt").on("keypress",function(n){n.keyCode==13&&(t.keyWord=a(this).val(),list(t.peIde,1,t.keyWord))}),a(".filterrig").on("click","a",function(){var n=a(this);if(n.hasClass("searchbtn"))t.keyWord=a(".searchtxt").val(),list(t.peIde,1,t.keyWord);else{var o=n.attr("tabs");t.peIde=o,i.peId=o,i.renderNav(e,o),list(t.peIde)}})}};r.init()}(jQuery,window),Date.prototype.format=function(a){var t={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};/(y+)/.test(a)&&(a=a.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length)));for(var r in t)new RegExp("("+r+")").test(a)&&(a=a.replace(RegExp.$1,RegExp.$1.length==1?t[r]:("00"+t[r]).substr((""+t[r]).length)));return a};function getTimeZhCN(a,t){if(new Date(parseInt(a))=="Invalid Date"&&new Date(parseInt(a)*1e3)=="Invalid Date")return"--";new Date(parseInt(t))=="Invalid Date"&&new Date(parseInt(t)*1e3)=="Invalid Date"&&(t=Date.parse(new Date));var r=t-a;if(r<0)return"\u521A\u521A";if(r<6e4)return parseInt(r/1e3,10)+"\u79D2\u524D";if(r<3600*1e3)return parseInt(r/1e3/60,10)+"\u5206\u949F\u524D";if(r<24*3600*1e3)return parseInt(r/1e3/3600,10)+"\u5C0F\u65F6\u524D";if(r<7*24*3600*1e3)return parseInt(r/1e3/3600/24,10)+"\u5929\u524D";if(r<30*24*3600*1e3)return parseInt(r/1e3/3600/24/7,10)+"\u5468\u524D";if(r<365*24*3600*1e3)return parseInt(r/1e3/3600/24/30,10)+"\u4E2A\u6708\u524D";var e=new Date(parseInt(a)),i=parseInt(e.getMonth()+1)<10?"0"+(e.getMonth()+1):e.getMonth()+1,n=parseInt(e.getDate())<10?"0"+e.getDate():e.getDate(),o=parseInt(e.getHours())<10?"0"+e.getHours():e.getHours(),s=parseInt(e.getMinutes())<10?"0"+e.getMinutes():e.getMinutes();return e.getFullYear()+"-"+i+"-"+n+" "+o+":"+s}function getPar(a){var t=document.location.href,r=t.indexOf(a+"=");if(r==-1)return!1;var e=t.slice(a.length+r+1),i=e.indexOf("&");return i!=-1&&(e=e.slice(0,i)),e}function getCookie(a){for(var t=document.cookie,r=t.split("; "),e=0;e<r.length;e++){var i=r[e].split("=");if(i[0]==a)return i[1]}return""}