portal html css js resource

myDemand.js 12KB

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