$(function() { var userid = $.cookie("userid"); if(userid && userid != "null" && userid != null) { $(".myWorkspace").attr("href", "workspaces.html?" + userid); loginStatus(); } //登陆个人信息下拉菜单 $('.head-portrait').hover(function() { $(".personal-infor").stop(true, false).slideDown(500); }, function() { $(".personal-infor").stop(true, false).slideUp(500); }); $(document).scroll(function() { var top = $(document).scrollTop(); if(top != 0) { $(".searchbox").fadeIn(1000); } else { $(".searchbox").fadeOut(1000); } }); var newc = GetQueryString("lookFor"); if(newc == 0 || newc == "") { var c = 0; } else { var c = 1; // $(".lookwho option[value='1']").attr("selected","selected"); $("#div_select").text("找资源"); } /* * var lookFor2 = 0; $("#lookFor2 ul li").on("click",function(){ * lookFor2=$(this).index(); }); //enter绑定时间 * $("#searchContent").keydown(function(e){ if(e.which==13) { synContent(2); * synContent(1); var searchContent = $("#searchContent").val(); if(lookFor2 = * 1){ $("#div_select").text("找资源"); location.href = * "search.html?searchContent=" + encodeURI(searchContent); } } * }) */ var userid = $.cookie("userid"); var subject; var subb = $.trim(GetQueryString("subject")); var industry; var pageSize; var sub = "SUBJECT"; var indu = "INDUSTRY"; var address = $("#address .colorbg")[0].title; $("#searchContent").val(GetQueryString("searchContent")); $("#hsearchContent").val(GetQueryString("searchContent")); var key = $("#searchContent").val(); var getData = function(key, subject, industry, pageSize, pageNo, isbind, add) { if(c == 0) { $ .ajax({ "url": "/ajax/professor/pqBaseInfo", "type": "GET", "data": { "key": key, "subject": subject, "industry": industry, "pageSize": pageSize, "pageNo": pageNo, "address": add }, "contentType": "application/x-www-form-urlencoded", "success": function($data) { if($data.success) { // console.log($data); $("#professorList").html(""); for(var i = 0; i < $data.data.data.length; i++) { // 创建HTML标签 var dataHtml = "
"; dataHtml += "
" if($data.data.data[i].hasHeadImage) { dataHtml += "
"; } else { dataHtml += "
"; } dataHtml += "
"; dataHtml += ""; if(typeof($data.data.data[i].name) !== "undefined") { dataHtml += $data.data.data[i].name; } dataHtml += ""; dataHtml += "
"; if($data.data.data[i].office) { dataHtml += $data.data.data[i].office + ", "; } if($data.data.data[i].title) { dataHtml += $data.data.data[i].title + ", "; } if($data.data.data[i].department) { dataHtml += $data.data.data[i].department + ", "; } if($data.data.data[i].orgName) { dataHtml += $data.data.data[i].orgName; } if($data.data.data[i].address) { dataHtml += " | " + $data.data.data[i].address; } dataHtml += "
"; dataHtml += "
"; if(typeof($data.data.data[i].subject) !== "undefined") { dataHtml += "

学术领域:" + $data.data.data[i].subject + "

"; } dataHtml += "
"; dataHtml += "
"; if(typeof($data.data.data[i].industry) !== "undefined") { dataHtml += "

应用行业:" + $data.data.data[i].industry + "

"; } if($data.data.data[i].researchAreas.length) { dataHtml += "

研究方向:" + $data.data.data[i].researchAreas[0].caption + "

"; // console.log($data.data.data[i].researchAreas[0].caption); } dataHtml += "
"; dataHtml += "
"; if($data.data.data[i].id != userid) { dataHtml += "
咨询
"; } var $datahtml = $(dataHtml); $("#professorList").append(dataHtml); var photoHeight = $(".photo1").eq(i).height(); var middleHeight = $(".synopsis").eq(i).height(); if(middleHeight < photoHeight) { $(".synopsis").eq(i).height(photoHeight); } if($data.data.data[i].authType) { $(".modify").eq(i).addClass("authicon authicon-cu"); } else { if($data.data.data[i].authStatus) { if($data.data.data[i].authentication == 1) { $(".modify").eq(i).addClass("authicon2 authicon-mana"); //$(".modify").eq(i).html("科研"); } else if($data.data.data[i].authentication == 2) { $(".modify").eq(i).addClass("authicon2 authicon-staff"); //$(".modify").eq(i).html("企业"); } else { $(".modify").eq(i).addClass("authicon2 authicon-stu"); //$(".modify").eq(i).html("学生"); } } } // 点击查看当前信息 (function(i) { $('.synopsis') .eq(i) .click( function() { location.href = 'information-brow.html?professorId=' + $data.data.data[i].id; }) } )(i); } //找专家点击咨询 $(".onlyConsultbtn").bind("click", clickSeachProConsultHandler); if(isbind == true) { $(".tcdPageCode").createPage({ pageCount: Math.ceil($data.data.total / pageSize), current: $data.data.pageNo, backFn: function(p) { getData(key, subject, industry, pageSize, p, false); } }); } } else { $.MsgBox.Alert("message", $data.msg); } } }); } else { //查询我的所有资源 $.ajax({ "url": "/ajax/resource/pq", "type": "get", "data": { "key": key, "subject": subject, "industry": industry, "pageSize": pageSize, "pageNo": pageNo, "address": add }, "contentType": "application/x-www-form-urlencoded", "success": function(data) { console.log(data); if(data.success) { $("#professorList").html(""); var $da = data.data.data; for(var i = 0; i < $da.length; i++) { var add = '
' add += '
' add += '
' add += '' if($da[i].professor.name) { add += '' } if($da[i].professor.title == undefined) { $da[i].professor.title = ""; } if($da[i].professor.department == undefined) { $da[i].professor.department = ""; } if($da[i].professor.orgName == undefined) { $da[i].professor.orgName = ""; } add += '
' if($da[i].professor.title && $da[i].professor.department && $da[i].professor.orgName) { add += $da[i].professor.title + "," + $da[i].professor.department + "," + $da[i].professor.orgName; } else if(!$da[i].professor.title && $da[i].professor.department && $da[i].professor.orgName) { add += $da[i].professor.department + "," + $da[i].professor.orgName; } else if($da[i].professor.title && !$da[i].professor.department && $da[i].professor.orgName) { add += $da[i].professor.title + "," + $da[i].professor.orgName; } else if($da[i].professor.title && $da[i].professor.department && !$da[i].professor.orgName) { add += $da[i].professor.title + "," + $da[i].professor.department; } else if(!$da[i].professor.title && !$da[i].professor.department && $da[i].professor.orgName) { add += $da[i].professor.orgName } else if(!$da[i].professor.title && $da[i].professor.department && !$da[i].professor.orgName) { add += $da[i].professor.department } else if($da[i].professor.title && !$da[i].professor.department && !$da[i].professor.orgName) { add += $da[i].professor.title } add += '
' if($da[i].subject) { add += '

学术领域:' + $da[i].subject + '

' } if($da[i].industry) { add += '

应用行业:' + $da[i].industry + '

' } if($da[i].supportedServices) { add += '

应用用途:' + $da[i].supportedServices + '

' } if(userid==$da[i]["professor"]["id"]){ add += '
' }else{ add += '
咨询
' } add += '
' var $add = $(add); $("#professorList").append($add); if($da[i].professor.authType) { $add.find(".modicon").addClass("authicon authicon-cu"); } else { if($da[i].professor.authStatus) { if($da[i].professor.authentication == 1) { $add.find(".modicon").addClass("authicon2 authicon-mana"); //$add.find(".modicon").html("科研"); } else if($da[i].professor.authentication == 2) { $add.find(".modicon").addClass("authicon2 authicon-staff"); //$add.find(".modicon").html("企业"); } else { $add.find(".modicon").addClass("authicon2 authicon-stu"); //$add.find(".modicon").html("学生"); } } } if(data.data.data[i].images.length) { $add.find(".resourceImg").attr("src", "/images/resource/" + $da[i].resourceId + ".jpg"); } else { $add.find(".resourceImg").attr("src", "/images/default-resource.jpg"); } } if(isbind == true) { $(".tcdPageCode").createPage({ pageCount: Math.ceil(data.data.total / pageSize), current: data.data.pageNo, backFn: function(p) { getData(key, subject, industry, pageSize, p, false); } }); } } else { $.MsgBox.Alert("消息提醒", "请先登录再进行咨询"); $("#mb_btn_ok").val("去登录"); } //资源中点击咨询 //$(".consultbtn").bind("click",clickResouceConsultHandler); $(".about").on("click", '.consultbtn', function(e) { e.stopPropagation(); //阻止事件冒泡,影响点击咨询 e.cancelBubble = true; // ie下阻止冒泡 clickResouceConsultHandler($(this), $(this).attr('id')); }); }, }); } } var subjectList = function() { $.get("../ajax/dataDict/qaDictCode", { dictCode: "SUBJECT" }, function(data) { if(data.success) { console.log(data); /*if (data.data.length <= 10) { $(".andmore").eq(0).hide(); }*/ $("#subject").find(".sub").remove(); for(var i = 0; i < data.data.length; i++) { $("#subject").append( "" + data.data[i].caption + ""); if(subb) { if(subb == data.data[i].caption) { $('.sub').eq(i).addClass('colorbg').siblings() .removeClass("colorbg"); } } if(i > 20) break; } } else { $.MsgBox.Alert("message", data.msg); } }) } var Address = function() { $.get("../ajax/dataDict/qaCity", { dictCode: "ADDRESS" }, function(data) { if(data.success) { $("#address").empty(); $("#address").prepend('不限'); /*if (data.data.length <= 10) { $(".andmore").eq(2).hide(); }*/ for(var i = 0; i < data.data.length; i++) { $("#address").append( "" + data.data[i].caption + ""); if(i > 20) break; } } else { $.MsgBox.Alert("message", data.msg); } }) } var industryList = function() { $.get("../ajax/dataDict/qaDictCode", { dictCode: "INDUSTRY" }, function(data) { console.log(data); if(data.success) { /*if (data.data.length <= 10) { $(".andmore").eq(1).hide(); }*/ $("#industry").find(".indu").remove(); for(var i = 0; i < data.data.length; i++) { $("#industry").append( "" + data.data[i].caption + ""); if(i > 20) break; } } else { $.MsgBox.Alert("message", data.msg); } }) } var findProfessor = function() { if(subb) { subject = subb; } else { subject = $("#subject .colorbg")[0].title; } industry = $("#industry .colorbg")[0].title; pageSize = 10; getData(key, subject, industry, pageSize, 1, true, address); } // enter键搜索 function synContent(type) { if(type == 1) { $("#searchContent").val($("#hsearchContent").val()); } else { $("#hsearchContent").val($("#searchContent").val()); } } $("#hsearchContent").blur(function() { synContent(1); }); $("#searchContent").blur(function() { synContent(2); }); $("#searchContent").keydown(function(e) { if(e.which == 13) { synContent(2); key = $("#searchContent").val(); $("#professorList").remove(); $(".aboutpro").append( '
') $(".tcdPageCode").remove(); $(".aboutpro").append('
'); getData(key, subject, industry, 10, 1, true, address); } }) $("#hsearchContent").keydown(function(e) { if(e.which == 13) { synContent(1); key = $("#searchContent").val(); $("#professorList").remove(); $(".aboutpro").append( '
') $(".tcdPageCode").remove(); $(".aboutpro").append('
'); getData(key, subject, industry, 10, 1, true, address); } }) $("#search1").on( "click", function() { $("#hsearchContent").val($("#searchContent").val()); key = $("#searchContent").val(); $("#professorList").remove(); $(".aboutpro").append( '
') $(".tcdPageCode").remove(); $(".aboutpro").append('
'); getData(key, subject, industry, 10, 1, true, address); }) $("#hsearch1").on( "click", function() { $("#searchContent").val($("#hsearchContent").val()); key = $("#hsearchContent").val(); $("#professorList").remove(); $(".aboutpro").append( '
') $(".tcdPageCode").remove(); $(".aboutpro").append('
'); getData(key, subject, industry, 10, 1, true, address); }) subjectList(); industryList(); findProfessor(); Address(); $(".class1").eq(0).on( "click", "a", function() { $(this).addClass("colorbg").siblings().removeClass("colorbg"); key = $("#searchContent").val(); subject = $(this).attr('title'); $("#professorList").remove(); $(".aboutpro").append( '
') $(".tcdPageCode").remove(); $(".aboutpro").append('
'); getData(key, subject, industry, 10, 1, true, address); }); $(".class1").eq(1).on( "click", "a", function() { $(this).addClass("colorbg").siblings().removeClass("colorbg"); industry = $(this).attr('title'); key = $("#searchContent").val(); $("#professorList").remove(); $(".aboutpro").append( '
') $(".tcdPageCode").remove(); $(".aboutpro").append('
'); getData(key, subject, industry, 10, 1, true, address); }); $(".class1").eq(2).on( "click", "a", function() { $(this).addClass("colorbg").siblings().removeClass("colorbg"); address = $(this).attr('title'); key = $("#searchContent").val(); $("#professorList").remove(); $(".aboutpro").append( '
') $(".tcdPageCode").remove(); $(".aboutpro").append('
'); getData(key, subject, industry, 10, 1, true, address); }); /* 搜索分类展开 */ var listi = 0; $(".andmore").click(function() { $(this).find(".updown").css("background-position", "left"); $(this).parent().css("height", "48px"); if(listi % 2 == 0) { } else { $(this).find(".updown").css("background-position", "right"); $(this).parent().css("height", "auto"); } listi++; }) /*搜索分类背景切换*/ $(".class1").on("click", "a", function() { $(this).addClass("colorbg").siblings().removeClass("colorbg"); }) /*专家、资源菜单切换*/ // $(".lookwho").change(function(){ // //$(this).addClass("tabcurrent").siblings().removeClass("tabcurrent"); // //$(".aboutcon").eq($(this).index()).show().siblings().hide(); // if($(this).value == "0"){ // $(".aboutpro").show(); // $(".aboutresou").hide(); // } // else{ // $(".aboutresou").show(); // $(".aboutpro").hide(); // } // // }) //判断是搜寻专家还是资源 $(".lishow li").on( "click", function() { c = $(this).index(); $("#industry").find(".no2").addClass("colorbg").siblings() .removeClass("colorbg"); $("#subject").find(".nox").addClass("colorbg").siblings() .removeClass("colorbg"); key = $("#searchContent").val(); industry = ""; subject = ""; address = ""; if(c == 0) { sub = "SUBJECT"; indu = "INDUSTRY"; } else { sub = "SUBJECT"; indu = "INDUSTRY"; } industryList(); subjectList(); Address(); $("#professorList").remove(); $(".aboutpro").append( '
') $(".tcdPageCode").remove(); $(".aboutpro").append('
'); getData(key, subject, industry, pageSize, 1, true, address); }); // 查询资源详细信息 $('.about') .on( "click", '.remess', function() { var resourceID = $(this).attr("resourceId"); ResourceMessage(); $ .ajax({ "url": "/ajax/resource/" + resourceID, "type": "get", "async": true, "success": function(info) { if(info.success) { $("#resourceName").text( info.data.resourceName); $("#supportedServices") .text( info.data.supportedServices); $("#hopePayMethod").text( info.data.hopePayMethod); $("#cooperationNotes").text( info.data.cooperationNotes); $("#subject").text( info.data.subject); $("#industry").text( info.data.industry); $("#descp").text(info.data.descp); $("#professor").text( info.data.professor.name); $(".resouImage").attr( "src", "/images/resource/" + resourceID + ".jpg"); $(".resouImage") .load(function() {}) .error( function() { $(this) .attr( "src", "/images/default-resource.jpg"); }); limitHeight(); } else { $.MsgBox.Alert('消息提醒', "系统异常!"); } }, "error": function() { $.MsgBox.Alert('message', 'failed') } }); }) // 资源申请 function getIdentity(professorId) { $ .ajax({ "url": "ajax/professor/" + professorId, "type": "get", "async": false, "success": function(data) { if(data.success) { $(".frmtype option")[0].value = data.data.name; $(".frmtype option")[1].value = data.data.organization.name; } else { $.MsgBox.Alert("消息提醒", "系统异常!"); } }, "error": function() { $.MsgBox.Alert('message', 'failddd') } }) } function replaceStr(s) { var pattern = new RegExp("-"); var rs = ""; for(var i = 0; i < s.length; i++) { rs = rs + s.substr(i, 1).replace(pattern, ''); } return rs; } $('.aboutpro') .on( "click", '.appl', function() { ResourceApply(); // 调用资源申请HTML创建函数 $(".limitBox").removeClass("limitBox"); $(".limitwords").removeClass("limitwords"); $(".limitwordbox").removeClass("limitwordbox"); // 获取当前时间并且格式化时间 var myDate = new Date(); var nowYear = myDate.getFullYear(); var nowMonth = myDate.getMonth() + 1; var nowDate = myDate.getDate(); if(nowMonth < 10) { nowMonth = "0" + nowMonth.toString(); } if(nowDate < 10) { nowDate = "0" + nowDate.toString(); } var now = nowYear + "-" + nowMonth + "-" + nowDate; $("#datepicker").val(now); $("#datepicker").datepicker({ "dateFormat": " yy-mm-dd" }); $(".timelo").css("display", "none"); var resName = $(this).attr("resourcename"); var name = $(this).attr("professor"); var resourceID = $(this).attr("resourceId"); $ .ajax({ "url": "/ajax/resource/" + resourceID, "type": "get", "async": false, "success": function(info) { if(info.success) { if(info.data.images.length) { $(".resouImage").attr( "src", "/images/resource/" + resourceID + ".jpg"); } else { $(".resouImage") .attr("src", "/images/default-resource.jpg"); } } } }) $(".namecon").text(name); $(".applysure").hide(); $(".btnboxup").hide(); $(".log").text(resName); getIdentity(userid); $("#deliver") .on( "click", function() { var $data = {}; $data.demandId = userid; $data.resourceId = resourceID; $data.detailDemand = $(".detail") .val(); // 去除时间里面的- 和字符串前后的空格 $data.deliverTime = replaceStr($ .trim($(".dealTime").val())); $data.operationStatus = 1; $data.applysquare = $( ".frmtype option:selected") .val(); $ .ajax({ "url": "/ajax/operation", "type": "POST", "success": function( rdata) { if(rdata.success) { $.MsgBox .Alert( '消息提醒', '资源"' + resName + '"申请发送成功!'); $(".blackcover") .remove(); $("body") .css( "position", "static"); // location.reload(true); } else { $.MsgBox .Alert( '消息提醒', '资源"' + resName + '"申请发送失败,请重新申请!'); } }, "data": $data, "beforeSend": function() { /* console.log(this.data) */ }, "contentType": "application/x-www-form-urlencoded", dataType: "json" }); }); }); // 找专家中 点击咨询处理函数 function clickSeachProConsultHandler() { if(userid != null && userid != 'null' && userid != undefined && userid != 'undefined') { var professorId = $(this).attr("id"); ConsultApply(); //点击的发送 $("#sendConsultBtn").click(function() { sendConsultHandler($(this).attr("proId")) }); concultProInfo(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'); } }; //找资源中 点击咨询 obj点击对象 function clickResouceConsultHandler(obj, professorId) { if(userid && userid != null && userid != 'null' && userid != undefined && userid != 'undefined') { // var professorId = $(this).attr("id"); ConsultApply(); //默认选中资源咨询和标题 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 item = obj.parent().parent().parent(); var consultTitleVal = item.find(".resouname").text(); $("#consultTitle").val("关于" + consultTitleVal + "的咨询"); //点击的发送 $("#sendConsultBtn").click(function() { sendConsultHandler($(this).attr("proId")); //common.js中 }); concultProInfo(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'); } }; /* function sendConsultHandler(){ var professorId = $(this).attr("proId"); var consult_type = $(".clicknow").text();//咨询类型 var consult_title = $("#consultTitle").val();//咨询主题 var consult_content = $("#consultcontent").val();//咨询内容 var consultStr = { "consultType":consult_type, "consultTitle":consult_title, "consultContant":consult_content, "professorId":professorId, "consultantId":userid }; if(consult_type == '' || consult_title == '' || consult_content == ''){ $.MsgBox.Alert("message","请填写完整"); }; if(consult_type == ''){ $.MsgBox.Alert("消息","请选择联系目的"); } if(consult_title == ''){ $.MsgBox.Alert("消息","请填写咨询目的"); } if(consult_content == ''){ $.MsgBox.Alert("消息","请填写咨询内容"); } if(userid && userid != null && userid != "null" && consult_type != '' && consult_title != '' && consult_content != '' ){ $.ajax({ "url" :"/ajax/consult", "type" : "post", //传值:咨询类型、主题、内容、专家id、申请人id "data" : consultStr, "contentType" : "application/x-www-form-urlencoded", "dataType" : "json", "success" : function(response) { consultId = response.data;//咨询id }, "error":function (){ $.MsgBox.Alert("消息","咨询申请失败"); }, "complete":function(){ //$(".consultapply").remove(); $(".blackcover").remove(); $("body").css("position","static"); $.MsgBox.Alert("消息","咨询申请成功"); }, }); } }*/ });