$(document).ready(function() {
var yesNo = "",
oSortType = 0;
/*我的需求列表*/
function myDemandList(isbind, page,pageNum,dema,sortType) {
$.ajax({
url: "/ajax/demand/pqDemander",
type: "GET",
timeout: 10000,
dataType: "json",
data: {
"demander": userid,
"pageNo": page,
"demandStatus": dema,
"sortType": sortType,
"pageSize": pageNum
},
beforeSend: function() {},
success: function(data, textState) {
if(data.success) {
console.log(data);
$(".workselectitem").html(" ");
demandHtml(data.data.data);
if(isbind == true) {
$(".tcdPageCode").createPage({
pageCount: Math.ceil(data.data.total / pageNum),
current: data.data.data.pageNo,
backFn: function(p) {
myDemandList(false, p,5,yesNo,oSortType);
}
});
}
}
},
error: function(XMLHttpRequest, textStats, errorThrown) {
}
})
}
function demandHtml($data) {
for(var i = 0; i < $data.length; i++) {
var oTime, oDemandType, oDemandAim, oDemandStatus;
if($data[i].demandType == 1) {
oDemandType = "个人需求"
} else if($data[i].demandType == 2) {
oDemandType = "企业需求"
}
if($data[i].demandAim == 1) {
oDemandAim = "技术咨询"
} else if($data[i].demandAim == 2) {
oDemandAim = "寻找资源"
} else if($data[i].demandAim == 3) {
oDemandAim = "其他需求"
}
if($data[i].demandStatus == 0) {
oDemandStatus = "已关闭"
} else if($data[i].demandStatus == 1) {
oDemandStatus = "发布中"
}
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 oString = "
"
oString += ""
oString += ""
oString += " " + $data[i].demandTitle + " "
oString += " "
oString += ""
oString += " 发布时间:" + oTime + " "
if($data[i].closeTime) {
var oCloseTime = $data[i]["closeTime"].substr(0, 4) + "年" + $data[i].closeTime.substr(4, 2) + "月" + $data[i].closeTime.substr(6, 2) + "日" +
$data[i].closeTime.substr(8, 2) + ":" + $data[i].closeTime.substr(10, 2);
oString += " 关闭时间:" + oCloseTime + " "
}
oString += "" + $data[i].demandContent + " "
oString += ""
oString += " "
oString += "查看 "
oString += " "
oString += "" + oDemandStatus + " "
oString += " "
oString += "" + oDemandAim + " "
oString += " "
oString += "" + oDemandType + " |
"
$(".workselectitem").append(oString)
}
}
myDemandList(true, 1,5,yesNo,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() == "全部") {
yesNo = "";
$(".tcdPageCode").remove();
$("#workContainer2").append('');
myDemandList(true, 1,5,yesNo,oSortType);
} else if($(this).text() == "发布中") {
yesNo = 1;
$(".tcdPageCode").remove();
$("#workContainer2").append('');
myDemandList(true, 1,5,yesNo,oSortType);
} else if($(this).text() == "已关闭") {
yesNo = 0;
$(".tcdPageCode").remove();
$("#workContainer2").append('');
myDemandList(true, 1,5,yesNo,oSortType);
} else if($(this).text() == "按最早发布时间排序") {
oSortType = 1;
$(".tcdPageCode").remove();
$("#workContainer2").append('');
myDemandList(true, 1,5,yesNo,oSortType);
} else if($(this).text() == "按最新发布时间排序") {
oSortType = 0;
$(".tcdPageCode").remove();
$("#workContainer2").append('');
myDemandList(true, 1,5,yesNo,oSortType);
}
return false;
});
$("body").click(function(e) {
if($(".option4")[0].style.display == "block" || $(".option1")[0].style.display == "block") {
$(".option4")[0].style.display = "none";
$(".option1")[0].style.display = "none";
}
});
return false;
})
}
selcet(1);
selcet(4);
$(".workselectitem").on("click",".replybtn",function(){
var de=$(this).attr("demanid");
location.href="needShow.html?demandId="+de
})
})