|
$(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 = "<table width='100%'><tbody><tr>"
oString += "<td style='position:relative;top:20px;'>"
oString += "<div class='workinfor worksitcon'>"
oString += "<h4><div class='titList h4Font' style='width:620px'>" + $data[i].demandTitle + "</div></h4>"
oString += "<h6 style='position:relative;'>"
oString += "<div class='clearfix'>"
oString += "<div class='floatL'>发布时间:<span class='lasttime'>" + oTime + "</span></div>"
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 += "<div class='floatL' style='margin-left:40px;'>关闭时间:<span class='lasttime'>" + oCloseTime + "</span></div></div>"
}
oString += "<p class='rebackcon lastReplyCon' style='width: 860px;' >" + $data[i].demandContent + "</p></h6></div>"
oString += "<div class='workhandle'>"
oString += "<div class='rightopert floatR'>"
oString += "<span class='replybtn'demanid='" + $data[i].demandId + "'>查看</span></div>"
oString += "<div class='leftstate floatR'>"
oString += "<span class='coultstate status-1'><i>" + oDemandStatus + "</i></span></div>"
oString += "<div class='leftstate floatR'>"
oString += "<span class='coultstate status-4'><i>" + oDemandAim + "</i></span></div>"
oString += "<div class='leftstate floatR'>"
oString += "<span class='coultstate coulstAim status-4'><i>" + oDemandType + "</i></span></div></div></td></tr></tbody></table>"
$(".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('<div class="tcdPageCode"></div>');
myDemandList(true, 1,5,yesNo,oSortType);
} else if($(this).text() == "发布中") {
yesNo = 1;
$(".tcdPageCode").remove();
$("#workContainer2").append('<div class="tcdPageCode"></div>');
myDemandList(true, 1,5,yesNo,oSortType);
} else if($(this).text() == "已关闭") {
yesNo = 0;
$(".tcdPageCode").remove();
$("#workContainer2").append('<div class="tcdPageCode"></div>');
myDemandList(true, 1,5,yesNo,oSortType);
} else if($(this).text() == "按最早发布时间排序") {
oSortType = 1;
$(".tcdPageCode").remove();
$("#workContainer2").append('<div class="tcdPageCode"></div>');
myDemandList(true, 1,5,yesNo,oSortType);
} else if($(this).text() == "按最新发布时间排序") {
oSortType = 0;
$(".tcdPageCode").remove();
$("#workContainer2").append('<div class="tcdPageCode"></div>');
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
})
})
|