$(document).ready(function(){ $(".unlogin").show(); $(".onlogin").hide(); var footerHeight = $("footer").outerHeight(true); $('#container').css("padding-bottom", footerHeight +"px" ); //窗口大小变更事件 $(window).resize(function() { footerHeight=$("footer").outerHeight(true); $('#container').css("padding-bottom", footerHeight +"px" ); //console.log(footerHeight) }); //底部企业入驻 var orgid = $.cookie('orgId'); $("#cmpSet2").on("click",function(){ if (orgid && orgid != "null" && orgid != null) { location.href="cmp-portal/cmp-workspaces.html" }else{ location.href="cmp-portal/cmp-settled-reg.html" } }) }); //搜索框跳转页面 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); }); var lookFor = 0; $("#lookFor ul li").on("click",function(){ lookFor=$(this).index(); console.log(lookFor); }); $("#search").on("click", function() { var searchContent = $("#searchContent").val(); location.href = "search.html?searchContent=" + encodeURI(searchContent)+"&lookFor=" + lookFor; }); //enter绑定时间 $("#searchContent").keydown(function(e){ if(e.which==13) { synContent(2); var searchContent = $("#searchContent").val(); console.log(searchContent); location.href = "search.html?searchContent=" + encodeURI(searchContent)+"&lookFor=" + lookFor; } }) $("#hsearchContent").keydown(function(e){ if(e.which==13) { synContent(1); var searchContent = $("#hsearchContent").val(); console.log(searchContent); location.href = "search.html?searchContent=" + encodeURI(searchContent); } }) $("#hsearch").on("click", function() { var searchContent = $("#hsearchContent").val(); location.href = "search.html?searchContent=" + encodeURI(searchContent); }); /*向下滚动时,header背景变半透明*/ $(document).scroll(function() { var top = $(document).scrollTop(); if (top == 0) { $(".navheader").removeClass("navhdown"); } else { $(".navheader").addClass("navhdown"); } if (top >= 300) { $(".content-left").css({ "position": "fixed", "top": "80px" }) } else { $(".content-left").css({ "position": "static" }) } }); var userid; function exit(){ $.cookie('userid', null); $.cookie('userAuth', null); $.cookie('userEmail', null); $.cookie('userMobilePhone', null); $.cookie('userName', null); $.cookie('userType', null); location.href="index.html" } function valUser(){ var userid = $.cookie('userid'); var userAuth = $.cookie('userAuth'); if(userid == undefined || userid.length==0 || userid == "null" || userAuth == false){ location.href="login.html"; } } function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); var context = ""; if (r != null) context = r[2]; reg = null; r = null; return context == null || context == "" || context == "undefined" ? "" : decodeURI(context); } /* function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ�� var context = ""; if (r != null) context = r[2]; reg = null; r = null; return context == null || context == "" || context == "undefined" ? "" : context; }*/ function loginStatus(){ userid = $.cookie('userid'); userAuth = $.cookie('userAuth'); authentication = $.cookie('authentication'); if(userid && userid != "null" && userid != null){ if(userAuth == "false" && authentication == "null"){ location.href="loginInviteFirst.html"; } if(userAuth == "true" && authentication == "null"){ location.href="fillinfo-select.html"; } if(userAuth == "true" && authentication != "null"){ $(".onlogin").show(); $(".unlogin").hide(); $(".portrait-p").attr("src","/images/head/"+userid+"_m.jpg"); $(".portrait-p").load(function(){//判断图片是否加载,加载不成功默认有默认的图像 }) .error(function(){ $(".portrait-p").attr("src","/images/default-photo.jpg"); }); } }else{ $(".unlogin").show(); $(".onlogin").hide(); } } //转换格式 function changeTime(dealtime){ var s = dealtime; //console.log(s); if(dealtime.length==8){ var y = s.substr(0,4); var m = s.substr(4,2); var d = s.substr(6,2); var formatTime = y+"-"+m+"-"+d; return formatTime; } else { var y = s.substr(0,4); var m = s.substr(4,2); var d = s.substr(6,2); var h = s.substr(8,2); var minute = s.substr(10,2); var formatTime = y+"-"+m+"-"+d+" "+h+":"+minute; return formatTime; } } //******过滤特殊字符*******// 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; } //**********************// //根据内容的多少获取高度给父级设置高度 function limitHeight(){ var Length = $(".limitBox").length; for(var i=0; i num ){ next.css("display","block"); prev.css("display","none"); }else{ next.css("display","none"); prev.css("display","none"); } next.click(function() { if (!obj.is(":animated")) { if (num < childcount) { tapnum++; prev.css("display","block"); if(tapnum == childcount-show){ next.css("display","none"); } num++; obj.animate({ left: "-=212px" }, 600); } } }); prev.click(function() { if (!obj.is(":animated")) { if (num > inde) { tapnum--; next.css("display","block"); if(tapnum == 0){ prev.css("display","none"); } num--; obj.animate({ left: "+=212px" }, 600); } } }); } //评价字数限制 //字数限制函数 function limitTextCountFn(TextAreaId,countContainerId,count){ var curLength=$(TextAreaId).val().length; if(curLength > count){ var num=$(TextAreaId).val().substr(0,count); $(TextAreaId).val(num); } else { $(countContainerId).text(count - $(TextAreaId).val().length); } }; //咨询申请主题字数限制函数 function titleLimitFontCountFn(){ var curLength= $("#consultTitle").val().length; if(curLength>20){ var num = $("#consultTitle").val().substr(0,20); $("#consultTitle").val(num); } }; //模拟下拉菜单 function selectThis(value){ $("#div_select").text(value); $("#div_select2").val(value); $("#li_show").css("display","none"); if(value=="找专家"){ $("#searchContent").attr("placeholder","搜索专家、机构、研究方向"); }else{ $("#searchContent").attr("placeholder","搜索资源、应用用途"); } } function selectThis2(value){ $("#div_select").text(value); $("#div_select2").val(value); $("#li_show").css("display","none"); if(value=="找专家"){ $("#searchContent").attr("placeholder","输入专家姓名、机构、研究方向等关键字"); }else{ $("#searchContent").attr("placeholder","输入资源名称、应用用途等关键字"); } } function showmenu(){ $("#li_show").css("display","block"); } /*选择城市填充js */ $(document).on("click","#City li a", function(){ var aVal = $(this).text(); $(this).parent().parent().parent().find('.mr_show').text(aVal); $(this).parent().parent().parent().find('input[name=cho_City]').val(aVal); }); //咨询 专家信息接口函数 function concultProInfo(professorId){ $.ajax({ url:"/ajax/professor/editBaseInfo/"+professorId, type:"get", data : {"id":professorId}, contentType : "application/x-www-form-urlencoded", success:function(response){ //console.log(response); var myData = response["data"]; $("#professorName").html(myData["name"]); if(myData["title"]){ $("#professorTitle").html(myData["title"]+' '); } if(myData["department"]){ $("#profDepartment").html(myData["department"]+' '); } if(myData["orgName"]){ $("#profOrganization").html(myData["orgName"]+' '); } if(myData["address"]){ $("#profAdress").html(myData["address"]); } console.log(myData["consultCount"]) if(!myData["consultCount"]){ $("#starLevel").hide(); } $("#byConsultConut").html(myData["consultCount"]); $("#sendConsultBtn").attr("proId",myData["id"]); //星级 var startConut = parseInt(myData["starLevel"]); if(myData["consultCount"]){ if(!startConut){ $(".evastarbox2").hide(); } } for(var i = 0; i < startConut; i ++){ $("#starLevel .evastar2").eq(i).addClass("addStar"); } //认证 var oSty=autho(myData.authType,myData.orgAuth,myData.authStatus); $("#proModifyN").addClass(oSty.sty); $("#proModifyN").attr("title",oSty.title); //头像 if(myData["hasHeadImage"] == 0){ $("#prohead").attr("src","images/default-photo.jpg"); } else { $("#prohead").attr("src","images/head/"+myData["id"]+"_l.jpg"); } }, error:function(error){ $.MsgBox.Alert("message","请求数据失败"); } }); }; //发送咨询 function sendConsultHandler(professorId){ var professorId = professorId; 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("消息提醒","请填写完整"); }; 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) { console.log(response); }, "error":function (){ $.MsgBox.Alert("消息提醒","咨询申请失败"); }, "complete":function(){ //$(".consultapply").remove(); $(".blackcover").remove(); $("body").css("position",""); $.MsgBox.Alert("消息提醒","咨询申请成功"); $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain'); }, }); } }; /*标志*/ function autho() { if(arguments[0] == 1) { return { "sty": "authicon-pro", "title": "科袖认证专家" } } else { if(arguments[1] == 1) { return { "sty": "authicon-staff-ok", "title": "企业认证员工" } } else { if(arguments[2] == 3) { return { "sty": "authicon-real", "title": "实名认证用户" } } else { return { "sty": "e", "title": " " } } } } } //获取用户类型 var ifuser = ifUserType(); function ifUserType(pa){ if(pa) { var useridtype =pa; }else{ var useridtype = $.cookie('userid'); } var authType2,authentication2; if (useridtype && useridtype != "null" && useridtype != null) { $.ajax({ "url" :"/ajax/professor/auth", "type" : "GET", "data" :{"id":useridtype} , "dataType" : "json", "async":false, "success" : function(data) { if(data.success){ authType2 = data.data.authType; authentication2 = data.data.authentication; } } }); } return{ "authType2":authType2, "authentication2":authentication2, } } //工作台判断用户类型显示用户权限 if ($.cookie('userName') && $.cookie('userName') != "null" && $.cookie('userName') != null) { if(ifuser.authType2==0){ $("#repalyf").addClass("repalyf"); /*点击未读咨询消息查看*/ $("#gozixu").on("click", function() { window.location.href = "myConsult.html"; }) }else{ $(".nohide").show(); /*点击未读咨询消息查看*/ $("#gozixu").on("click", function() { window.location.href = "consult.html"; }) } }