$(document).ready(function() {
$(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
loginStatus();//判断个人是否登录
var oDemandAim = "",
oSortType = "";
/*需求列表*/
function demandList(isbind, pageSize, pageNo, oDemand, oSort) {
$.ajax({
url: "/ajax/demand/pq",
type: "GET",
timeout: 10000,
dataType: "json",
data: {
"pageNo": pageNo,
"demandAim": oDemand,
"sortType": oSort
},
beforeSend: function() {},
success: function(data, textState) {
if(data.success) {
//console.log(data);
$("#demandList").html(" ");
var $info = data.data.data;
demandHtml($info);
if(isbind == true) {
$(".tcdPageCode").createPage({
pageCount: Math.ceil(data.data.total / pageSize),
current: data.data.data.pageNo,
backFn: function(p) {
demandList(false, 5, p, oDemandAim, oSortType);
}
});
}
}
},
error: function(XMLHttpRequest, textStats, errorThrown) {
}
})
}
function demandHtml($data) {
for(var i = 0; i < $data.length; i++) {
var $obje = $data[i].professor;
var personStr = personalInformation($obje);
var demandAim = "技术咨询",
demandType = "企业需求";
var oImg = "",
oTime = "";
if($data[i].demandAim == 2) {
demandAim = "寻找资源"
} else if($data[i].demandAim == 3) {
demandAim = "其他需求"
}
if($data[i].demandType == 1) {
demandType = "个人需求"
}
if($obje.hasHeadImage) {
oImg = "/images/head/" + $obje.id + "_l.jpg";
} else {
oImg = "images/default-photo.jpg"
}
//认证
var oSty=autho($obje.authType,$obje.orgAuth,$obje.authStatus);
typeTname = oSty.sty;
oTime = $data[i]["createTime"].substr(0, 4) + "年" + $data[i].createTime.substr(4, 2) + "月" + $data[i].createTime.substr(6, 2) + "日" +
$data[i].createTime.substr(8, 2) + ":" + $data[i].createTime.substr(10, 2);
var dataString = "
"
dataString += ""
dataString += ""
dataString += " | "
dataString += ""
dataString += ""
dataString += "" + personStr + ""
dataString += ""
dataString += "需求主题:" + $data[i].demandTitle + " "
dataString += "" + oTime + ""
dataString += "" + $data[i].demandContent + " "
dataString += ""
dataString += "查看 "
dataString += " "
dataString += "" + demandAim + " "
dataString += " "
dataString += "" + demandType + ""
dataString += " |
"
$("#demandList").append(dataString);
}
}
/*职位职称所在机构,部门,地址等等*/
function personalInformation($person) {
var arr1 = [$person.title, $person.office, $person.department, $person.orgName, $person.address];
var arr = new Array();
var arr2 = new Array();
var n = 0;
for(var i = 0; i < arr1.length; i++) {
if(arr1[i]) {
arr.push(arr1[i]);
if(arr1[i] == arr1[arr1.length - 1]) {
n = 1;
}
}
}
if(n == 1) {
for(var i = 0; i < arr.length-1; i++) {
arr2.push(arr[i]);
}
return arr2.join()+ " | " + arr[arr.length - 1];
} else {
return arr.join();
}
}
demandList(true, 5, 1, oDemandAim, oSortType);
/*检索排序*/
function selcet(i) {
$(".selcet" + i).on('click', function(e) {
var option = $(this).find(".option" + i);
option.css("display", "block")
var o_this = $(this);
o_this.find("li").click(function() {
o_this.find("li").removeClass("workcurrent");
$(this).addClass("workcurrent");
o_this.find("span").text($(this).text());
option.css("display", "none");
if($(this).text() == "技术咨询") {
oDemandAim = 1;
$(".tcdPageCode").remove();
$("#shoudao").append('');
demandList(true, 5, 1, oDemandAim, oSortType);
} else if($(this).text() == "资源合作") {
oDemandAim = 2;
$(".tcdPageCode").remove();
$("#shoudao").append('');
demandList(true, 5, 1, oDemandAim, oSortType);
} else if($(this).text() == "其他需求") {
oDemandAim = 3;
$(".tcdPageCode").remove();
$("#shoudao").append('');
demandList(true, 5, 1, oDemandAim, oSortType);
} else if($(this).text() == "不限") {
oDemandAim = "";
$(".tcdPageCode").remove();
$("#shoudao").append('');
demandList(true, 5, 1, oDemandAim, oSortType);
} else if($(this).text() == "按最早发布时间排序") {
oSortType = 1;
$(".tcdPageCode").remove();
$("#shoudao").append('');
demandList(true, 5, 1, oDemandAim, oSortType);
} else if($(this).text() == "按最新发布时间排序") {
oSortType = 0;
$(".tcdPageCode").remove();
$("#shoudao").append('');
demandList(true, 5, 1, oDemandAim, oSortType);
}
return false;
});
$("body").click(function(e) {
if($(".option4")[0].style.display == "block" || $(".option3")[0].style.display == "block") {
$(".option4")[0].style.display = "none";
$(".option3")[0].style.display = "none";
}
});
return false;
})
}
selcet(3);
selcet(4);
/*进入needSure.html*/
$("#demandList").on("click", ".replybtn", function() {
var demand = $(this).attr("demanid");
location.href = "needSure.html?demandId=" + demand;
})
})