$(document).ready(function() { $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent"); loginStatus(); //判断个人是否登录 valUser(); var userid = $.cookie("userid"); var yesNo = "", oSortType = 0, demandType, orgId; /*我的需求列表*/ 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) { // if(data.data.data.length==0){ // return; // } $(".workselectitem").html(" "); demandHtml(data.data.data); if(data.data.data.length==0) return; 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 + "
" $("#myNeed").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); $("#myNeed").on("click", ".replybtn", function() { var de = $(this).attr("demanid"); location.href = "needShow.html?demandId=" + de }); /*发布新需求*/ $("#needIssueBtn").click(function() { $.ajax({ url: "/ajax/professor/baseInfo/" + userid, type: "GET", timeout: 10000, dataType: "json", success: function(data) { if(data.success) { console.log(data); var $rta = data.data; orgId = $rta.orgId console.log(orgId) $("#induSub").val(""); $("textarea").val(""); $("#demandContent").val(""); $("#navsub").find("li").removeClass("aimedLi"); $("#mutChecked").find("li").removeClass("checkedLi"); $('.checkNow').removeClass('checkNow'); if($rta.authStatus != 3) { if($rta.orgAuth == 1) { $(".blackcover ").show(); $("body").css("position","fixed"); $("span:contains('企业需求')").addClass("checkNow"); $("span:contains('个人需求')").addClass("checkNo"); demandType = 2; } else { location.href = "realname-authentication.html"; } } else { $(".blackcover ").show(); $("body").css("position","fixed"); if($rta.orgAuth == 0) { $("span:contains('企业需求')").addClass("checkNo"); $("span:contains('个人需求')").addClass("checkNow"); demandType = 1; } else { demanTy(); } } } }, error: function(XMLHttpRequest, textStats, errorThrown) { } }) }); $("#workclose2").click(function() { $(".blackcover ").hide(); $("body").css("position","relative"); }) /*发布新需求目的*/ var consun; tab("navsub"); //身份切换 function tab(name) { var oDome = document.getElementById(name); var oSpan = oDome.getElementsByTagName('ul')[0].childNodes; for(var i = 0; i < oSpan.length; i++) { oSpan[i].onclick = function() { for(var i = 0; i < oSpan.length; i++) { oSpan[i].className = ''; } this.className = 'aimedLi'; if(this.getElementsByTagName("span")[0].innerText == "咨询技术难题") { consun = 1; } else if(this.getElementsByTagName("span")[0].innerText == "寻求研发资源") { consun = 2; } else { consun = 3; } } } } /*切换需求类型*/ function demanTy() { var deTy = document.getElementsByClassName("boxnavTo")[0]; var deTyChild = deTy.getElementsByTagName("span"); if(deTyChild[0].className != "checkNo" && deTyChild[1].className != "checkNo") { for(var n = 0; n < deTyChild.length; n++) { (function(m) { deTyChild[m].onclick = function() { this.className = "checkNow"; if(m == 0) { demandType = 1; deTyChild[1].className = ""; } else if(m == 1) { demandType = 2; deTyChild[0].className = ""; } } })(n); } } } /*需求题目限制30个字*/ $("#demandContent").on('keyup', function() { if(this.value.length > 30) { this.value = this.value.substring(0, 30); } }); /*需求内容限制300个字*/ $("textarea").on('keyup', function() { var maxChars = 300; if(this.value.length > maxChars) { this.value = this.value.substring(0, maxChars); } var oCanInput = maxChars - this.value.length; $("#countNum").text(oCanInput); }); /*查询应用行业及学术领域*/ function industry(insu) { $.ajax({ url: "/ajax/dataDict/qaDictCode", dataType: 'json', //数据格式类型 type: 'GET', //http请求类型 timeout: 10000, //超时设置 data: { "dictCode": insu }, success: function(data) { if(data.success) { var $data = data.data; var n; ($data.length > 5) ? n = 5: n = $data.length for(var i = 0; i < n; i++) { var oString = '
  • ' + $data[i].caption + '
  • '; $("#mutChecked").append(oString); } } }, error: function() { return; } }); } industry("INDUSTRY"); industry("SUBJECT"); /*行业及领域选择*/ $('#mutChecked').on('click', 'li', function() { if(this.className == "checkedLi") { this.className = "" } else { this.className = "checkedLi" } }) /*行业或者领域添加及删除*/ $("#labelshow").on("click", ".removeNu", function() { $(this).parent().remove(); }); $("#addIndu").click(function() { var oinduSub = $("#induSub").val(); var oAddNum = $("#labelshow").find("em"); if(!oinduSub.trim()) { $.MsgBox.Alert("消息", "请先添加内容"); return; } if(oinduSub.trim().length > 10) { $.MsgBox.Alert("消息", "不能多于10个字"); return; } if(oAddNum.length == 5) { $.MsgBox.Alert("消息", "最多添加五条"); return; } for(var i = 0; i < oAddNum.length; i++) { if(oAddNum[i].innerHTML == oinduSub) { $.MsgBox.Alert("消息", "不能重复添加"); return; } } $("#labelshow").append('
  • ' + oinduSub + '
  • ') $("#induSub").val(""); }) /*发布新需求*/ $("#postDemand").click(function() { var dd = $("#navsub").find(".aimedLi"); var cc = $("#navsubTo").find(".checkNow"); if(dd.length == 0) { $.MsgBox.Alert("消息", "请选择您发布需求的目的"); return; } if(cc.length == 0) { $.MsgBox.Alert("消息", "请选择您的需求类型"); return; } if(!$("#demandContent").val().trim()) { $.MsgBox.Alert("消息", "请填写需求主题"); return; } if(!$("textarea").val().trim()) { $.MsgBox.Alert("消息", "请填写需求内容"); return; } publish() }); function publish() { var arr = []; var oSuin = $(".checkedLi"); var oin = $("#labelshow").find("li"); for(var i = 0; i < oSuin.length; i++) { arr[i] = oSuin[i].innerText; } for(var j = 0; j < oin.length; j++, i++) { //console.log(oin[j].innerText); arr[i] = oin[j].innerText; } $.ajax({ url: '/ajax/demand', dataType: 'json', //数据格式类型 type: 'post', //http请求类型 timeout: 10000, //超时设置 traditional: true, data: { "demander": userid, "demandAim": consun, "demandType": demandType, "demandTitle": $("#demandContent").val(), "demandContent": $("textarea").val(), "args": arr, "orgId": (demandType == 2) ? orgId : "", }, success: function(data) { if(data.success) { myDemandList(true, 1, 5, yesNo, oSortType); $(".blackcover ").hide(); $("body").css("position","relative"); $.MsgBox.Alert("消息", "需求发布成功!很快会有专家与您联系,您可以在咨询列表中查看专家回复的信息"); $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain'); } }, error: function() { return; } }); } /*判断是否是专家*/ $.ajax({ url: "/ajax/professor/auth", type: "GET", timeout: 10000, dataType: "json", data: { "id": userid, }, success: function(data, textState) { if(data.success) { var $rta = data.data; if($rta.authType == 0) { $("#searchDemand").hide(); } } }, error: function(XMLHttpRequest, textStats, errorThrown) { } }) })