portal html css js resource

myDemand.js 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. $(document).ready(function() {
  2. $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
  3. loginStatus(); //判断个人是否登录
  4. valUser();
  5. var userid = $.cookie("userid");
  6. var yesNo = "",
  7. oSortType = 0,
  8. demandType, orgId;
  9. /*我的需求列表*/
  10. function myDemandList(isbind, page, pageNum, dema, sortType) {
  11. $.ajax({
  12. url: "/ajax/demand/pqDemander",
  13. type: "GET",
  14. timeout: 10000,
  15. dataType: "json",
  16. data: {
  17. "demander": userid,
  18. "pageNo": page,
  19. "demandStatus": dema,
  20. "sortType": sortType,
  21. "pageSize": pageNum
  22. },
  23. beforeSend: function() {},
  24. success: function(data, textState) {
  25. if(data.success) {
  26. // if(data.data.data.length==0){
  27. // return;
  28. // }
  29. $(".workselectitem").html(" ");
  30. demandHtml(data.data.data);
  31. if(data.data.data.length==0) return;
  32. if(isbind == true) {
  33. $(".tcdPageCode").createPage({
  34. pageCount: Math.ceil(data.data.total / pageNum),
  35. current: data.data.data.pageNo,
  36. backFn: function(p) {
  37. myDemandList(false, p, 5, yesNo, oSortType);
  38. }
  39. });
  40. }
  41. }
  42. },
  43. error: function(XMLHttpRequest, textStats, errorThrown) {
  44. }
  45. })
  46. }
  47. function demandHtml($data) {
  48. for(var i = 0; i < $data.length; i++) {
  49. var oTime, oDemandType, oDemandAim, oDemandStatus;
  50. if($data[i].demandType == 1) {
  51. oDemandType = "个人需求"
  52. } else if($data[i].demandType == 2) {
  53. oDemandType = "企业需求"
  54. }
  55. if($data[i].demandAim == 1) {
  56. oDemandAim = "技术咨询"
  57. } else if($data[i].demandAim == 2) {
  58. oDemandAim = "寻找资源"
  59. } else if($data[i].demandAim == 3) {
  60. oDemandAim = "其他需求"
  61. }
  62. if($data[i].demandStatus == 0) {
  63. oDemandStatus = "已关闭"
  64. } else if($data[i].demandStatus == 1) {
  65. oDemandStatus = "发布中"
  66. }
  67. oTime = $data[i]["createTime"].substr(0, 4) + "年" + $data[i].createTime.substr(4, 2) + "月" + $data[i].createTime.substr(6, 2) + "日" +
  68. $data[i].createTime.substr(8, 2) + ":" + $data[i].createTime.substr(10, 2);
  69. var oString = "<div class='workselectitem'><table width='100%'><tbody><tr>"
  70. oString += "<td style='position:relative;top:20px;'>"
  71. oString += "<div class='workinfor worksitcon'>"
  72. oString += "<h4><div class='titList h4Font' style='width:620px'>" + $data[i].demandTitle + "</div></h4>"
  73. oString += "<h6 style='position:relative;'>"
  74. oString += "<div class='clearfix'>"
  75. oString += "<div class='floatL'>发布时间:<span class='lasttime'>" + oTime + "</span></div>"
  76. if($data[i].closeTime) {
  77. var oCloseTime = $data[i]["closeTime"].substr(0, 4) + "年" + $data[i].closeTime.substr(4, 2) + "月" + $data[i].closeTime.substr(6, 2) + "日" +
  78. $data[i].closeTime.substr(8, 2) + ":" + $data[i].closeTime.substr(10, 2);
  79. oString += "<div class='floatL' style='margin-left:40px;'>关闭时间:<span class='lasttime'>" + oCloseTime + "</span></div></div>"
  80. }
  81. oString += "<div style='height:70px'><p class='rebackcon lastReplyCon' style='width: 860px;' >" + $data[i].demandContent + "</p></div></h6></div>"
  82. oString += "<div class='workhandle'>"
  83. oString += "<div class='rightopert floatR'>"
  84. oString += "<span class='replybtn'demanid='" + $data[i].demandId + "'>查看</span></div>"
  85. oString += "<div class='leftstate floatR'>"
  86. oString += "<span class='coultstate status-1'><i>" + oDemandStatus + "</i></span></div>"
  87. oString += "<div class='leftstate floatR'>"
  88. oString += "<span class='coultstate status-4'><i>" + oDemandAim + "</i></span></div>"
  89. oString += "<div class='leftstate floatR'>"
  90. oString += "<span class='coultstate coulstAim status-4'><i>" + oDemandType + "</i></span></div></div></td></tr></tbody></table></div>"
  91. $("#myNeed").append(oString)
  92. }
  93. }
  94. myDemandList(true, 1, 5, yesNo, oSortType);
  95. /*检索排序*/
  96. function selcet(i) {
  97. $(".selcet" + i).on('click', function(e) {
  98. var option = $(this).find(".option" + i);
  99. option.css("display", "block")
  100. var o_this = $(this);
  101. o_this.find("li").click(function() {
  102. o_this.find("li").removeClass("workcurrent");
  103. $(this).addClass("workcurrent");
  104. o_this.find("span").text($(this).text());
  105. option.css("display", "none");
  106. if($(this).text() == "全部") {
  107. yesNo = "";
  108. $(".tcdPageCode").remove();
  109. $("#workContainer2").append('<div class="tcdPageCode"></div>');
  110. myDemandList(true, 1, 5, yesNo, oSortType);
  111. } else if($(this).text() == "发布中") {
  112. yesNo = 1;
  113. $(".tcdPageCode").remove();
  114. $("#workContainer2").append('<div class="tcdPageCode"></div>');
  115. myDemandList(true, 1, 5, yesNo, oSortType);
  116. } else if($(this).text() == "已关闭") {
  117. yesNo = 0;
  118. $(".tcdPageCode").remove();
  119. $("#workContainer2").append('<div class="tcdPageCode"></div>');
  120. myDemandList(true, 1, 5, yesNo, oSortType);
  121. } else if($(this).text() == "按最早发布时间排序") {
  122. oSortType = 1;
  123. $(".tcdPageCode").remove();
  124. $("#workContainer2").append('<div class="tcdPageCode"></div>');
  125. myDemandList(true, 1, 5, yesNo, oSortType);
  126. } else if($(this).text() == "按最新发布时间排序") {
  127. oSortType = 0;
  128. $(".tcdPageCode").remove();
  129. $("#workContainer2").append('<div class="tcdPageCode"></div>');
  130. myDemandList(true, 1, 5, yesNo, oSortType);
  131. }
  132. return false;
  133. });
  134. $("body").click(function(e) {
  135. if($(".option4")[0].style.display == "block" || $(".option1")[0].style.display == "block") {
  136. $(".option4")[0].style.display = "none";
  137. $(".option1")[0].style.display = "none";
  138. }
  139. });
  140. return false;
  141. })
  142. }
  143. selcet(1);
  144. selcet(4);
  145. $("#myNeed").on("click", ".replybtn", function() {
  146. var de = $(this).attr("demanid");
  147. location.href = "needShow.html?demandId=" + de
  148. });
  149. /*发布新需求*/
  150. $("#needIssueBtn").click(function() {
  151. $.ajax({
  152. url: "/ajax/professor/baseInfo/" + userid,
  153. type: "GET",
  154. timeout: 10000,
  155. dataType: "json",
  156. success: function(data) {
  157. if(data.success) {
  158. console.log(data);
  159. var $rta = data.data;
  160. orgId = $rta.orgId
  161. console.log(orgId)
  162. $("#induSub").val("");
  163. $("textarea").val("");
  164. $("#demandContent").val("");
  165. $("#navsub").find("li").removeClass("aimedLi");
  166. $("#mutChecked").find("li").removeClass("checkedLi");
  167. $('.checkNow').removeClass('checkNow');
  168. if($rta.authStatus != 3) {
  169. if($rta.orgAuth == 1) {
  170. $(".blackcover ").show();
  171. $("body").css("position","fixed");
  172. $("span:contains('企业需求')").addClass("checkNow");
  173. $("span:contains('个人需求')").addClass("checkNo");
  174. demandType = 2;
  175. } else {
  176. location.href = "realname-authentication.html";
  177. }
  178. } else {
  179. $(".blackcover ").show();
  180. $("body").css("position","fixed");
  181. if($rta.orgAuth == 0) {
  182. $("span:contains('企业需求')").addClass("checkNo");
  183. $("span:contains('个人需求')").addClass("checkNow");
  184. demandType = 1;
  185. } else {
  186. demanTy();
  187. }
  188. }
  189. }
  190. },
  191. error: function(XMLHttpRequest, textStats, errorThrown) {
  192. }
  193. })
  194. });
  195. $("#workclose2").click(function() {
  196. $(".blackcover ").hide();
  197. $("body").css("position","relative");
  198. })
  199. /*发布新需求目的*/
  200. var consun;
  201. tab("navsub"); //身份切换
  202. function tab(name) {
  203. var oDome = document.getElementById(name);
  204. var oSpan = oDome.getElementsByTagName('ul')[0].childNodes;
  205. for(var i = 0; i < oSpan.length; i++) {
  206. oSpan[i].onclick = function() {
  207. for(var i = 0; i < oSpan.length; i++) {
  208. oSpan[i].className = '';
  209. }
  210. this.className = 'aimedLi';
  211. if(this.getElementsByTagName("span")[0].innerText == "咨询技术难题") {
  212. consun = 1;
  213. } else if(this.getElementsByTagName("span")[0].innerText == "寻求研发资源") {
  214. consun = 2;
  215. } else {
  216. consun = 3;
  217. }
  218. }
  219. }
  220. }
  221. /*切换需求类型*/
  222. function demanTy() {
  223. var deTy = document.getElementsByClassName("boxnavTo")[0];
  224. var deTyChild = deTy.getElementsByTagName("span");
  225. if(deTyChild[0].className != "checkNo" && deTyChild[1].className != "checkNo") {
  226. for(var n = 0; n < deTyChild.length; n++) {
  227. (function(m) {
  228. deTyChild[m].onclick = function() {
  229. this.className = "checkNow";
  230. if(m == 0) {
  231. demandType = 1;
  232. deTyChild[1].className = "";
  233. } else if(m == 1) {
  234. demandType = 2;
  235. deTyChild[0].className = "";
  236. }
  237. }
  238. })(n);
  239. }
  240. }
  241. }
  242. /*需求题目限制30个字*/
  243. $("#demandContent").on('keyup', function() {
  244. if(this.value.length > 30) {
  245. this.value = this.value.substring(0, 30);
  246. }
  247. });
  248. /*需求内容限制300个字*/
  249. $("textarea").on('keyup', function() {
  250. var maxChars = 300;
  251. if(this.value.length > maxChars) {
  252. this.value = this.value.substring(0, maxChars);
  253. }
  254. var oCanInput = maxChars - this.value.length;
  255. $("#countNum").text(oCanInput);
  256. });
  257. /*查询应用行业及学术领域*/
  258. function industry(insu) {
  259. $.ajax({
  260. url: "/ajax/dataDict/qaDictCode",
  261. dataType: 'json', //数据格式类型
  262. type: 'GET', //http请求类型
  263. timeout: 10000, //超时设置
  264. data: {
  265. "dictCode": insu
  266. },
  267. success: function(data) {
  268. if(data.success) {
  269. var $data = data.data;
  270. var n;
  271. ($data.length > 5) ? n = 5:
  272. n = $data.length
  273. for(var i = 0; i < n; i++) {
  274. var oString = '<li><span>' + $data[i].caption + '</span></li>';
  275. $("#mutChecked").append(oString);
  276. }
  277. }
  278. },
  279. error: function() {
  280. return;
  281. }
  282. });
  283. }
  284. industry("INDUSTRY");
  285. industry("SUBJECT");
  286. /*行业及领域选择*/
  287. $('#mutChecked').on('click', 'li', function() {
  288. if(this.className == "checkedLi") {
  289. this.className = ""
  290. } else {
  291. this.className = "checkedLi"
  292. }
  293. })
  294. /*行业或者领域添加及删除*/
  295. $("#labelshow").on("click", ".removeNu", function() {
  296. $(this).parent().remove();
  297. });
  298. $("#addIndu").click(function() {
  299. var oinduSub = $("#induSub").val();
  300. var oAddNum = $("#labelshow").find("em");
  301. if(!oinduSub.trim()) {
  302. $.MsgBox.Alert("消息", "请先添加内容");
  303. return;
  304. }
  305. if(oinduSub.trim().length > 10) {
  306. $.MsgBox.Alert("消息", "不能多于10个字");
  307. return;
  308. }
  309. if(oAddNum.length == 5) {
  310. $.MsgBox.Alert("消息", "最多添加五条");
  311. return;
  312. }
  313. for(var i = 0; i < oAddNum.length; i++) {
  314. if(oAddNum[i].innerHTML == oinduSub) {
  315. $.MsgBox.Alert("消息", "不能重复添加");
  316. return;
  317. }
  318. }
  319. $("#labelshow").append('<li class="deleteSubject"><em>' + oinduSub + '</em><span class="removeNu"><img src="images/move.png"></span></li>')
  320. $("#induSub").val("");
  321. })
  322. /*发布新需求*/
  323. $("#postDemand").click(function() {
  324. var dd = $("#navsub").find(".aimedLi");
  325. var cc = $("#navsubTo").find(".checkNow");
  326. if(dd.length == 0) {
  327. $.MsgBox.Alert("消息", "请选择您发布需求的目的");
  328. return;
  329. }
  330. if(cc.length == 0) {
  331. $.MsgBox.Alert("消息", "请选择您的需求类型");
  332. return;
  333. }
  334. if(!$("#demandContent").val().trim()) {
  335. $.MsgBox.Alert("消息", "请填写需求主题");
  336. return;
  337. }
  338. if(!$("textarea").val().trim()) {
  339. $.MsgBox.Alert("消息", "请填写需求内容");
  340. return;
  341. }
  342. publish()
  343. });
  344. function publish() {
  345. var arr = [];
  346. var oSuin = $(".checkedLi");
  347. var oin = $("#labelshow").find("li");
  348. for(var i = 0; i < oSuin.length; i++) {
  349. arr[i] = oSuin[i].innerText;
  350. }
  351. for(var j = 0; j < oin.length; j++, i++) {
  352. //console.log(oin[j].innerText);
  353. arr[i] = oin[j].innerText;
  354. }
  355. $.ajax({
  356. url: '/ajax/demand',
  357. dataType: 'json', //数据格式类型
  358. type: 'post', //http请求类型
  359. timeout: 10000, //超时设置
  360. traditional: true,
  361. data: {
  362. "demander": userid,
  363. "demandAim": consun,
  364. "demandType": demandType,
  365. "demandTitle": $("#demandContent").val(),
  366. "demandContent": $("textarea").val(),
  367. "args": arr,
  368. "orgId": (demandType == 2) ? orgId : "",
  369. },
  370. success: function(data) {
  371. if(data.success) {
  372. myDemandList(true, 1, 5, yesNo, oSortType);
  373. $(".blackcover ").hide();
  374. $("body").css("position","relative");
  375. $.MsgBox.Alert("消息", "需求发布成功!很快会有专家与您联系,您可以在咨询列表中查看专家回复的信息");
  376. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  377. }
  378. },
  379. error: function() {
  380. return;
  381. }
  382. });
  383. }
  384. /*判断是否是专家*/
  385. $.ajax({
  386. url: "/ajax/professor/auth",
  387. type: "GET",
  388. timeout: 10000,
  389. dataType: "json",
  390. data: {
  391. "id": userid,
  392. },
  393. success: function(data, textState) {
  394. if(data.success) {
  395. var $rta = data.data;
  396. if($rta.authType == 0) {
  397. $("#searchDemand").hide();
  398. }
  399. }
  400. },
  401. error: function(XMLHttpRequest, textStats, errorThrown) {
  402. }
  403. })
  404. })