portal html css js resource

workindex.js 34KB

    $(function(){ var userid = $.cookie("userid"); var lookall; //获取专家的数据 function getProfessorData(professorId){ $.ajax({ "url":"/ajax/professor/editBaseInfo/"+professorId, "type":"get", "async": true, "success":function(data) { if(data.success) { $("#nameS").text(data.data.name); $("#allConsultCount").text(data.data.consultCount); if(data.data.authType) { $(".modifyicon").addClass("authicon authicon-cu"); } else { if(data.data.authStatus) { if(data.data.authentication == 1) { $(".modifyicon").addClass("authicon2 authicon-mana"); //$(".modifyicon").html("<span style='top:12px'>科研</span>"); } else if(data.data.authentication == 2) { $(".modifyicon").addClass("authicon2 authicon-staff"); //$(".modifyicon").html("<span style='top:12px'>企业</span>"); } else { $(".modifyicon").addClass("authicon2 authicon-stu"); //$(".modifyicon").html("<span style='top:12px'>学生</span>"); } } } if(data.data.office) { if(data.data.title) { $("#office").text(data.data.office+","); }else{ $("#office").text(data.data.office); } } if(data.data.title) { $("#title").text(data.data.title); } if(data.data.department) { if(data.data.orgName) { $("#department").text(data.data.department+","); }else{ $("#department").text(data.data.department); } } if(data.data.orgName) { $("#organization").text(data.data.orgName); } if(data.data.address) { $("#address").text(data.data.address); } if(data.data.hasHeadImage) { $(".imgProfess").attr("src","/images/head/"+userid+"_l.jpg"); } else { $(".imgProfess").attr("src","/images/default-photo.jpg"); } var startLeval=parseInt(data.data.starLevel); for(var i=0;i<startLeval;i++) { $(".evastar2").eq(i).addClass("startStyle"); } } else { $.MsgBox.Alert("消息","获取专家数据失败!"); } }, "error":function(){$.MsgBox.Alert('message','获取专家数据失败')} }) } getProfessorData(userid); getRecentlyData(); $("#allResource,#worklinkre").on("click",function(){ $(".worksubmenu").eq(1).addClass("subcolor").siblings().removeClass("subcolor"); $.ajax({ "url":"newsciresource.html", "dataType":"html", "success":function(result){ $(".workcon").html(result); if(reNO==false&&opNO) { $(".workmysrc1").eq(1).show().siblings().hide(); $(".worksamlltit").eq(1).addClass("worksamlltitnow").siblings().removeClass("worksamlltitnow"); } } }) }) //新加工作台我的资源 getDataResource(); function getDataResource(){ $.ajax({ "url":"/ajax/resource/qapro", "type":"get", "async": true, "data":{"professorId":userid,"pageSize":3}, "success":function(data){ if(data.success) { var add=''; $("#consdcen").html(""); for(var i=0;i<data.data.length;i++) { var add='<div class="addworkbtn-list"> <div class="resoumag">' add+='<h3><img src="" class="resourceImg"></h3>' add+='<h2>'+data.data[i].resourceName+'</h2>' add+='<p>'+data.data[i].supportedServices+'</p>' add+='</div></div>'; $add = $(add); $("#consdcen").append($add); if(data.data[i].subject==undefined){ $(".li1").eq(i).css({"display":"none"}); } $add.find('.resoumag').attr("resourceId",data.data[i].resourceId); //$('.resoumag').eq(i+1).attr("resourceId",data.data[i].resourceId); if(data.data[i].images.length){ $add.find(".resourceImg").attr("src","/images/resource/"+data.data[i].resourceId+".jpg"); } else { $add.find(".resourceImg").attr("src","/images/default-resource.jpg"); } } $(".addworkbtn-list:gt(2)").css({"display":"none"}); } else { $.MsgBox.Alert('message',"系统异常!"); } }, "error":function(){$.MsgBox.Alert('message','failed')} }); } //获取最近3次的申请 function getRecentlyData(){ $.ajax({ "url":"/ajax/operation/pqpro", "type":"get", "data":{"id":userid,"pageSize":3}, "async": false, "success":function(data) { if(data.success) { $(".sharesrcbox11").html(""); for(var i=0;i<data.data.data.length;i++) { data.data.data[i].createTime=changeTime(data.data.data[i].createTime); var stringContent=""; if(userid==data.data.data[i].professor.id) { stringContent +='<div class="sharesrc replySide" resourId='+data.data.data[i].resource.resourceId+' operationStatus='+data.data.data[i].operationStatus+' operationId='+data.data.data[i].operationId+' dealPrice='+data.data.data[i].dealPrice+' flag=1>' } else { stringContent +='<div class="sharesrc replySide" resourId='+data.data.data[i].resource.resourceId+' operationStatus='+data.data.data[i].operationStatus+' operationId='+data.data.data[i].operationId+' dealPrice='+data.data.data[i].dealPrice+' flag=0>' } stringContent +='<div class="shareshow"><img src="" width="186" height="186"class="resourceImage"></div>' stringContent +='<div class="shareshow"><p>资源名称:'+data.data.data[i].resource.resourceName+'</p>' if(userid==data.data.data[i].professor.id) { stringContent +='<p>合作对象:'+data.data.data[i].resource.professor.name+'</p>' } else{ stringContent +='<p>合作对象:'+data.data.data[i].professor.name+'</p>' } stringContent +='<p>最新动态:</p>' stringContent +='<p class="statuswork"></p></div>' stringContent +='</div>' var $stringContent=$(stringContent) $(".sharesrcbox11").append($stringContent); if(data.data.data[i].resource.images.length){ $stringContent.find(".resourceImage").attr("src","/images/resource/"+data.data.data[i].resource.resourceId+".jpg"); } else{ $stringContent.find(".resourceImage").attr("src","/images/default-resource.jpg"); } //console.log(data.data.data[i].resource.supportedServices); if(userid==data.data.data[i].professor.id) { switch(data.data.data[i].operationStatus) { case 1: var string='<span title="修改申请">申请已发送,待'+data.data.data[i].resource.professor.name+'确认</span><br/>' $(".statuswork").eq(i).html(string); break; case 2: var string='<span>'+data.data.data[i].resource.professor.name+'发来报价,回复报价</span><br/>' $(".statuswork").eq(i).html(string); break; case 3: var string='<span>合作进行中,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; case 4: var string='<span>中止合作,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; case 5: var string='<span>'+data.data.data[i].resource.professor.name+'拒绝合作,合作结束,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; case 6: var string='<span>本人中止合作,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; case 7: var string='<span>合作进行中,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; case 8: var string='<span>完成,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; default: } } else { switch(data.data.data[i].operationStatus) { case 1: var string='<span>'+data.data.data[i].professor.name+'</span> <span>发来了</span><span>新的申请</span>' $(".statuswork").eq(i).html(string); break; case 2: var string='<span>发送报价待'+data.data.data[i].professor.name+'确认,修改报价</span><br/>'; $(".statuswork").eq(i).html(string); break; case 3: var string='<span>'+data.data.data[i].professor.name+'发来报价,合作进行中,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; case 4: var string='<span>'+data.data.data[i].professor.name+'拒绝报价,合作结束,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; case 5: var string='<span>本人拒绝合作,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; case 6: var string='<span>'+data.data.data[i].professor.name+'中止合作合作结束,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; case 7: var string='<span>合作进行中,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; case 8: var string='<span>完成,查看详情</span><br/>' $(".statuswork").eq(i).html(string); break; default: } } } } else { alert("系统异常!"); } }, "error":function(){$.MsgBox.Alert('message','fail111')} }); } //根据不同的状态进行操作回复或者查看详情 $(".sharesrcbox11").on("click",".replySide",function(){ var operationId=$(this).attr("operationId"); var operationStatus=$(this).attr("operationStatus"); var priceDifference=$(this).attr("dealPrice"); var flag=$(this).attr("flag"); var resourceId=$(this).attr("resourId"); opo=operationId; if(flag==0&&operationStatus==1) { ResourceApply(); ajaxGet(operationId); $(".dealTime").replaceWith("<span class='dealTime'></span>"); $(".detail").replaceWith("<span class='detail'></span>"); $("select").replaceWith("<span class='sname'></span>") $(".btnboxdown").css({"display":"none"}); $(".applysure").css({"display":"none"}); $("#nextStep").click(function(){ $(".stateinfor span").text("报价中"); $(".btnboxup").css({"display":"none"}); $(".btnboxdown").css({"display":"block"}); $(".applysure").css({"display":"block"}); $(".bag").css("display","none"); $(".frm").click(function(){ var $date = {}; $date.detailDemand=$(".detail").text(); $date.deliverTime=replaceStr($.trim($(".dealTime").text())); $date.dealPrice =$("#dealPrice").val(); $date.payMethod = $("#payMethod").val(); $date.replyNotes = $("#consultContent").val(); $date.applysquare = $(".sname").text(); $date.operationId=operationId; $date.operationStatus=2; $.ajax({ "url" : "/ajax/operation", "type" : "put", "data" :JSON.stringify($date), "contentType" :"application/json", "success" : function(data) { if (data.success) { $(".blackcover").remove(); $("body").css("position","static"); getRecentlyData(); $.MsgBox.Alert('message',"报价成功"); } else { $.MsgBox.Alert('message',data.msg); } }, "beforeSend":function(){ //console.log(this.data); }, }); }) }) $("#refuses").click(function(){ ResourceApply(); ajaxGet(operationId); n=5; $(".blackcover").remove(); $("body").css("position","static"); $.MsgBox.Confirm("消息", "确定拒绝吗?",upStatus1); }); } if(flag==0&&operationStatus==2){ ResourceApply(); ajaxGet(operationId); $(".dealTime").replaceWith("<span class='dealTime'></span>"); $(".detail").replaceWith("<span class='detail'></span>"); $("select").replaceWith("<span class='sname'></span>") $(".btnboxdown").css({"display":"none"}); $(".applysure").css({"display":"none"}); $(".stateinfor span").text("修改报价中"); $(".btnboxup").css({"display":"none"}); $(".btnboxdown").css({"display":"block"}); $(".applysure").css({"display":"block"}); $(".bag").css("display","none"); $(".frm").click(function(){ var $date = {}; $date.detailDemand=$(".detail").text(); $date.deliverTime=replaceStr($.trim($(".dealTime").text())); $date.dealPrice = $("#dealPrice").val(); $date.payMethod = $("#payMethod").val(); $date.replyNotes = $("#consultContent").val(); $date.applysquare = $(".sname").text(); $date.operationId=operationId; $date.operationStatus=2; $.ajax({ "url" : "/ajax/operation", "type" : "put", "data" :JSON.stringify($date), "contentType" :"application/json", "success" : function(data) { if (data.success) { $(".blackcover").remove(); $("body").css("position","static"); getRecentlyData(); $.MsgBox.Alert('message',"报价成功"); } else { $.MsgBox.Alert('message',data.msg); } }, "beforeSend":function(){ //console.log(this.data); }, }); }) } if(flag==0&&operationStatus==3){ DetailInfo(); $("#totalPrice").text(priceDifference); $(".liuyaninfo").css("display","none"); $(".pingjiainfo").css("display","none"); $(".filebox").css("display","none"); ajaxGet1(operationId); $(".payaddbox1").css("display","none"); discussGetPaidMoney(operationId,priceDifference) } if(flag==0&&operationStatus==4){ ResourceApply(); ajaxGet1(operationId); $(".dealTime").replaceWith("<span class='dealTime'></span>"); $(".detail").replaceWith("<span class='detail'></span>"); $("select").replaceWith("<span class='sname'></span>") $(".btnboxdown").css({"display":"none"}); $(".applysure").css({"display":"none"}); $(".stateinfor span").text("详情"); $(".btnboxup").css({"display":"none"}); $(".btnboxdown").css({"display":"block"}); $(".applysure").css({"display":"block"}); $(".bag").css("display","none"); $(".addrebtn").css("display","none"); $("#payMethod").replaceWith("<span id='payMethod'><span>"); $("#dealPrice").replaceWith("<span id='dealPrice'><span>"); $("#consultContent").replaceWith("<span id='consultContent'><span>"); } if(flag==0&&operationStatus==5){ ResourceApply(); ajaxGet(operationId); $(".dealTime").replaceWith("<span class='dealTime'></span>"); $(".detail").replaceWith("<span class='detail'></span>"); $("select").replaceWith("<span class='sname'></span>") $(".btnboxdown").css({"display":"none"}); $(".applysure").css({"display":"none"}); $(".addrebtn").css("display","none"); } if(flag==0&&operationStatus==6){ DetailInfo(); $("#totalPrice").text(priceDifference); $(".liuyaninfo").css("display","none"); $(".pingjiainfo").css("display","none"); $(".filebox").css("display","none"); ajaxGet1(operationId); $(".payaddbox1").css("display","none"); discussGetPaidMoney(operationId,priceDifference) } if(flag==0&&operationStatus==7){ DetailInfo(); $("#totalPrice").text(priceDifference); $(".liuyaninfo").css("display","none"); $(".pingjiainfo").css("display","none"); $(".filebox").css("display","none"); ajaxGet1(operationId); $(".payaddbox1").css("display","none"); discussGetPaidMoney(operationId,priceDifference) } if(flag==0&&operationStatus==8){ DetailInfo(); $("#totalPrice").text(priceDifference); $(".liuyaninfo").css("display","none"); $(".pingjiainfo").css("display","none"); $(".filebox").css("display","none"); ajaxGet1(operationId); $(".payaddbox1").css("display","none"); discussGetPaidMoney(operationId,priceDifference) } if(flag==1&&operationStatus==1) { ResourceApply(); $(".limitBox").removeClass("limitBox"); $(".limitwords").removeClass("limitwords"); $(".limitwordbox").removeClass("limitwordbox"); $( "#datepicker" ).datepicker({ "dateFormat":" yy-mm-dd"}); $(".stateinfor span").text("修改申请中"); $(".btnboxup").css({"display":"none"}); $(".applysure").css({"display":"none"}); ajaxGet(operationId,1,1); getIdentity(userid); //if($(".dealTime").val()!=""&&$(".detail").val()!="") //{ $("#deliver").on("click",function() { var $data = {}; $data.demandId = userid; $data.resourceId = resourceId; $data.operationId=operationId; $data.detailDemand=$(".detail").val(); $data.deliverTime=replaceStr($.trim($("#datepicker").val())); $data.applysquare=$("select option:selected").val(); $data.operationStatus=1; $.ajax({ "url" : "/ajax/operation", "type" : "put", "success" : function(rdata){ if (rdata.success){ getRecentlyData(); $(".blackcover").remove(); $("body").css("position","static"); $.MsgBox.Alert('消息',"资源申请信息修改成功"); } else { $.MsgBox.Alert('消息',"资源申请信息修改失败"); } }, "data" : JSON.stringify($data) , "contentType" :"application/json", dataType : "json" }); }); //} } if(flag==1&&operationStatus==2) { ResourceApply(); ajaxGet1(operationId); $(".dealTime").replaceWith("<span class='dealTime'></span>"); $(".detail").replaceWith("<span class='detail'></span>"); $("select").replaceWith("<span class='sname'></span>") $(".btnboxdown").css({"display":"none"}); $(".applysure").css({"display":"none"}); $(".stateinfor span").text("回复报价中"); $(".btnboxup").css({"display":"none"}); $(".btnboxdown").css({"display":"block"}); $(".applysure").css({"display":"block"}); $(".bag").css("display","none"); $(".sendpri").text(""); $("#payMethod").replaceWith("<span id='payMethod'><span>"); $("#dealPrice").replaceWith("<span id='dealPrice'><span>"); $("#consultContent").replaceWith("<span id='consultContent'><span>"); $(".frm")[0].value="直接拒绝"; $("#cooperation")[0].value="合作"; $(".frm").click(function(){ n=4; $(".blackcover").remove(); $("body").css("position","static"); $.MsgBox.Confirm("消息", "确定继续吗?",upStatus1); }) $("#cooperation").click(function(){ n=3; $(".blackcover").remove(); $("body").css("position","static"); upStatus1(); }) } if(flag==1&&operationStatus==3){ DetailInfo(); //console.log(priceDifference); $("#totalPrice").text(priceDifference); $(".liuyaninfo").css("display","none"); $(".pingjiainfo").css("display","none"); $(".filebox").css("display","none"); ajaxGet1(operationId); $(".payaddbox1").css("display","none"); discussGetPaidMoney(operationId,priceDifference); } if(flag==1&&operationStatus==4){ ResourceApply(); ajaxGet1(operationId); $(".dealTime").replaceWith("<span class='dealTime'></span>"); $(".detail").replaceWith("<span class='detail'></span>"); $("select").replaceWith("<span class='sname'></span>") $(".btnboxdown").css({"display":"none"}); $(".applysure").css({"display":"none"}); $(".sendpri").text(""); $(".stateinfor span").text("详情"); $(".resde").text("详情页面"); $(".btnboxup").css({"display":"none"}); $(".btnboxdown").css({"display":"block"}); $(".applysure").css({"display":"block"}); $(".bag").css("display","none"); $(".addrebtn").css("display","none"); $("#payMethod").replaceWith("<span id='payMethod'><span>"); $("#dealPrice").replaceWith("<span id='dealPrice'><span>"); $("#consultContent").replaceWith("<span id='consultContent'><span>"); } if(flag==1&&operationStatus==5){ ResourceApply(); ajaxGet(operationId); $(".stateinfor").find("span").text("合作结束"); $(".dealTime").replaceWith("<span class='dealTime'></span>"); $(".detail").replaceWith("<span class='detail'></span>"); $("select").replaceWith("<span class='sname'></span>") $(".btnboxdown").css({"display":"none"}); $(".applysure").css({"display":"none"}); //$(".resouinfotype2").text(""); $(".addrebtn").css("display","none"); } if(flag==1&&operationStatus==6){ DetailInfo(); $("#totalPrice").text(priceDifference); $(".filebox").css("display","none"); $(".liuyaninfo").css("display","none"); $(".pingjiainfo").css("display","none"); $(".filebox").css("display","none"); ajaxGet1(operationId); $(".payaddbox1").css("display","none"); discussGetPaidMoney(operationId,priceDifference) } if(flag==1&&operationStatus==7){ DetailInfo(); $("#totalPrice").text(priceDifference); $(".liuyaninfo").css("display","none"); $(".pingjiainfo").css("display","none"); $(".filebox").css("display","none"); ajaxGet1(operationId); $(".payaddbox1").css("display","none"); discussGetPaidMoney(operationId,priceDifference) } if(flag==1&&operationStatus==8){ DetailInfo(); $("#totalPrice").text(priceDifference); $(".liuyaninfo").css("display","none"); $(".pingjiainfo").css("display","none"); $(".filebox").css("display","none"); ajaxGet1(operationId); $(".payaddbox1").css("display","none"); discussGetPaidMoney(operationId,priceDifference) } }) function ajaxGet(operationId,o,p){ $.ajax({ "url":"/ajax/operation/"+operationId, "type":"get", "async": true, "success":function(data){ if(data.success) { $(".log").text(data.data.resource.resourceName); $(".timelog").text(changeTime(data.data.createTime)); $(".contration").text(data.data.operationId); $(".detail").text(data.data.detailDemand); if(o==1&&p==1){ $(".dealTime").val(changeTime(data.data.deliverTime)); }else{ $(".dealTime").text(changeTime(data.data.deliverTime)); } if(data.data.professor.name==data.data.applysquare){ $("select").find("option[title=个人]").attr("selected",true); }else{ $("select").find("option[title=所属机构]").attr("selected",true); } $(".sname").text(data.data.applysquare); $(".namecon").text(data.data.resource.professor.name); $(".resouImage").attr("src","/images/resource/"+data.data.resource.resourceId+".jpg"); $(".resouImage").load(function(){}) .error(function(){ $(this).attr("src","/images/default-resource.jpg"); }); if(data.data.payMethod){ $("#payMethod").val(data.data.payMethod); } if(data.data.dealPrice){ $("#dealPrice").val(data.data.dealPrice); } if(data.data.replyNotes){ $("#consultContent").val(data.data.replyNotes); } } else { //console.log("系统异常!"); } }, "error":function(){$.MsgBox.Alert('message','failddd')} }); } function upStatus1(){ $.ajax({"url" : "/ajax/operation/operationStatus", "type" : "POST", "success" : function(rdata) { if (rdata.success) { getRecentlyData(); } else { $.MsgBox.Alert('message','状态更新失败'); } }, "data" :{"operationId":opo,"operationStatus":n}, "beforeSend":function(){/*console.log(this.data)*/}, "contentType" :"application/x-www-form-urlencoded", dataType : "json" }); } function ajaxGet1(operationId){ $.ajax({ "url":"/ajax/operation/"+operationId, "type":"get", "async": true, "success":function(data){ if(data.success) { $(".log").text(data.data.resource.resourceName); $(".timelog").text(changeTime(data.data.createTime)); $(".contration").text(data.data.operationId); $(".detail").text(data.data.detailDemand); $(".dealTime").text(changeTime(data.data.deliverTime)); $(".namecon").text(data.data.resource.professor.name); $(".sname").text(data.data.applysquare); $(".resouImage").attr("src","/images/resource/"+data.data.resource.resourceId+".jpg"); $(".resouImage").load(function(){}) .error(function(){ $(this).attr("src","/images/default-resource.jpg"); }); if(data.data.payMethod){ $("#payMethod").text(data.data.payMethod); } if(data.data.dealPrice){ $("#dealPrice").text(data.data.dealPrice); } if(data.data.replyNotes){ $("#consultContent").text(data.data.replyNotes); } } else { //console.log("系统异常!"); } }, "error":function(){$.MsgBox.Alert('message','failddd')} }); } function discussGetPaidMoney(operationId,priceDifference){ var realCharge=0,balance=0; $.ajax({ "url":"/ajax/payhistory/qadetail", "type":"get", "async": true, "data":{"operationId":operationId}, "success":function(data){ if(data.success){ var popHtml=""; var $data=data.data; var m; for(var i=0;i<$data.length;i++){ PopHtml = '<tr class="payitem">'; PopHtml += '<td><div class="resouinforcon">'+changeTime($data[i].createTime)+'</div></td>'; PopHtml += '<td><div class="resouinforcon">'+$data[i].professor.name+'</div></td>'; PopHtml += '<td><div class="resouinforcon resou"></div></td>'; PopHtml += '<td><div class="resouinforcon to"></div></td>'; PopHtml += '<td><div class="resouinforcon resta"></div></td>'; PopHtml += '<td><div class="resouinforcon">'+$data[i].remark+'</div></td>'; PopHtml += '</tr>'; $("#paytit").append(PopHtml); if($data[i].paidMoney==undefined) { $data[i].paidMoney=0; } if($data[i].returnMoney==undefined) { $data[i].returnMoney=0; } m=$data[i].paidMoney-$data[i].returnMoney; $(".to").eq(i).text(m); if($data[i].payType==0){ $(".resou").eq(i).text("线下支付"); }else{ $(".resou").eq(i).text("线上支付"); } if($data[i].payStatus==0){ $(".resta").eq(i).text("未确认"); }else{ $(".resta").eq(i).text("确认收款"); } popHtml=""; realCharge+=m; } balance=priceDifference-realCharge; $("#balance").text(balance); $("#realCharge").text(realCharge); } else { //console.log("系统异常!"); } }, "error":function(){$.MsgBox.Alert('message','failddd')} }); } function getIdentity(professorId){ $.ajax({ "url":"ajax/professor/"+professorId, "type":"get", "async": false, "success":function(data){ if(data.success) { $("option")[0].value=data.data.name; $("option")[1].value=data.data.organization.name; } else { $.MsgBox.Alert("消息","系统异常!"); } }, "error":function(){$.MsgBox.Alert('message','failddd')} }) } //正在合作的数量 $.ajax({ "url":"/ajax/operation/qaOnGoingOper", "type":"get", "data":{"professorId":userid}, "async": true, "success":function(data) { if(data.success) { $("#workcontain").text(data.data); } } }); //最新咨询中的发送 $("#myFlatSendConsultBtn").bind("click",newConsultSendFn); //最新回复中的发送 $("#myFlatSendReplyBtn").bind("click",newReplySendFn); //点击最新咨询查看全部 $("#lookAllConsult,#lookMyConsult").click(function(){ $("#consultbtn").css({ color:"#fff", background:"#f99550" }); lookall = 1; clickConsultBtn(lookall); }); //点击最新回复查看全部 $("#lookAllReply").click(function(){ $("#consultbtn").css({ color:"#fff", background:"#f99550" }); lookall = 2; clickConsultBtn(lookall); }); getConsultData(userid); getReplyData(userid); queryUnreadConsultFn(userid);//未读咨询总数 function queryUnreadConsultFn(professorId){//未读咨询总数函数 var params = {"professorId":professorId}; $.ajax({ "url":"/ajax/consult/qaReadStatus", "type":"get", "async": false, "data":params, "success":function(response){ $("#unreadConsult").html(response["data"]); }, "error":function(){ $.MsgBox.Alert('message','总的未读咨询条数请求失败'); } }); }; function getConsultData(professorId){ var params = {"professorId":professorId}; $.ajax({ "url":"/ajax/consult/qaNewConsult", "type":"get", "async": false, "data":params, "success":function(response){ if(response.success) { if(response.data != null) { var newConsultData = response["data"]; $("#myFlatConsultTime").attr("consultId",newConsultData["consultId"]); $("#myFlatProName").text(newConsultData["professor"]["name"]); if(newConsultData["professor"]["office"]) { $("#myReplyProOffice").html(newConsultData["professor"]["office"]+","); } if(newConsultData["professor"]["title"]) { $("#myReplyProTitle").html(newConsultData["professor"]["title"]); } if(newConsultData["professor"]["department"]) { $("#myReplyProDepartment").html(newConsultData["professor"]["department"]+","); } if(newConsultData["professor"]["orgName"]) { $("#myReplyProOrgName").html(newConsultData["professor"]["orgName"]); } if(newConsultData["professor"]["address"]) { $("#myReplyAddress").html(newConsultData["professor"]["address"]); } $("#myFlatConsultTime").html(newConsultData["createTime"].substr(0,4) + "-" + newConsultData["createTime"].substr(4,2) + "-" + newConsultData["createTime"].substr(6,2) + " " + newConsultData["createTime"].substr(8,2)+ ":" +newConsultData["createTime"].substr(10,2)); $("#myFlatConsultTitle").html(newConsultData["consultTitle"]); $("#myFlatConsultContent").html(newConsultData["consultContant"]); if(response.data.professor.hasHeadImage){ $("#proImage").attr("src","images/head/"+response.data.professor.id+"_m.jpg"); }else{ $("#proImage").attr("src","images/default-photo.jpg"); } } else { $("#wbcon1").empty(""); var height=$("#repalyf").height(); $("#wbcon1").append('<span id="wbcen">暂无最新咨询消息</span>').css("height",height); var oHeight=($("#wbcon1").height()-$("#wbcen").height())/2; var oWidth=($("#wbcon1").width()-$("#wbcen").width())/2; $("#wbcen").css({"color":"#999","display":"inline-block","margin-top":oHeight,"margin-left":oWidth}); } } else { $.MsgBox.Alert("消息","最新咨询数据请求失败"); } }, "error":function(){ $.MsgBox.Alert('message','最新咨询数据请求失败'); } }) } function getReplyData(consultantId){ var params = {"consultantId":consultantId}; $.ajax({ "url":"/ajax/tidings/qaNewReply", "type":"get", "async": true, "data":params, "success":function(response){ if(response.success) { if(response["data"] != null) { var newReplyData = response["data"]; $("#myFlatRelpyTime").attr("consultId",newReplyData["consult"]["consultId"]); $("#myFlatReplyProName").html(newReplyData["professor"]["name"]); if(newReplyData["professor"]["office"]) { $("#myProOffice").html(newReplyData["professor"]["office"]+","); } if(newReplyData["professor"]["title"]) { $("#myProTitle").html(newReplyData["professor"]["title"]); } if(newReplyData["professor"]["department"]) { $("#myProDepartment").html(newReplyData["professor"]["department"]+","); } if(newReplyData["professor"]["orgName"]) { $("#myProOrgName").html(newReplyData["professor"]["orgName"]); } if(newReplyData["professor"]["address"]) { $("#myAddress").html(newReplyData["professor"]["address"]); } $("#myFlatRelpyTime").html(newReplyData["createTime"].substr(0,4) + "-" + newReplyData["createTime"].substr(4,2) + "-" + newReplyData["createTime"].substr(6,2) + " " + newReplyData["createTime"].substr(8,2)+ ":" +newReplyData["createTime"].substr(10,2)); $("#myFlatRelpyTitle").html(newReplyData["consult"]["consultTitle"]); $("#myFlatRelpyContent").html(newReplyData["tidingsContant"]); if(response.data.professor.hasHeadImage){ $("#proreplayImage").attr("src","images/head/"+response.data.professor.id+"_m.jpg"); }else{ $("#proreplayImage").attr("src","images/default-photo.jpg"); } } else { $("#wbcon2").empty("") var height=$("#wbcon1").height(); $("#wbcon2").append('<span id="wbcent">暂无最新回复消息</span>').css("height",height); var oHeight=($("#wbcon2").height()+40-$("#wbcent").height())/2; var oWidth=($("#wbcon2").width()-$("#wbcent").width())/2; $("#wbcent").css({"color":"#999","display":"inline-block","margin-top":oHeight,"margin-left":oWidth}); } } else { $.MsgBox.Alert('message','最新回复数据请求失败'); } }, "error":function(){ $.MsgBox.Alert('message','最新回复数据请求失败'); } }) } //发送userid:用户id,container:获得内容的container function newConsultSendFn(){ var consultId = $("#myFlatConsultTime").attr("consultId"); var consultCon = $("#myFlatConsultCon").val(); var params = { "tidingsContant":consultCon, "consultId":consultId, "senderId":userid } $.ajax({ url:"/ajax/tidings", type:"post", async:true, "contentType" : "application/x-www-form-urlencoded", data:params, success:function(response){ getConsultData(userid); }, error:function(error){ } }); $("#myFlatConsultCon").val(""); }; function newReplySendFn(){ var consultId = $("#myFlatRelpyTime").attr("consultId"); var consultCon = $("#myFlatReplyCon").val(); var params = { "tidingsContant":consultCon, "consultId":consultId, "senderId":userid } $.ajax({ url:"/ajax/tidings", type:"post", async:false, "contentType" : "application/x-www-form-urlencoded", data:params, success:function(response){ getReplyData(userid); }, error:function(error){ } }); // $.MsgBox.Alert("消息","回复成功!"); $("#myFlatReplyCon").val(""); }; });