123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- $(document).ready(function() {
- loginStatus();
-
- 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) {
-
- 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);
-
- 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);
- });
- } 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')
- }
- });
- }
- })
|