portal html css js resource

myDemand.js 13KB

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