portal html css js resource

resourceInfo.js 6.8KB

    $(document).ready(function() { loginStatus();//判断个人是否登录 /*获取资源ID*/ var resourceId = GetQueryString("resourceId"); var professorId; var userid = $.cookie("userid"); //填充学术领域 var subjectShow = function(data) { if(data != undefined && data.length != 0) { var subs = new Array(); if(data.indexOf(',')) { subs = data.split(','); } else { subs[0] = data; } if(subs.length > 0) { for(var i = 0; i < subs.length; i++) { $("#subjectList").append("<li>" + subs[i] + "</li>") }; } } } //填充应用行业 var industryShow = function(data) { if(data != undefined && data.length != 0) { var subs = new Array(); if(data.indexOf(',')) { subs = data.split(','); } else { subs[0] = data; } if(subs.length > 0) { for(var i = 0; i < subs.length; i++) { $("#industryList").append("<li>" + subs[i] + "</li>") }; } } } /*获取资源的数据的函数*/ var resourceData = function() { $.ajax({ "url": "/ajax/resource/resourceInfo", data: { 'resourceId': resourceId }, "type": "get", "async": true, "success": function(info) { if(info.success) { //console.log(info) var $info = info.data; $(".h2Font").text($info.resourceName); $("#application").text($info.supportedServices); professorId = $info.professorId; if(userid==professorId){ $("#consultin,.attentBtn").hide() } if($info.subject) { subjectShow($info.subject) } else { $("span:contains('学术领域')").hide(); } if($info.industry) { industryShow($info.industry) } else { $("span:contains('应用行业')").hide(); } if($info.cooperationNotes) { $("#cooperationNote").text($info.cooperationNotes); } else { $("span:contains('合作备注')").hide(); } if(!$info.subject && !$info.industry && !$info.cooperationNotes) { $(".resAbout").hide(); } if($info.images.length) { $("#resouImg").attr("src", "/images/resource/" + $info.resourceId + ".jpg") } if($info.descp) { $(".resMore").html($info.descp); var pWidth = $(".resMore").find("p").width(); var leng = $(".resMore").find("img").length; for(var i = 0; i < leng; i++) { (function(i) { $(".resMore").find("img").eq(i).load(function() { var imgWidth = $(".resMore").find("img").eq(i).width(); if(imgWidth > pWidth) { $(".resMore").find("img").eq(i).css({ "width": "100%" }) } }) })(i) } } else { $(".resBottom").hide(); } $("#nameS").text($info.editProfessor.name); if($info.editProfessor.title) { if($info.editProfessor.office) { $("#title").text($info.editProfessor.title + ","); } else { $("#title").text($info.editProfessor.title); } } if($info.editProfessor.office) { $("#office").text($info.editProfessor.office); } if($info.editProfessor.department) { $("#department").text($info.editProfessor.department); } if($info.editProfessor.orgName) { $("#orgName").text($info.editProfessor.orgName); } if($info.editProfessor.address) { $("#address").text($info.editProfessor.address); } if($info.editProfessor.hasHeadImage) { $("#headImg").attr("src", "/images/head/" + $info.professorId + "_l.jpg") } var resourcetitle = $info.resourceName + "-科袖网"; window.setInterval(function() { document.title = resourcetitle; }, 500); //专家相关资源 relevantResource($info.professorId, $info.resourceId) } else { $.MsgBox.Alert('消息提醒', info.msg); } }, "error": function() { $.MsgBox.Alert('message', 'failed') } }); } /*资源信息*/ resourceData(); /*点击专家头像进入专家页面*/ $("#headImg").on("click", function() { location.href = "information-brow.html?professorId=" + professorId; }); /*点击咨询*/ $("#consultin").on("click", function() { clickResouceConsultHandler(); }); /*咨询函数*/ function clickResouceConsultHandler() { if(userid && userid != "null" && userid != null) { ConsultApply(); 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 = $(".h2Font").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'); } }; /*专家相关资源*/ var relevantResource = function(id, reid) { $.ajax({ "url": "/ajax/resource/qapro", "type": "get", "data": { "professorId": id }, "async": true, "success": function(data) { if(data.success) { var $info = data.data; var reId = reid; var j = 0; for(var i = 0; i < $info.length; i++) { if($info[i].resourceId != reId) { var string = "" string += '<li>' string += '<a class="resoumag" href="resourceInfo.html?resourceId=' + $info[i].resourceId + '">' string += '<div class="ResImgBox resourceImgBox">' if($info[i].images.length) { string += '<img class="resImg headRadius resourceImg" src="/images/resource/' + $info[i].resourceId + '.jpg" />' } else { string += '<img class="resImg headRadius resourceImg" src="images/default-resource.jpg" />' } string += '</div>' string += '<h2>' + $info[i].resourceName + '</h2>' string += '</a>' string += '</li>' j++; if(j == 4) { return; } $(".otherRes").append(string); } if($info.length == 1) { $("#relaResou").hide() } } } else { $.MsgBox.Alert("消息", data.msg); } }, "error": function() { $.MsgBox.Alert('message', 'fail') } }); } })