$(function(){ loginStatus();//读取用户头像 var userid = $.cookie("userid"); var professorId = GetQueryString("professorId"); var name; if(professorId){ 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++) { $("#subjectShow").append("
资源名称:'+ data.data[i].resourceName+'
' add+='简介:'+data.data[i].supportedServices+'
' add+='' $("#sharescrollbox").append(add); $('.applicant').eq(i).attr("resourceId",data.data[i].resourceId); $(".resourceImg").eq(i).attr("src","/images/resource/"+data.data[i].resourceId+".jpg"); $(".resourceImg").load(function(){}) .error(function(){ $(this).attr("src","/images/default-resource.jpg"); }); add=""; } //资源轮播 var $content = $(".sharescrollbox"); var childcount = $content.find(".sharesrc").length; Carousel(3,3, childcount, $content, $(".resounext"), $(".resouprev")); //科研资源中点咨询 $(".introduction").find(".resourceConsult").bind("click",clickResourceConsult); function Carousel(inde, num, childcount, obj, next, prev) { next.click(function() { if (!obj.is(":animated")) { if (num < childcount) { num++; obj.animate({ left: "-=212px" }, 600); } } }); prev.click(function() { if (!obj.is(":animated")) { if (num > inde) { num--; obj.animate({ left: "+=212px" }, 600); } } }); } } else { $.MsgBox.Alert("消息","系统异常!"); } }, "error":function(){$.MsgBox.Alert('message','failddd')} }); function getIdentity(professorId){ $.ajax({ "url":"ajax/professor/"+professorId, "type":"get", "async": false, "success":function(data){ if(data.success) { //console.log(data); $("option")[0].value=data.data.name; $("option")[1].value=data.data.organization.name; //console.log($("option")[0].value); //console.log($("option")[1].value); } else { $.MsgBox.Alert("消息","系统异常!"); } }, "error":function(){$.MsgBox.Alert('message','failddd')} }) } //查看资源详细信息 $('#sharescrollbox').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) { console.log(info); $("#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(name); $(".resouImage").attr("src","/images/resource/"+resourceID+".jpg"); $(".resouImage").load(function(){}) .error(function(){ $(this).attr("src","/images/default-resource.jpg"); }); } else { $.MsgBox.Alert('message',"系统异常!"); } }, "error":function(){$.MsgBox.Alert('message','failed')} }); }) //资源申请入口 $('.introduction').on("click",'.applicant',function(){ if(userid && userid != null && userid != "null"){ 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"); $(".namecon").text(name); $(".applysure").hide(); $(".btnboxup").hide(); var index1=$(this).parent().parent().parent().index(); var resName=$('.presou').eq(index1).text(); 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"); } } } }) $(".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())); //alert(replaceStr($.trim($(".dealTime").val()))); //alert(replaceStr($.trim($(".dealTime").val())).length); $data.operationStatus=1; $data.applysquare=$("select option:selected").val(); //console.log($data.applysquare); $.ajax({ "url" : "/ajax/operation", "type" : "POST", "success" : function(rdata) { if (rdata.success) { $.MsgBox.Alert('message','资源"'+ resName +'"申请发送成功!'); $(".blackcover").remove(); $("body").css("position","static"); //location.reload(true); } else { $.MsgBox.Alert('message','资源"'+ resName +'"申请发送失败,请重新申请!'); } }, "data" : $data, "beforeSend":function(){/*console.log(this.data)*/}, "contentType" : "application/x-www-form-urlencoded", dataType : "json" }); }); }else{ $.MsgBox.Alert("消息","您还未登录,请登录之后进行资源申请"); } }); //科研资源中的咨询 function clickResourceConsult(){ var professorId = $(this).attr("professorId"); consultHandler(); $("ul.menucon").children().eq(1).addClass("clicknow"); var consultTitleVal = $(this).parent().parent().parent().find(".consultTitleVal").text(); $("#consultTitle").val("关于"+consultTitleVal+"的咨询"); }; //===============点击咨询============== var userid = $.cookie("userid");//登陆人id====重复代码 var professorId = GetQueryString("professorId");//专家id====重复代码 //点击咨询 $("#consultbtn").bind('click',consultHandler); //字数限制函数 function limitFontCountFn(){ var curLength=$(this).val().length; if(curLength>500){ var num=$(this).val().substr(0,500); $(this).val(num); $.MsgBox.Alert('提醒',"已经超过500字"); } else{ $("#textCount").text(500-$(this).val().length); } } function consultHandler(){ ConsultApply(); $("#consultContent").bind("keyup",limitFontCountFn); //点击的发送 $("#sendConsultBtn").on("click",sendConsultHandler); if(userid && userid != null && userid != "null"){ $.ajax({ "url" :"/ajax/professor/"+ professorId, "type" : "get", "data" : {"professorId":professorId}, "contentType" : "application/x-www-form-urlencoded", "success" : function(response) { if (response.success) { //console.log(response); $("#professorName").text(response.data["name"]); $("#professorTitle").text(response.data["title"]); if(response.data["department"] == "" || response.data["department"] == null){ $("#profOrganization").text(response.data["organization"]["name"]); }else{ $("#profDepartment").text(response.data["department"]+","); $("#profOrganization").text(response.data["organization"]["name"]); } if(response.data["adress"] == "" || response.data["adress"] == null ){ $("#adress").html(""); }else{ $("#profAdress").text(response.data["adress"]); } } else { $.MsgBox.Alert("message","请登录"); } }, "complete":function(){ } }); } }; var consultId; //发送咨询申请处理函数 function sendConsultHandler(){ 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 == ''){ $.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", "beforeSend":function(){/*console.log(this.data)*/}, "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("消息","咨询申请成功"); }, }); } } })