portal html css js resource

myDemand.js 13KB

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