$(document).ready(function() {
loginStatus(); //判断个人是否登录
var userid=$.cookie("userid");
var demandId = GetQueryString("demandId");
var pid = GetQueryString("pid");
getDemandinfo();
getPlatName();
userFun();
$(".showStatus").on('click',".meSendBack",function(){
if(userid && userid != null && userid != 'null' && userid != undefined && userid != 'undefined') {
$(".questionCover").fadeIn();
$("body").css("position", "fixed");
} else {
quickLog();
operatTab();
closeLog();
}
});
$("#workclose,#preSte").on("click",function(){
$("#queTit").val('');
$(".questionCover").fadeOut();
$("body").css("position", "");
})
$(".showStatus").on("click",".flexCenter",function(){
location.href="userInforShow.html?professorId="+userid;
})
$("#pubSte").on("click",function(){
if (!$('#queTit').val()) {
$.MsgBox.Alert('提示', '留言不能为空')
return;
}
replayDemand();
})
function getPlatName() {
$.ajax({
url: "/ajax/platform/info",
type: "GET",
timeout: 10000,
dataType: "json",
traditional:true,
data:{
id: pid
},
success: function(data) {
if(data.success) {
$('.platName').text(data.data.name);
}
},
error: function() {
$.MsgBox.Alert('提示', '链接服务器超时')
}
})
}
function getDemandinfo(){
$.ajax({
"url": "/ajax/platform/demand/qo",
"type": "GET",
"data": {
"id": demandId,
"pid": pid,
},
"dataType": "json",
"success": function(data) {
console.log(data);
if(data.success) {
var $da=data.data;
$("#demandTit").text($da.title); //名字
var thisNum="";
thisNum+='
需求方: '+$da.linkOrg+'';
thisNum+='发布时间:'+commenTime($da.publishTime)+'';
$("#demandNum").prepend(thisNum);
$("#demandDesp")[0].innerText=$da.descp; //内容
document.title = $da.title + "-科袖网";
var strCon="";
if($da.city){ strCon+='所在城市:'+$da.city+'' }
if($da.duration){ strCon+='预计周期:'+$da.duration+'' }
if($da.cost){ strCon+='费用预算:'+$da.cost+'' }
if($da.invalidDay){ strCon+='有效期至:'+TimeTr($da.invalidDay)+'' }
$(strCon).appendTo($("#demandInf"));
}
},
'error': function() {
$.MsgBox.Alert('提示', '服务器连接超时!');
}
});
}
function replayDemand() {
$.ajax({
"url": "/ajax/platform/demand/reply",
"type": "POST",
"data": {
"id": demandId,
"pid": pid,
"uid": userid,
"descp": $('#queTit').val()
},
"dataType": "json",
"success": function(data) {
console.log(data);
if(data.success) {
$(".questionCover").fadeOut();
$("body").css("position", "");
$(".queStep").find("textarea").val("")
$.MsgBox.Alert("提示","留言发布成功");
$("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
userFun();
}
},
'error': function() {
$.MsgBox.Alert('提示', '服务器连接超时!');
}
})
}
function getProfessor(id,descp,timer) {
$.ajax({
"url": "/ajax/professor/baseInfo/"+id,
"type": "get",
"dataType": "json",
"success": function(data) {
if(data.success) {
var $data=data.data;
var img;
var oClass = autho($data.authType, $data.orgAuth, $data.authStatus);
var oTitle = "";
if($data.title) {
oTitle = $data.title;
} else {
if($data.office) {
oTitle = $data.office;
}
}
if($data.hasHeadImage==1) {
img = "/images/head/" + $data.id + "_l.jpg";
} else {
img = "../images/default-photo.jpg"
}
var oSt = '您已回复该需求'
oSt += ''
oSt += ''
oSt += ''
oSt += '
'
oSt += '' + $data.name + ''
oSt += '
'
oSt += '
' + oTitle + '
'
oSt += '
'
oSt += ''
oSt += '留言:'+descp+''+timer+''
$(".showStatus").html(oSt);
}
},
'error': function() {
$.MsgBox.Alert('提示', '服务器连接超时!');
}
})
}
function userFun() {
$.ajax({
"url": "/ajax/platform/demand/pro",
"type": "get",
"data": {
"id":demandId ,
"pid":pid,
"uid":userid
},
"async": true,
"datatype":"json",
"success": function(data) {
if(data.success) {
console.log(data);
if(data.data) {
getProfessor(userid,data.data.descp,commenTime(data.data.assTime));
$(".showStatus").addClass("showStatusY")
} else {
$(".showStatus").html('')
}
}
},
"error": function() {
$.MsgBox.Alert('提示', '链接服务器超时')
}
});
}
})