portal html css js resource

myDemand.js 13KB

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