portal html css js resource

myDemand.js 11KB

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