portal html css js resource

search.js 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. $(function() {
  2. loginStatus();//判断个人是否登录
  3. $(document).scroll(function() {
  4. var top = $(document).scrollTop();
  5. if(top != 0) {
  6. $(".searchbox").fadeIn(1000);
  7. } else {
  8. $(".searchbox").fadeOut(1000);
  9. }
  10. });
  11. var newc = GetQueryString("lookFor");
  12. if(newc == 0 || newc == "") {
  13. var c = 0;
  14. } else {
  15. var c = 1;
  16. // $(".lookwho option[value='1']").attr("selected","selected");
  17. $("#div_select").text("找资源");
  18. }
  19. /*
  20. * var lookFor2 = 0; $("#lookFor2 ul li").on("click",function(){
  21. * lookFor2=$(this).index(); }); //enter绑定时间
  22. * $("#searchContent").keydown(function(e){ if(e.which==13) { synContent(2);
  23. * synContent(1); var searchContent = $("#searchContent").val(); if(lookFor2 =
  24. * 1){ $("#div_select").text("找资源"); location.href =
  25. * "search.html?searchContent=" + encodeURI(searchContent); } }
  26. * })
  27. */
  28. var userid = $.cookie("userid");
  29. var subject;
  30. var subb = $.trim(GetQueryString("subject"));
  31. var industry;
  32. var pageSize;
  33. var sub = "SUBJECT";
  34. var indu = "INDUSTRY";
  35. var address = $("#address .colorbg")[0].title;
  36. $("#searchContent").val(GetQueryString("searchContent"));
  37. $("#hsearchContent").val(GetQueryString("searchContent"));
  38. var key = $("#searchContent").val();
  39. var getData = function(key, subject, industry, pageSize, pageNo, isbind,
  40. add) {
  41. if(c == 0) {
  42. $
  43. .ajax({
  44. "url": "/ajax/professor/pqBaseInfo",
  45. "type": "GET",
  46. "data": {
  47. "key": key,
  48. "subject": subject,
  49. "industry": industry,
  50. "pageSize": pageSize,
  51. "pageNo": pageNo,
  52. "address": add
  53. },
  54. "contentType": "application/x-www-form-urlencoded",
  55. "success": function($data) {
  56. if($data.success) {
  57. // console.log($data);
  58. $("#professorList").html("");
  59. for(var i = 0; i < $data.data.data.length; i++) {
  60. // 创建HTML标签
  61. var dataHtml = "<div class='item'>";
  62. dataHtml += "<a class='infoi' href='information-brow.html?professorId=" +
  63. $data.data.data[i].id +
  64. "' ><div class='photo1 userRadius'>"
  65. if($data.data.data[i].hasHeadImage) {
  66. dataHtml += "<img class='images' style='width:100%;' src='/images/head/" +
  67. $data.data.data[i].id +
  68. "_l.jpg'/></div></a>";
  69. } else {
  70. dataHtml += "<img class='images' style='width:100%;' src='/images/default-photo.jpg'/></div></a>";
  71. }
  72. dataHtml += "<div class='synopsis'>";
  73. dataHtml += "<a href='javascript:void();' class='named'>";
  74. if(typeof($data.data.data[i].name) !== "undefined") {
  75. dataHtml += $data.data.data[i].name;
  76. }
  77. dataHtml += "</a><a href='information-brow.html?professorId=" +
  78. $data.data.data[i].id +
  79. "' class='authiconNew'></a>";
  80. dataHtml += "<div class='position'>";
  81. if($data.data.data[i].office) {
  82. dataHtml += $data.data.data[i].office +
  83. ", ";
  84. }
  85. if($data.data.data[i].title) {
  86. dataHtml += $data.data.data[i].title +
  87. ", ";
  88. }
  89. if($data.data.data[i].department) {
  90. dataHtml += $data.data.data[i].department +
  91. ", ";
  92. }
  93. if($data.data.data[i].orgName) {
  94. dataHtml += $data.data.data[i].orgName;
  95. }
  96. if($data.data.data[i].address) {
  97. dataHtml += " | " +
  98. $data.data.data[i].address;
  99. }
  100. dataHtml += "</div>";
  101. dataHtml += "<div class='ellipsisbox science'>";
  102. if(typeof($data.data.data[i].subject) !== "undefined") {
  103. dataHtml += "<p>学术领域:" +
  104. $data.data.data[i].subject +
  105. "</p>";
  106. }
  107. dataHtml += "</div>";
  108. dataHtml += "<div class='ellipsisbox industry'>";
  109. if(typeof($data.data.data[i].industry) !== "undefined") {
  110. dataHtml += "<p>应用行业:" +
  111. $data.data.data[i].industry +
  112. "</p>";
  113. }
  114. if($data.data.data[i].researchAreas.length) {
  115. dataHtml += "<p>研究方向:"
  116. for(var m = 0; m < $data.data.data[i].researchAreas.length; m++) {
  117. dataHtml += $data.data.data[i].researchAreas[m].caption;
  118. if(m<$data.data.data[i].researchAreas.length-1){
  119. dataHtml += " , "
  120. }
  121. }
  122. dataHtml += "</p>";
  123. }
  124. dataHtml += "</div>";
  125. dataHtml += "</div>";
  126. if($data.data.data[i].id != userid) {
  127. dataHtml += "<div class='operbox'><span class='operbtn onlyConsultbtn' id='" +
  128. $data.data.data[i]['id'] +
  129. "'>咨询</span></div>";
  130. }
  131. var $datahtml = $(dataHtml);
  132. $("#professorList").append(dataHtml);
  133. var photoHeight = $(".photo1").eq(i).height();
  134. var middleHeight = $(".synopsis").eq(i).height();
  135. if(middleHeight < photoHeight) {
  136. $(".synopsis").eq(i).height(photoHeight);
  137. }
  138. //认证
  139. var oSty=autho($data.data.data[i].authType,$data.data.data[i].orgAuth,$data.data.data[i].authStatus);
  140. $(".authiconNew").eq(i).addClass(oSty.sty);
  141. $(".authiconNew").eq(i).attr("title",oSty.title);
  142. // 点击查看当前信息
  143. (function(i) {
  144. $('.synopsis')
  145. .eq(i)
  146. .click(
  147. function() {
  148. location.href = 'information-brow.html?professorId=' +
  149. $data.data.data[i].id;
  150. })
  151. }
  152. )(i);
  153. }
  154. //找专家点击咨询
  155. $(".onlyConsultbtn").bind("click", clickSeachProConsultHandler);
  156. if(isbind == true) {
  157. $(".tcdPageCode").createPage({
  158. pageCount: Math.ceil($data.data.total / pageSize),
  159. current: $data.data.pageNo,
  160. backFn: function(p) {
  161. getData(key, subject, industry, pageSize, p, false);
  162. }
  163. });
  164. }
  165. } else {
  166. $.MsgBox.Alert("message", $data.msg);
  167. }
  168. }
  169. });
  170. } else {
  171. //查询我的所有资源
  172. $.ajax({
  173. "url": "/ajax/resource/pq",
  174. "type": "get",
  175. "data": {
  176. "key": key,
  177. "subject": subject,
  178. "industry": industry,
  179. "pageSize": pageSize,
  180. "pageNo": pageNo,
  181. "address": add
  182. },
  183. "contentType": "application/x-www-form-urlencoded",
  184. "success": function(data) {
  185. //console.log(data);
  186. if(data.success) {
  187. $("#professorList").html("");
  188. var $da = data.data.data;
  189. for(var i = 0; i < $da.length; i++) {
  190. var add = '<div class="item"><div class="remess" resourceId=' + $da[i].resourceId + '>'
  191. add += '<div class="clearfix"><a class="resourcephoto headRadius" ><div class="ResImgBox" style="background:#ffffff;"><img class="resImg headRadius resourceImg" src="" /></div></a>'
  192. add += '<div class="synopsis" style="width:66%;">'
  193. add += '<div class="cousultName"><a class="resouname" href="javascript:void();">' + $da[i].resourceName + '</a></div>'
  194. var oStyT=autho($da[i].editProfessor.authType,$da[i].editProfessor.orgAuth,$da[i].editProfessor.authStatus);
  195. if($da[i].editProfessor.name) {
  196. add += '<div class="belongname"><a style="float:left;display:block;">' + $da[i].editProfessor.name + '</a><a class="authiconNew '+ oStyT.sty+'" title="'+ oStyT.title +'"></a></div>'
  197. }
  198. if($da[i].editProfessor.title == undefined) {
  199. $da[i].editProfessor.title = "";
  200. }
  201. if($da[i].editProfessor.department == undefined) {
  202. $da[i].editProfessor.department = "";
  203. }
  204. if($da[i].editProfessor.orgName == undefined) {
  205. $da[i].editProfessor.orgName = "";
  206. }
  207. add += '<div style="clear:both"></div><div class="positionbox">'
  208. if($da[i].editProfessor.title && $da[i].editProfessor.department && $da[i].editProfessor.orgName) {
  209. add += $da[i].editProfessor.title + "," + $da[i].editProfessor.department + "," + $da[i].editProfessor.orgName;
  210. } else if(!$da[i].editProfessor.title && $da[i].editProfessor.department && $da[i].editProfessor.orgName) {
  211. add += $da[i].editProfessor.department + "," + $da[i].editProfessor.orgName;
  212. } else if($da[i].editProfessor.title && !$da[i].editProfessor.department && $da[i].editProfessor.orgName) {
  213. add += $da[i].editProfessor.title + "," + $da[i].editProfessor.orgName;
  214. } else if($da[i].editProfessor.title && $da[i].editProfessor.department && !$da[i].editProfessor.orgName) {
  215. add += $da[i].editProfessor.title + "," + $da[i].editProfessor.department;
  216. } else if(!$da[i].editProfessor.title && !$da[i].editProfessor.department && $da[i].editProfessor.orgName) {
  217. add += $da[i].editProfessor.orgName
  218. } else if(!$da[i].editProfessor.title && $da[i].editProfessor.department && !$da[i].editProfessor.orgName) {
  219. add += $da[i].editProfessor.department
  220. } else if($da[i].editProfessor.title && !$da[i].editProfessor.department && !$da[i].editProfessor.orgName) {
  221. add += $da[i].editProfessor.title
  222. }
  223. add += '</div>'
  224. if($da[i].subject) {
  225. add += '<div class="ellipsisbox sciencebox"><p>学术领域:' + $da[i].subject + '</p></div>'
  226. }
  227. if($da[i].industry) {
  228. add += '<div class="ellipsisbox industrybox"><p>应用行业:' + $da[i].industry + '</p></div>'
  229. }
  230. if($da[i].supportedServices) {
  231. add += '<div class="ellipsisbox provideservice"><p>应用用途:' + $da[i].supportedServices + '</p></div></div>'
  232. }
  233. add += "</div>"
  234. if(userid == $da[i]["editProfessor"]["id"]) {
  235. add += '<div class="operbox"><span class="operbtn consultbtn" id="' + $da[i]["editProfessor"]["id"] + '" style="display:none;">咨询</span><span style="display: none;" class="operbtn applybtn appl" resourceId=' + $da[i].resourceId + ' resourceName=' + $da[i].resourceName + ' editProfessor=' + $da[i].editProfessor.name + '>申请</span></div>'
  236. } else {
  237. add += '<div class="operbox"><span class="operbtn consultbtn" id="' + $da[i]["editProfessor"]["id"] + '">咨询</span><span style="display: none;" class="operbtn applybtn appl" resourceId=' + $da[i].resourceId + ' resourceName=' + $da[i].resourceName + ' editProfessor=' + $da[i].editProfessor.name + '>申请</span></div>'
  238. }
  239. add += '</div></div>'
  240. var $add = $(add);
  241. $("#professorList").append($add);
  242. if(data.data.data[i].images.length) {
  243. $add.find(".resourceImg").attr("src", "/images/resource/" + $da[i].resourceId + ".jpg");
  244. } else {
  245. $add.find(".resourceImg").attr("src", "/images/default-resource.jpg");
  246. }
  247. }
  248. if(isbind == true) {
  249. $(".tcdPageCode").createPage({
  250. pageCount: Math.ceil(data.data.total / pageSize),
  251. current: data.data.pageNo,
  252. backFn: function(p) {
  253. getData(key, subject, industry, pageSize, p, false);
  254. }
  255. });
  256. }
  257. } else {
  258. $.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
  259. $("#mb_btn_ok").val("去登录");
  260. }
  261. //资源中点击咨询
  262. //$(".consultbtn").bind("click",clickResouceConsultHandler);
  263. },
  264. });
  265. }
  266. }
  267. $(".about").on("click", '.consultbtn', function(e) {
  268. e.stopPropagation(); //阻止事件冒泡,影响点击咨询
  269. e.cancelBubble = true; // ie下阻止冒泡
  270. clickResouceConsultHandler($(this), $(this).attr('id'));
  271. });
  272. var subjectList = function() {
  273. $.get("../ajax/dataDict/qaDictCode", {
  274. dictCode: "SUBJECT"
  275. }, function(data) {
  276. if(data.success) {
  277. //console.log(data);
  278. /*if (data.data.length <= 10) {
  279. $(".andmore").eq(0).hide();
  280. }*/
  281. $("#subject").find(".sub").remove();
  282. for(var i = 0; i < data.data.length; i++) {
  283. $("#subject").append(
  284. "<a href='#' class='sub'title='" +
  285. data.data[i].caption + "'>" +
  286. data.data[i].caption + "</a>");
  287. if(subb) {
  288. if(subb == data.data[i].caption) {
  289. $('.sub').eq(i).addClass('colorbg').siblings()
  290. .removeClass("colorbg");
  291. }
  292. }
  293. if(i > 20)
  294. break;
  295. }
  296. } else {
  297. $.MsgBox.Alert("message", data.msg);
  298. }
  299. })
  300. }
  301. var Address = function() {
  302. $.get("../ajax/dataDict/qaCity", {
  303. dictCode: "ADDRESS"
  304. }, function(data) {
  305. if(data.success) {
  306. $("#address").empty();
  307. $("#address").prepend('<a href="#" class="colorbg no3" title="">不限</a>');
  308. /*if (data.data.length <= 10) {
  309. $(".andmore").eq(2).hide();
  310. }*/
  311. for(var i = 0; i < data.data.length; i++) {
  312. $("#address").append(
  313. "<a href='#' title='" + data.data[i].caption + "'>" +
  314. data.data[i].caption + "</a>");
  315. if(i > 20)
  316. break;
  317. }
  318. } else {
  319. $.MsgBox.Alert("message", data.msg);
  320. }
  321. })
  322. }
  323. var industryList = function() {
  324. $.get("../ajax/dataDict/qaDictCode", {
  325. dictCode: "INDUSTRY"
  326. }, function(data) {
  327. //console.log(data);
  328. if(data.success) {
  329. /*if (data.data.length <= 10) {
  330. $(".andmore").eq(1).hide();
  331. }*/
  332. $("#industry").find(".indu").remove();
  333. for(var i = 0; i < data.data.length; i++) {
  334. $("#industry").append(
  335. "<a href='#' class='indu'title='" +
  336. data.data[i].caption + "'>" +
  337. data.data[i].caption + "</a>");
  338. if(i > 20)
  339. break;
  340. }
  341. } else {
  342. $.MsgBox.Alert("message", data.msg);
  343. }
  344. })
  345. }
  346. var findProfessor = function() {
  347. if(subb) {
  348. subject = subb;
  349. } else {
  350. subject = $("#subject .colorbg")[0].title;
  351. }
  352. industry = $("#industry .colorbg")[0].title;
  353. pageSize = 10;
  354. getData(key, subject, industry, pageSize, 1, true, address);
  355. }
  356. //搜索框跳转页面 enter键搜索
  357. $("#searchContent").keydown(function(e) {
  358. if(e.which == 13) {
  359. synContent(2);
  360. key = $("#searchContent").val();
  361. $("#professorList").remove();
  362. $(".aboutpro").append(
  363. '<div class="about-in" id="professorList"></div>')
  364. $(".tcdPageCode").remove();
  365. $(".aboutpro").append('<div class="tcdPageCode"></div>');
  366. getData(key, subject, industry, 10, 1, true, address);
  367. }
  368. })
  369. $("#hsearchContent").keydown(function(e) {
  370. if(e.which == 13) {
  371. synContent(1);
  372. key = $("#searchContent").val();
  373. $("#professorList").remove();
  374. $(".aboutpro").append(
  375. '<div class="about-in" id="professorList"></div>')
  376. $(".tcdPageCode").remove();
  377. $(".aboutpro").append('<div class="tcdPageCode"></div>');
  378. getData(key, subject, industry, 10, 1, true, address);
  379. }
  380. })
  381. $("#search1").on(
  382. "click",
  383. function() {
  384. $("#hsearchContent").val($("#searchContent").val());
  385. key = $("#searchContent").val();
  386. $("#professorList").remove();
  387. $(".aboutpro").append(
  388. '<div class="about-in" id="professorList"></div>')
  389. $(".tcdPageCode").remove();
  390. $(".aboutpro").append('<div class="tcdPageCode"></div>');
  391. getData(key, subject, industry, 10, 1, true, address);
  392. })
  393. // $("#hsearch1")
  394. $("#hsearch").on(
  395. "click",
  396. function() {
  397. $("#searchContent").val($("#hsearchContent").val());
  398. key = $("#hsearchContent").val();
  399. location.href = "javascript:;";
  400. $("#professorList").remove();
  401. $(".aboutpro").append(
  402. '<div class="about-in" id="professorList"></div>')
  403. $(".tcdPageCode").remove();
  404. $(".aboutpro").append('<div class="tcdPageCode"></div>');
  405. getData(key, subject, industry, 10, 1, true, address);
  406. })
  407. subjectList();
  408. industryList();
  409. findProfessor();
  410. Address();
  411. $(".class1").eq(0).on(
  412. "click",
  413. "a",
  414. function() {
  415. $(this).addClass("colorbg").siblings().removeClass("colorbg");
  416. key = $("#searchContent").val();
  417. subject = $(this).attr('title');
  418. $("#professorList").remove();
  419. $(".aboutpro").append(
  420. '<div class="about-in" id="professorList"></div>')
  421. $(".tcdPageCode").remove();
  422. $(".aboutpro").append('<div class="tcdPageCode"></div>');
  423. getData(key, subject, industry, 10, 1, true, address);
  424. });
  425. $(".class1").eq(1).on(
  426. "click",
  427. "a",
  428. function() {
  429. $(this).addClass("colorbg").siblings().removeClass("colorbg");
  430. industry = $(this).attr('title');
  431. key = $("#searchContent").val();
  432. $("#professorList").remove();
  433. $(".aboutpro").append(
  434. '<div class="about-in" id="professorList"></div>')
  435. $(".tcdPageCode").remove();
  436. $(".aboutpro").append('<div class="tcdPageCode"></div>');
  437. getData(key, subject, industry, 10, 1, true, address);
  438. });
  439. $(".class1").eq(2).on(
  440. "click",
  441. "a",
  442. function() {
  443. $(this).addClass("colorbg").siblings().removeClass("colorbg");
  444. address = $(this).attr('title');
  445. key = $("#searchContent").val();
  446. $("#professorList").remove();
  447. $(".aboutpro").append(
  448. '<div class="about-in" id="professorList"></div>')
  449. $(".tcdPageCode").remove();
  450. $(".aboutpro").append('<div class="tcdPageCode"></div>');
  451. getData(key, subject, industry, 10, 1, true, address);
  452. });
  453. /* 搜索分类展开 */
  454. var listi = 0;
  455. $(".andmore").click(function() {
  456. $(this).find(".updown").css("background-position", "left");
  457. $(this).parent().css("height", "48px");
  458. if(listi % 2 == 0) {
  459. } else {
  460. $(this).find(".updown").css("background-position", "right");
  461. $(this).parent().css("height", "auto");
  462. }
  463. listi++;
  464. })
  465. /*搜索分类背景切换*/
  466. $(".class1").on("click", "a", function() {
  467. $(this).addClass("colorbg").siblings().removeClass("colorbg");
  468. })
  469. /*专家、资源菜单切换*/
  470. // $(".lookwho").change(function(){
  471. // //$(this).addClass("tabcurrent").siblings().removeClass("tabcurrent");
  472. // //$(".aboutcon").eq($(this).index()).show().siblings().hide();
  473. // if($(this).value == "0"){
  474. // $(".aboutpro").show();
  475. // $(".aboutresou").hide();
  476. // }
  477. // else{
  478. // $(".aboutresou").show();
  479. // $(".aboutpro").hide();
  480. // }
  481. //
  482. // })
  483. //判断是搜寻专家还是资源
  484. $(".lishow li").on(
  485. "click",
  486. function() {
  487. c = $(this).index();
  488. $("#industry").find(".no2").addClass("colorbg").siblings()
  489. .removeClass("colorbg");
  490. $("#subject").find(".nox").addClass("colorbg").siblings()
  491. .removeClass("colorbg");
  492. key = $("#searchContent").val();
  493. industry = "";
  494. subject = "";
  495. address = "";
  496. if(c == 0) {
  497. sub = "SUBJECT";
  498. indu = "INDUSTRY";
  499. } else {
  500. sub = "SUBJECT";
  501. indu = "INDUSTRY";
  502. }
  503. industryList();
  504. subjectList();
  505. Address();
  506. $("#professorList").remove();
  507. $(".aboutpro").append(
  508. '<div class="about-in" id="professorList"></div>')
  509. $(".tcdPageCode").remove();
  510. $(".aboutpro").append('<div class="tcdPageCode"></div>');
  511. getData(key, subject, industry, pageSize, 1, true, address);
  512. });
  513. // 查询资源详细信息
  514. $('.about')
  515. .on(
  516. "click",
  517. '.remess',
  518. function() {
  519. var resourceID = $(this).attr("resourceId");
  520. location.href = "resourceInfo.html?resourceId=" + resourceID;
  521. //ResourceMessage();
  522. // $
  523. // .ajax({
  524. // "url": "/ajax/resource/" + resourceID,
  525. // "type": "get",
  526. // "async": true,
  527. // "success": function(info) {
  528. // if(info.success) {
  529. // $("#resourceName").text(
  530. // info.data.resourceName);
  531. // $("#supportedServices")
  532. // .text(
  533. // info.data.supportedServices);
  534. // $("#hopePayMethod").text(
  535. // info.data.hopePayMethod);
  536. // $("#cooperationNotes").text(
  537. // info.data.cooperationNotes);
  538. // $("#subject").text(
  539. // info.data.subject);
  540. // $("#industry").text(
  541. // info.data.industry);
  542. // $("#descp").text(info.data.descp);
  543. // $("#professor").text(
  544. // info.data.professor.name);
  545. // $(".resouImage").attr(
  546. // "src",
  547. // "/images/resource/" +
  548. // resourceID +
  549. // ".jpg");
  550. // $(".resouImage")
  551. // .load(function() {})
  552. // .error(
  553. // function() {
  554. // $(this)
  555. // .attr(
  556. // "src",
  557. // "/images/default-resource.jpg");
  558. // });
  559. // limitHeight();
  560. // } else {
  561. // $.MsgBox.Alert('消息提醒', "系统异常!");
  562. // }
  563. // },
  564. // "error": function() {
  565. // $.MsgBox.Alert('message', 'failed')
  566. // }
  567. // });
  568. })
  569. // 资源申请
  570. function getIdentity(professorId) {
  571. $
  572. .ajax({
  573. "url": "ajax/professor/" + professorId,
  574. "type": "get",
  575. "async": false,
  576. "success": function(data) {
  577. if(data.success) {
  578. $(".frmtype option")[0].value = data.data.name;
  579. $(".frmtype option")[1].value = data.data.organization.name;
  580. } else {
  581. $.MsgBox.Alert("消息提醒", "系统异常!");
  582. }
  583. },
  584. "error": function() {
  585. $.MsgBox.Alert('message', 'failddd')
  586. }
  587. })
  588. }
  589. function replaceStr(s) {
  590. var pattern = new RegExp("-");
  591. var rs = "";
  592. for(var i = 0; i < s.length; i++) {
  593. rs = rs + s.substr(i, 1).replace(pattern, '');
  594. }
  595. return rs;
  596. }
  597. $('.aboutpro')
  598. .on(
  599. "click",
  600. '.appl',
  601. function() {
  602. ResourceApply(); // 调用资源申请HTML创建函数
  603. $(".limitBox").removeClass("limitBox");
  604. $(".limitwords").removeClass("limitwords");
  605. $(".limitwordbox").removeClass("limitwordbox");
  606. // 获取当前时间并且格式化时间
  607. var myDate = new Date();
  608. var nowYear = myDate.getFullYear();
  609. var nowMonth = myDate.getMonth() + 1;
  610. var nowDate = myDate.getDate();
  611. if(nowMonth < 10) {
  612. nowMonth = "0" + nowMonth.toString();
  613. }
  614. if(nowDate < 10) {
  615. nowDate = "0" + nowDate.toString();
  616. }
  617. var now = nowYear + "-" + nowMonth + "-" + nowDate;
  618. $("#datepicker").val(now);
  619. $("#datepicker").datepicker({
  620. "dateFormat": " yy-mm-dd"
  621. });
  622. $(".timelo").css("display", "none");
  623. var resName = $(this).attr("resourcename");
  624. var name = $(this).attr("professor");
  625. var resourceID = $(this).attr("resourceId");
  626. $
  627. .ajax({
  628. "url": "/ajax/resource/" + resourceID,
  629. "type": "get",
  630. "async": false,
  631. "success": function(info) {
  632. if(info.success) {
  633. if(info.data.images.length) {
  634. $(".resouImage").attr(
  635. "src",
  636. "/images/resource/" +
  637. resourceID +
  638. ".jpg");
  639. } else {
  640. $(".resouImage")
  641. .attr("src",
  642. "/images/default-resource.jpg");
  643. }
  644. }
  645. }
  646. })
  647. $(".namecon").text(name);
  648. $(".applysure").hide();
  649. $(".btnboxup").hide();
  650. $(".log").text(resName);
  651. getIdentity(userid);
  652. $("#deliver")
  653. .on(
  654. "click",
  655. function() {
  656. var $data = {};
  657. $data.demandId = userid;
  658. $data.resourceId = resourceID;
  659. $data.detailDemand = $(".detail")
  660. .val();
  661. // 去除时间里面的- 和字符串前后的空格
  662. $data.deliverTime = replaceStr($
  663. .trim($(".dealTime").val()));
  664. $data.operationStatus = 1;
  665. $data.applysquare = $(
  666. ".frmtype option:selected")
  667. .val();
  668. $
  669. .ajax({
  670. "url": "/ajax/operation",
  671. "type": "POST",
  672. "success": function(
  673. rdata) {
  674. if(rdata.success) {
  675. $.MsgBox
  676. .Alert(
  677. '消息提醒',
  678. '资源"' +
  679. resName +
  680. '"申请发送成功!');
  681. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  682. $(".blackcover")
  683. .remove();
  684. $("body")
  685. .css(
  686. "position",
  687. "");
  688. // location.reload(true);
  689. } else {
  690. $.MsgBox
  691. .Alert(
  692. '消息提醒',
  693. '资源"' +
  694. resName +
  695. '"申请发送失败,请重新申请!');
  696. }
  697. },
  698. "data": $data,
  699. "beforeSend": function() { /* console.log(this.data) */ },
  700. "contentType": "application/x-www-form-urlencoded",
  701. dataType: "json"
  702. });
  703. });
  704. });
  705. // 找专家中 点击咨询处理函数
  706. function clickSeachProConsultHandler() {
  707. if(userid != null && userid != 'null' && userid != undefined && userid != 'undefined') {
  708. var professorId = $(this).attr("id");
  709. ConsultApply();
  710. //点击的发送
  711. $("#sendConsultBtn").click(function() {
  712. sendConsultHandler($(this).attr("proId"))
  713. });
  714. concultProInfo(professorId);
  715. } else {
  716. $.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
  717. $("#mb_btn_ok").val("去登录");
  718. var aele = document.createElement('a');
  719. $("#mb_btnbox").append(aele);
  720. $("#mb_btnbox a").css({
  721. 'display': "block",
  722. 'width': '100%',
  723. 'height': '40px',
  724. 'position': 'absolute',
  725. 'bottom': '-6px',
  726. 'left': '0'
  727. });
  728. aele.setAttribute('href', '../login.html');
  729. }
  730. };
  731. //找资源中 点击咨询 obj点击对象
  732. function clickResouceConsultHandler(obj, professorId) {
  733. if(userid && userid != null && userid != 'null' && userid != undefined && userid != 'undefined') {
  734. // var professorId = $(this).attr("id");
  735. ConsultApply();
  736. //默认选中资源咨询和标题
  737. for(var i = 0; i < $("ul.menucon").children().length; i++) {
  738. $("ul.menucon").children().eq(i).removeClass("clicknow");
  739. $("ul.menucon").children().eq(1).addClass("clicknow");
  740. }
  741. var item = obj.parent().parent().parent();
  742. var consultTitleVal = item.find(".resouname").text();
  743. $("#consultTitle").val("关于" + consultTitleVal + "的咨询");
  744. //点击的发送
  745. $("#sendConsultBtn").click(function() {
  746. sendConsultHandler($(this).attr("proId")); //common.js中
  747. });
  748. concultProInfo(professorId); //common.js中
  749. } else {
  750. $.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
  751. $("#mb_btn_ok").val("去登录");
  752. var aele = document.createElement('a');
  753. $("#mb_btnbox").append(aele);
  754. $("#mb_btnbox a").css({
  755. 'display': "block",
  756. 'width': '100%',
  757. 'height': '40px',
  758. 'position': 'absolute',
  759. 'bottom': '-6px',
  760. 'left': '0'
  761. });
  762. aele.setAttribute('href', '../login.html');
  763. }
  764. };
  765. /* function sendConsultHandler(){
  766. var professorId = $(this).attr("proId");
  767. var consult_type = $(".clicknow").text();//咨询类型
  768. var consult_title = $("#consultTitle").val();//咨询主题
  769. var consult_content = $("#consultcontent").val();//咨询内容
  770. var consultStr = {
  771. "consultType":consult_type,
  772. "consultTitle":consult_title,
  773. "consultContant":consult_content,
  774. "professorId":professorId,
  775. "consultantId":userid
  776. };
  777. if(consult_type == '' || consult_title == '' || consult_content == ''){
  778. $.MsgBox.Alert("message","请填写完整");
  779. };
  780. if(consult_type == ''){
  781. $.MsgBox.Alert("消息","请选择联系目的");
  782. }
  783. if(consult_title == ''){
  784. $.MsgBox.Alert("消息","请填写咨询目的");
  785. }
  786. if(consult_content == ''){
  787. $.MsgBox.Alert("消息","请填写咨询内容");
  788. }
  789. if(userid && userid != null && userid != "null" && consult_type != '' &&
  790. consult_title != '' && consult_content != ''
  791. ){
  792. $.ajax({
  793. "url" :"/ajax/consult",
  794. "type" : "post",
  795. //传值:咨询类型、主题、内容、专家id、申请人id
  796. "data" : consultStr,
  797. "contentType" : "application/x-www-form-urlencoded",
  798. "dataType" : "json",
  799. "success" : function(response) {
  800. consultId = response.data;//咨询id
  801. },
  802. "error":function (){
  803. $.MsgBox.Alert("消息","咨询申请失败");
  804. },
  805. "complete":function(){
  806. //$(".consultapply").remove();
  807. $(".blackcover").remove();
  808. $("body").css("position","");
  809. $.MsgBox.Alert("消息","咨询申请成功");
  810. },
  811. });
  812. }
  813. }*/
  814. });