portal html css js resource

discover.js 10KB

    //发现模块 $(function() { $(".headnav li").eq(1).addClass("navcurrent"); loginStatus();//判断个人是否登录 var userid = $.cookie("userid"); var exculdeIds=[]; var exculdeId2s=[]; //轮播加载页面 $.ajax({ "url":"/data/inc/col_banner.html", "dataType":"html", "success":function(result){ $(".slide-box").html(result); bannerRotate.bannerInit();// 轮播 for(var i=0;i<5;i++){ var dataId=$(".slide-item").eq(i).attr("data-id"); exculdeIds.push(dataId); exculdeId2s.push(dataId); } $(".slide-list").on("click",".slide-item",function(){ var columId=$(this).attr("data-col"); $.ajax({ "url":"/ajax/operation/statist/bannerClick", "type":"POST" , "dataType":"json", "data":{"id":columId}, "success" : function(data) { console.log(data) } }) }) } }) importNews(exculdeIds); hotNews(); var linkNum=0;//栏目类别导航 if(linkNum==0){ listShow(exculdeId2s,1,0,true); } $(document).bind("click",function(e){ var target = $(e.target); if(target.closest(".table-tab-item").length == 0){ $(".table-drop").hide(); $(".rightbtn").find("em").removeClass("unfoldtr").addClass("foldtr"); } }) $(".table-tab-item").on("mouseenter","li.rightbtn",function(){ $(this).find(".table-drop").show(); $(this).find("em").removeClass("foldtr").addClass("unfoldtr"); }).on("mouseleave","li.rightbtn",function(){ $(this).find("em").removeClass("unfoldtr").addClass("foldtr"); $(this).find(".table-drop").hide(); }) $(".table-drop").on("click","li",function(){ $(".rightbtn").find("span").html($(this).text()); }) $(".table-tab-item").on("click","li",function(){ if($(this).is('.table-tab-slide')){ linkNum = $(this).index(".table-tab-slide"); dataColNum=$(this).attr('data-col'); $(".table-tab-slide").removeClass("table-tab-slide-active"); $(this).addClass("table-tab-slide-active"); $(".table-drop").fadeOut(1000); $(".rightbtn").find("em").removeClass("unfoldtr").addClass("foldtr"); $(".table-item-list").eq(linkNum).show().siblings().hide(); if($(".rightbtn").find("li").is(".table-tab-slide-active")){ $(".rightbtn").addClass("table-tab-slide-active"); }else{ $(".rightbtn").removeClass("table-tab-slide-active"); } if(linkNum==0){ listShow(exculdeId2s,1,0,true); }else{ var thisNum=dataColNum; listShow(exculdeIds,1,thisNum,true); } }else{ $(this).find(".table-drop").show(); } }) //重大新闻 function importNews(obj) { $.ajax({ "url" :"/ajax/article/find", "type" : "GET" , "dataType" : "json", "traditional": true, "async":false, "data" :{ "exclude":obj, "col":9,//重大新闻 "pageSize":5, "pageNo":1 }, "success" : function(data) { if (data.success){ console.log(data) var $data=data.data.data; if($data.length>0){ $("#importNews").parents(".conItem").removeClass("displayNone"); var oLeng=$data.length<5?$data.length:5; for(var i=0;i<oLeng;i++) { var listLi=$('<li class="flexCenter"></li>').appendTo($("#importNews")); var str='<a target="_blank" href="/'+pageUrl('a',$data[i])+'"><p class="h2Font ellipsisSty-2"><em class="circlePre"></em>'+$data[i].articleTitle+'</p>'+ '<span class="smalltip">'+commenTime($data[i].publishTime)+'</span></a></li>' $(str).appendTo(listLi); exculdeId2s.push($data[i].articleId); } } } }, "error":function(){ $.MsgBox.Alert('提示','链接服务器超时') } }); } //热门文章 function hotNews(){ $.ajax({ "url" :"/ajax/article/lastestPublished", "type" : "GET" , "dataType" : "json", "success" : function(data) { if (data.success){ console.log(data) var $data=data.data; if($data.length>0){ $("#hotNews").parents(".conItem").removeClass("displayNone"); var oLeng=$data.length<10?$data.length:10; for(var i=0;i<oLeng;i++) { var listLi=$('<li class="flexCenter"></li>').appendTo($("#hotNews")); var str='<a target="_blank" href="/'+pageUrl('a',$data[i])+'"><p class="h2Font ellipsisSty-2">'+$data[i].articleTitle+'</p></a>' $(str).appendTo(listLi); } } } }, "error":function(){ $.MsgBox.Alert('提示','链接服务器超时') } }); } //栏目列表 function listShow(obj,pageNo,colNum,isbind){ $.ajax({ "url" :"/ajax/article/find", "type" : "GET" , "dataType" : "json", "traditional": true, "data" :{ "exclude":obj, "col":colNum, "pageSize":10, "pageNo":pageNo }, "beforeSend": function() { $(".table-body").append('<img src="../images/loading.gif" class="loading" />'); }, "success" : function(data) { if (data.success){ console.log(data) var idItem=0; if(colNum>0){ idItem=colNum-2; } //console.log(idItem) $("#table-item-"+idItem).html(""); var strNo='<div class="nodatabox"><div class="nodata"><div class="picbox picNull"></div>' strNo+='<div class="txtbox"><p class="noContip">该栏目暂时没有任何动态</p></div></div></div>' var dataStr=data.data.data; if(dataStr.length>0){ for(var i=0;i<dataStr.length;i++) { if(colNum>0){ var listLi=$('<li class="flexCenter"></li>').appendTo($("#table-item-"+idItem)); otherColum(dataStr[i],listLi); }else{ var listLi=$('<li class="flexCenter"></li>').appendTo($("#table-item-0")); lastestColum(dataStr[i],listLi); } } }else{ $("#table-item-"+idItem).html(strNo); $("#table-item-"+idItem).parent().find(".tcdPageCode").hide(); } //分页 if(isbind==true){ $("#table-item-"+idItem).parent().find(".tcdPageCode").off("click").createPage({ pageCount: Math.ceil(data.data.total / 10), current: data.data.pageNo, backFn: function(p) { $("#table-item-"+idItem).html(""); listShow(obj,p,colNum,false); document.body.scrollTop = document.documentElement.scrollTop = 0; } }); } $(".loading").remove(); } }, "error":function(){ $.MsgBox.Alert('提示','链接服务器超时') } }); } function lastestColum(dataStr,listLi){ var madiaHead="../images/default-artical.jpg"; if(dataStr.articleImg) { madiaHead ='/data/article/' + dataStr.articleImg ; } var sowU=""; if(dataStr.pageViews!=0){ if(dataStr.articleAgree!=0){ sowU='<span>阅读量 '+dataStr.pageViews+'</span><span>赞 '+dataStr.articleAgree+'</span>' }else{ sowU='<span>阅读量 '+dataStr.pageViews+'</span>' } } var columTag=''; if(dataStr.colNum>0){ columTag='<span class="columTag">'+columnType[dataStr.colNum].shortName+'</span>'; } var strAdd = ''; strAdd += '<a target="_blank" href="/'+ pageUrl('a',dataStr) +'" class="flexCenter urlgo">'; strAdd += '<div class="lefthead articalhead" style="background-image:url('+ madiaHead +')">'+columTag+'</div>'; strAdd += '<div class="centercon centercon2"><p class="h1font ellipsisSty-2">'+ dataStr.articleTitle +'</p>'; strAdd += '<div class="h2font showInfo clearfix">'; strAdd += '<span class="ownerName"></span>'; strAdd += '<span class="time">'+ commenTime(dataStr.publishTime) +'</span>'; strAdd += sowU strAdd += '<span class="comment"></span>'; strAdd += '</div></div>'; strAdd += '</a>'; var $strAdd = $(strAdd); listLi.append( $strAdd); commentnum(dataStr.articleId, $strAdd) //文章评论数 if(dataStr.articleType==1){ userFun(dataStr.professorId, $strAdd); }else{ cmpFun(dataStr.orgId, $strAdd); } } function otherColum(dataStr,listLi){ var madiaHead="../images/default-artical.jpg"; if(dataStr.articleImg) { madiaHead ='/data/article/' + dataStr.articleImg ; } var sowU=""; if(dataStr.pageViews!=0){ if(dataStr.articleAgree!=0){ sowU='<span>阅读量 '+dataStr.pageViews+'</span><span>赞 '+dataStr.articleAgree+'</span>' }else{ sowU='<span>阅读量 '+dataStr.pageViews+'</span>' } } var strAdd = ''; strAdd += '<a target="_blank" href="/'+ pageUrl('a',dataStr) +'" class="flexCenter urlgo">'; strAdd += '<div class="lefthead articalhead" style="background-image:url('+ madiaHead +')"></div>'; strAdd += '<div class="centercon centercon2"><p class="h1font ellipsisSty-2">'+ dataStr.articleTitle +'</p>'; strAdd += '<div class="h2font showInfo clearfix">'; strAdd += '<span class="ownerName"></span>'; strAdd += '<span class="time">'+ commenTime(dataStr.publishTime) +'</span>'; strAdd += sowU strAdd += '<span class="comment"></span>'; strAdd += '</div></div>'; strAdd += '</a>'; var $strAdd = $(strAdd); listLi.append($strAdd); commentnum(dataStr.articleId, $strAdd) //文章评论数 if(dataStr.articleType==1){ userFun(dataStr.professorId, $strAdd); }else{ cmpFun(dataStr.orgId, $strAdd); } } //查文章留言数 function commentnum(articleId, $itemlist) { $.ajax({ "url": "/ajax/leaveWord/lwCount", "type": "GET", "dataType": "json", "async": false, "data": { "articleId": articleId }, "success": function(data) { if(data.success) { if(data.data>0){ $itemlist.find(".comment").text("留言 " + data.data); } } }, "error": function() { $.MsgBox.Alert('提示', '链接服务器超时') } }); } /*用户信息*/ function userFun(id,$listItem) { $.ajax({ "url": "/ajax/professor/baseInfo/" + id, "type": "get", "async": true, "success": function(data) { if(data.success && data.data) { $listItem.find(".ownerName").text(data.data.name); } }, "error": function() { $.MsgBox.Alert('提示', '链接服务器超时') } }); } /*企业用户信息*/ function cmpFun(id,$listItem) { $.ajax({ "url": "/ajax/org/" + id, "type": "get", "async": true, "success": function(data) { if(data.success && data.data) { if(data.data.forShort) { $listItem.find(".ownerName").text(data.data.forShort); }else{ $listItem.find(".ownerName").text(data.data.name); } } }, "error": function() { $.MsgBox.Alert('提示', '链接服务器超时') } }); } })