$(document).ready(function() { loginStatus(); //判断个人是否登录 var userid = $.cookie("userid"); $(".jqzoom").imagezoom(); $("#thumblist").on("click", "li a", function() { $(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected"); $(".jqzoom").attr('src', $(this).find("img").attr("src")); $(".jqzoom").attr('rel', $(this).find("img").attr("src")); }); $('.shareWeixin').hover(function() { $('.shareCode').stop(true, false).fadeToggle(); }); var resourceId = GetQueryString("resourceId"); ifcollectionAbout(resourceId,$("#attention").find("em"), 2) var professorId = ""; getRecourceMe(); //热门资源 function recentlyRe(num,obj) { var ourl=num==1?"/ajax/resource/qaOrgPublish":"/ajax/resource/qaProPublish"; $.ajax({ "url" :ourl , "type" : "GET" , "dataType" : "json", "data" :obj, "success" : function(data) { if (data.success){ var $data=data.data; var only=false; if($data.length>1){ $(".recentlyList").parents(".currentBlock").removeClass("displayNone"); var oLeng=$data.length<5?$data.length:5; for(var i=0;i'+ '
'+ '

'+$data[i].resourceName+'

' $(".recentlyList").append(str); } } } }, "error":function(){ $.MsgBox.Alert('提示','链接服务器超时') } }); } /*获取资源信息*/ function getRecourceMe() { $.ajax({ "url": "/ajax/resource/queryOne", "type": "GET", "success": function(data) { console.log(data); if(data.success) { resourceHtml(data.data); var resourceName = data.data.resourceName + "-科袖网"; window.setTimeout(function() { document.title = resourceName; }, 500); } }, "data": { "resourceId": resourceId }, dataType: "json", 'error': function() { $.MsgBox.Alert('提示', '服务器连接超时!'); } }); } /*合作备注及性能参数存储换行格式*/ function outHTML(selecter) { var getValue = selecter; var aa = ""; if(getValue) { var endValue = ((getValue.replace(/<(.+?)>/gi, "<$1>")).replace(/ /gi, " ")).replace(/\n/gi, "|"); var cc = endValue.split("|"); for(var i = 0; i < cc.length; i++) { aa += cc[i] + '
' } } return aa; } /*处理资源html代码*/ function resourceHtml($da) { $("#resourceName").text($da.resourceName); //名字 $("#application").text($da.supportedServices); //应用用途 if($da.editProfessor) { $("#person").show(); if($da.orgName) { //所属机构 $("#organizationName").text($da.orgName).parents("li").show(); } $("#nameS").text($da.editProfessor.name); if($da.editProfessor.title) { $("#titleOffice").text($da.editProfessor.title); } else { if($da.editProfessor.office) { $("#titleOffice").text($da.editProfessor.office); } } if($da.editProfessor.orgName) { $("#orgType").text($da.editProfessor.orgName); } professorId = $da.editProfessor.id; console.log(professorId); console.log(userid); if(userid != professorId) { ifcollectionAbout(professorId,$("#person").find(".attenSpan"), 1) $(".goSpan").show(); } var professorFlag = autho($da.editProfessor.authType, $da.editProfessor.orgAuth, $da.editProfessor.authStatus); $("#authFlag").addClass(professorFlag.sty).attr("title", professorFlag.title); if($da.editProfessor.hasHeadImage == 1) { $("#headImg").css("background-image", 'url(/images/head/' + $da.editProfessor.id + '_l.jpg)'); } recentlyRe(2,{"professorId":professorId}) }else{ $("#enterprise").show(); $(".qiyego").attr('dataid',$da.organization.id); $(".qiyego").attr("href","cmpInforShow.html?orgId="+$da.organization.id); if($da.organization.hasOrgLogo) { $("#companyImg").attr("src", "/images/org/" + $da.organization.id + ".jpg"); }else{ $("#companyImg").attr("src", "/images/default-icon.jpg"); } if($da.organization.authStatus==3){ $("#QauthFlag").addClass("authicon-com-ok").attr("title", "认证企业"); } if($da.organization.forShort) { $("#Qname").text($da.organization.forShort).attr("href","cmpInforShow.html?orgId="+$da.organization.id); }else{ $("#Qname").text($da.organization.name).attr("href","cmpInforShow.html?orgId="+$da.organization.id); } $("#Qindustry").text($da.organization.subject); $("#QorgType").text(orgTypeShow[$da.organization.orgType]) if(userid){ ifcollectionAbout($da.organization.id,$("#enterprise").find(".attenSpan"), 6) } recentlyRe(1,{"orgId":$da.organization.id}) } if($da.spec) { //厂商型号 $("#modelNumber").text($da.spec).parents("li").show(); } if($da.parameter) { //性能参数 $("#performancePa").html(outHTML($da.parameter)).parents("li").show(); } if($da.cooperationNotes) { //合作备注 $("#remarkContent").html(outHTML($da.cooperationNotes)).parents("li").show(); } if($da.subject) { var oSub = $da.subject.split(","); if($da.resourceType==1) { interestingResources(oSub,$da.professorId,0); }else{ interestingResources(oSub,$da.orgId,1); } var oSt = ""; for(var i = 0; i < oSub.length; i++) { oSt += '
  • ' + oSub[i] + '

  • ' } $(".tagList").html(oSt); } else { $(".aboutTit:contains('您可能感兴趣的资源')").parent().hide(); } if($da.descp) { //编辑器 $("#descp").html($da.descp).parents("li").show(); } var weibotitle = $da.resourceName; var weibourl = window.location.href; //return; if($da.images.length) { var weibopic = "http://" + window.location.host + "/data/resource/" + $da.images[0].imageSrc; $("#firstFigure").attr({ "src": "/data/resource/" + $da.images[0].imageSrc, "rel": "/data/resource/" + $da.images[0].imageSrc }).parent().attr("href", "/data/resource/" + $da.images[0].imageSrc); var arr = ""; for(var i = 0; i < $da.images.length; i++) { if($da.images[i] == $da.images[0]) { var oString = '
  • ' + '
    ' + '' + '' + '' + '
    ' + '
  • ' } else { var oString = '
  • ' + '
    ' + '' + '' + '' + '
    ' + '
  • ' } arr += oString; } $("#thumblist").html(arr); } else { var weibopic = "http://" + window.location.host + "../images/default-resource.jpg"; $("#firstFigure").attr({ "src": '../images/default-resource.jpg', "rel": '../images/default-resource.jpg' }); } $("#weibo").attr("href","http://service.weibo.com/share/share.php?appkey=3677230589&title="+encodeURIComponent(weibotitle)+"&url="+encodeURIComponent(weibourl)+"&pic="+encodeURIComponent(weibopic)+"&content=utf-8"+"&ralateUid=6242830109&searchPic=false&style=simple"); } /*点击名字及头像跳转个人浏览页面*/ $("#nameS,#headImg").click(function() { location.href = "userInforShow.html?professorId=" + professorId; }) //关键词标签点击进去搜索 $(".tagList").on("click","li",function(){ var tagText = $(this).find("p").text(); location.href = "searchNew.html?searchContent=" + tagText + "&tagflag=2"; }) /*资源里面相关文章*/ function relatedArticles() { $.ajax({ "url": "/ajax/resource/articles", "type": "GET", "success": function(data) { console.log(data); if(data.success) { if(data.data.length == 0) { $("#oArticle").parent().hide(); $(".aboutTit:contains('相关文章')").hide(); return; } relatedArticlesHtml(data.data); } }, "data": { "resourceId": resourceId, "rows": 5 }, dataType: "json", 'error': function() { $.MsgBox.Alert('提示', '服务器连接超时!'); } }); } relatedArticles(); /*资源相关文章html*/ function relatedArticlesHtml($html) { for(var i = 0; i < $html.length; i++) { (function(n) { var oURL; if($html[i].article.articleType==1) { oURL="/ajax/professor/baseInfo/" + $html[i].article.professorId; }else{ oURL="/ajax/org/" + $html[i].article.orgId; } $.ajax({ "url":oURL, "type": "GET", "success": function(data) { if(data.success) { var cmpname=""; if(data.data.forShort){ cmpname=data.data.forShort; }else{ cmpname=data.data.name; } if($html[n].article.articleType==1) { var stl = autho(data.data.authType, data.data.orgAuth, data.data.authStatus); }else { var stl={}; stl.sty=""; stl.title=""; if(data.data.authStatus==3) { stl.sty="authicon-com-ok"; stl.title="认证企业"; } } var str = "" str += '
  • ' if($html[n].article.articleImg) { str += '
    ' } else { str += '
    ' } str += '
    ' str += '

    ' + $html[n].article.articleTitle + '

    ' str += '

    ' + cmpname + '

    ' str += '
  • ' $("#oArticle").append(str); } }, 'dataType': "json", 'error': function() { $.MsgBox.Alert('提示', '服务器连接超时!'); } }); })(i); } } /*文章跳转*/ $("#oArticle").on("click", "li", function() { location.href = "articalShow.html?articleId=" + $(this).attr("data-id"); }) /*感兴趣的资源*/ function interestingResources(arry,oId,oNu) { var oUrl; var $in={}; $in.keys= arry; $in.resourceId= resourceId; if(oNu==0) { $in.professorId= oId; oUrl="/ajax/resource/ralateRes"; }else { $in.orgId= oId; oUrl="/ajax/resource/orgRalateRes"; } $.ajax({ "url": oUrl, "type": "GET", "success": function(data) { console.log(data); if(data.success) { if(data.data.length == 0) { $(".aboutTit:contains('您可能感兴趣的资源')").parent().hide(); return; } interestingResourcesHtml(data.data); } }, "data":$in, "traditional": true, dataType: "json", 'error': function() { $.MsgBox.Alert('提示', '服务器连接超时!'); } }); } /*感兴趣资源的html*/ function interestingResourcesHtml($respond) { for(var i = 0; i < $respond.length; i++) { if($respond[i].organization) { var stl={}; stl.sty=""; stl.title=""; if($respond[i].organization.authStatus==3) { stl.sty="authicon-com-ok"; stl.title="认证企业"; } var name=""; if($respond[i].organization.forShort){ name=$respond[i].organization.forShort; }else{ name=$respond[i].organization.name; } }else { var stl = autho($respond[i].editProfessor.authType, $respond[i].editProfessor.orgAuth, $respond[i].editProfessor.authStatus); var name= $respond[i].editProfessor.name; } var oStr = ''; if($respond[i].images.length) { oStr += '
  • ' } else { oStr += '
  • ' } oStr += '
    ' oStr += '

    ' + $respond[i].resourceName + '

    ' oStr += '

    用途:' + $respond[i].supportedServices + '

    ' oStr += '

    ' + name + '

    ' oStr += '
  • ' $("#resourceList").append(oStr); } } /*点击资源列表*/ $("#resourceList").on("click", "li", function() { location.href = "resourceShow.html?resourceId=" + $(this).attr("data-id"); }) /*点击咨询*/ $("#consultin").on("click", function() { clickResouceConsultHandler(); }); $("#expertli").on("click", ".addbtn", function() { var $this = $(this); clickResouceConsultHandler($this); }) /*咨询函数*/ function clickResouceConsultHandler($this) { if(userid && userid != "null" && userid != null) { ConsultApply(); if(!professorId) { concultProInfo($this.attr("data-id")); //专家信息common.js中 } else { concultProInfo(professorId); //专家信息common.js中 } //默认选中资源咨询和标题 for(var i = 0; i < $("ul.menucon").children().length; i++) { $("ul.menucon").children().eq(i).removeClass("clicknow"); $("ul.menucon").children().eq(1).addClass("clicknow"); } var consultTitleVal = $("#resourceName").text(); $("#consultTitle").val("关于" + consultTitleVal + "的咨询"); //点击的发送 $("#sendConsultBtn").click(function() { sendConsultHandler(professorId); //common.js中 }); } else { $.MsgBox.Alert("消息提醒", "请先登录再进行咨询"); $("#mb_btn_ok").val("去登录"); var aele = document.createElement('a'); $("#mb_btnbox").append(aele); $("#mb_btnbox a").css({ 'display': "block", 'width': '100%', 'height': '40px', 'position': 'absolute', 'bottom': '-6px', 'left': '0' }); aele.setAttribute('href', '../login.html'); } }; //点击专家关注 $("#person").on("click",'.attenSpan',function() { if(userid && userid != "null" && userid != null) { if($(this).is('.attenedSpan')){ cancelCollectionAbout(professorId,$(this), 1) } else { collectionAbout(professorId,$(this),1); } } else { $.MsgBox.Alert('提示', "请先登录再进行关注"); $("#mb_btn_ok").val("去登录"); var aele = document.createElement('a'); $("#mb_btnbox").append(aele); $("#mb_btnbox a").css({ 'display': "block", 'width': '100%', 'height': '40px', 'position': 'absolute', 'bottom': '-6px', 'left': '0' }); aele.setAttribute('href', '../login.html'); } }) $("#enterprise").on("click",'.attenSpan',function() { if(userid && userid != "null" && userid != null) { if($(this).is('.attenedSpan')){ cancelCollectionAbout($(".qiyego").attr('dataid'),$(this), 6) } else { collectionAbout($(".qiyego").attr('dataid'),$(this),6); } } else { $.MsgBox.Alert('提示', "请先登录再进行关注"); $("#mb_btn_ok").val("去登录"); var aele = document.createElement('a'); $("#mb_btnbox").append(aele); $("#mb_btnbox a").css({ 'display': "block", 'width': '100%', 'height': '40px', 'position': 'absolute', 'bottom': '-6px', 'left': '0' }); aele.setAttribute('href', '../login.html'); } }) //点击资源收藏 $('#attention em').click(function() { if (userid && userid != "null" && userid != null) { if($(this).is('.icon-collected')){ cancelCollectionAbout(resourceId,$(this),3) }else{ collectionAbout(resourceId,$(this),3) } } else { $.MsgBox.Alert('提示', "请先登录再进行收藏"); $("#mb_btn_ok").val("去登录"); var aele = document.createElement('a'); $("#mb_btnbox").append(aele); $("#mb_btnbox a").css({ 'display': "block", 'width': '100%', 'height': '40px', 'position': 'absolute', 'bottom': '-6px', 'left': '0' }); aele.setAttribute('href', '../login.html'); } }) //资源浏览量 function pageViewsVal() { $.ajax({ "url": "/ajax/resource/pageViews", "type": "POST", "dataType": "json", "data": { "resourceId": resourceId }, "success": function(data) { console.log(data); if(data.success) {} }, "error": function() { $.MsgBox.Alert('提示', '链接服务器超时') } }); } pageViewsVal(); selUse(); function selUse() { $.ajax({ url: "/ajax/resource/qaLinkman", type: "GET", timeout: 10000, dataType: "json", async: true, data: { "resourceId": resourceId, }, success: function(data, textState) { console.log(data) if(data.success) { unauthUser(data.data); } }, error: function(XMLHttpRequest, textStats, errorThrown) { $.MsgBox.Alert('提示', '服务器请求失败') } }) } function unauthUser($res) { var osting = "" for(var i = 0; i < $res.length; i++) { var img; var styC = ""; var oClass = autho($res[i].professor.authType, $res[i].professor.orgAuth, $res[i].professor.authStatus); var oTitle = ""; if($res[i].professor.title) { oTitle = $res[i].professor.title; } else { if($res[i].professor.office) { oTitle = $res[i].professor.office; } } if($res[i].professor.hasHeadImage) { img = "/images/head/" + $res[i].professor.id + "_l.jpg"; } else { img = "../images/default-photo.jpg" } var oSt = '
  • ' oSt += '
    ' oSt += '
    ' oSt += '

    ' oSt += '' + $res[i].professor.name + '' oSt += '

    ' oSt += '

    ' + oTitle + '

    ' oSt += '
    ' oSt += '咨询' oSt += '
  • ' osting += oSt; } $("#expertli").html(osting); } //纠错反馈 $(".correctSubmit").on("click",function(){ var cntCon=$(this).siblings(".correctCon").val(); var cntUser=""; if(userid && userid != null && userid != "null") { cntUser = userid; } if(cntCon.length>500){ $.MsgBox.Alert('提示', '纠错反馈内容不得超过500个字'); return; }else{ $.ajax({ "url": "/ajax/feedback/error/resource", "type": "POST", "dataType": "json", "async": true, "data": { "id": resourceId, "cnt":cntCon, "user":cntUser }, "success": function(data) { if(data.success) { backSuccessed(); } }, "error": function() { $.MsgBox.Alert('提示', '链接服务器超时') } }); } }) })