portal html css js resource

common.js 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. $(document).ready(function() {
  2. $(".unlogin").show();
  3. $(".onlogin").hide();
  4. var footerHeight = $("footer").outerHeight(true);
  5. $('#container').css("padding-bottom", footerHeight + "px");
  6. //窗口大小变更事件
  7. $(window).resize(function() {
  8. footerHeight = $("footer").outerHeight(true);
  9. $('#container').css("padding-bottom", footerHeight + "px");
  10. //console.log(footerHeight)
  11. });
  12. //底部企业入驻
  13. var orgid = $.cookie('orgId');
  14. $("#cmpSet2").on("click", function() {
  15. if(orgid && orgid != "null" && orgid != null) {
  16. location.href = "cmp-portal/cmp-workspaces.html"
  17. } else {
  18. location.href = "cmp-portal/cmp-settled-reg.html"
  19. }
  20. })
  21. });
  22. //搜索框跳转页面
  23. $("#search").on("click", function() {
  24. var searchContent = $("#searchContent").val();
  25. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  26. });
  27. //enter绑定时间
  28. $("#searchContent").keydown(function(e) {
  29. if(e.which == 13) {
  30. var searchContent = $("#searchContent").val();
  31. console.log(searchContent);
  32. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  33. }
  34. })
  35. $("#hsearchContent").keydown(function(e) {
  36. if(e.which == 13) {
  37. var searchContent = $("#hsearchContent").val();
  38. console.log(searchContent);
  39. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  40. }
  41. })
  42. $("#hsearch").on("click", function() {
  43. var searchContent = $("#hsearchContent").val();
  44. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  45. });
  46. /*向下滚动时,header背景变半透明*/
  47. $(document).scroll(function() {
  48. var top = $(document).scrollTop();
  49. if(top == 0) {
  50. $(".navheader").removeClass("navhdown");
  51. } else {
  52. $(".navheader").addClass("navhdown");
  53. }
  54. if(top >= 300) {
  55. $(".content-left").css({
  56. "position": "fixed",
  57. "top": "80px"
  58. })
  59. } else {
  60. $(".content-left").css({
  61. "position": "static"
  62. })
  63. }
  64. });
  65. var userid;
  66. function exit() {
  67. $.cookie('userid', null);
  68. $.cookie('userAuth', null);
  69. $.cookie('userEmail', null);
  70. $.cookie('userMobilePhone', null);
  71. $.cookie('userName', null);
  72. $.cookie('userType', null);
  73. location.href = "index.html"
  74. }
  75. function valUser() {
  76. var userid = $.cookie('userid');
  77. var userAuth = $.cookie('userAuth');
  78. if(userid == undefined || userid.length == 0 || userid == "null" || userAuth == false) {
  79. location.href = "login.html";
  80. }
  81. }
  82. function GetQueryString(name) {
  83. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  84. var r = window.location.search.substr(1).match(reg);
  85. var context = "";
  86. if(r != null)
  87. context = r[2];
  88. reg = null;
  89. r = null;
  90. return context == null || context == "" || context == "undefined" ? "" : decodeURI(context);
  91. }
  92. /* function GetQueryString(name) {
  93. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  94. var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ��
  95. var context = "";
  96. if (r != null)
  97. context = r[2];
  98. reg = null;
  99. r = null;
  100. return context == null || context == "" || context == "undefined" ? "" : context;
  101. }*/
  102. function loginStatus() {
  103. userid = $.cookie('userid');
  104. userAuth = $.cookie('userAuth');
  105. authentication = $.cookie('authentication');
  106. if(userid && userid != "null" && userid != null) {
  107. if(userAuth == "false" && authentication == "null") {
  108. location.href = "loginInviteFirst.html";
  109. }
  110. if(userAuth == "true" && authentication == "null") {
  111. location.href = "fillinfo-select.html";
  112. }
  113. if(userAuth == "true" && authentication != "null") {
  114. $(".onlogin").show();
  115. $(".unlogin").hide();
  116. $(".portrait-p").attr("src", "/images/head/" + userid + "_m.jpg");
  117. $(".portrait-p").load(function() { //判断图片是否加载,加载不成功默认有默认的图像
  118. })
  119. .error(function() {
  120. $(".portrait-p").attr("src", "/images/default-photo.jpg");
  121. });
  122. }
  123. } else {
  124. $(".unlogin").show();
  125. $(".onlogin").hide();
  126. }
  127. }
  128. //转换格式
  129. function changeTime(dealtime) {
  130. var s = dealtime;
  131. //console.log(s);
  132. if(dealtime.length == 8) {
  133. var y = s.substr(0, 4);
  134. var m = s.substr(4, 2);
  135. var d = s.substr(6, 2);
  136. var formatTime = y + "-" + m + "-" + d;
  137. return formatTime;
  138. } else {
  139. var y = s.substr(0, 4);
  140. var m = s.substr(4, 2);
  141. var d = s.substr(6, 2);
  142. var h = s.substr(8, 2);
  143. var minute = s.substr(10, 2);
  144. var formatTime = y + "-" + m + "-" + d + " " + h + ":" + minute;
  145. return formatTime;
  146. }
  147. }
  148. //******过滤特殊字符*******//
  149. function replaceStr(s) {
  150. var pattern = new RegExp("-");
  151. var rs = "";
  152. for(var i = 0; i < s.length; i++) {
  153. rs = rs + s.substr(i, 1).replace(pattern, '');
  154. }
  155. return rs;
  156. }
  157. //**********************//
  158. //根据内容的多少获取高度给父级设置高度
  159. function limitHeight() {
  160. var Length = $(".limitBox").length;
  161. for(var i = 0; i < Length; i++) {
  162. var limitheight = $(".limitwords").eq(i).height();
  163. console.log(limitheight);
  164. $(".limitBox").eq(i).css("height", limitheight);
  165. }
  166. }
  167. //根据用户输入的Email跳转到相应的电子邮箱首页
  168. var hash = {
  169. 'qq.com': 'http://mail.qq.com',
  170. 'gmail.com': 'http://mail.google.com',
  171. 'sina.com': 'http://mail.sina.com.cn',
  172. '163.com': 'http://mail.163.com',
  173. '126.com': 'http://mail.126.com',
  174. 'yeah.net': 'http://www.yeah.net/',
  175. 'sohu.com': 'http://mail.sohu.com/',
  176. 'tom.com': 'http://mail.tom.com/',
  177. 'sogou.com': 'http://mail.sogou.com/',
  178. '139.com': 'http://mail.10086.cn/',
  179. 'hotmail.com': 'http://www.hotmail.com',
  180. 'live.com': 'http://login.live.com/',
  181. 'live.cn': 'http://login.live.cn/',
  182. 'live.com.cn': 'http://login.live.com.cn',
  183. '189.com': 'http://webmail16.189.cn/webmail/',
  184. 'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
  185. 'yahoo.cn': 'http://mail.cn.yahoo.com/',
  186. 'eyou.com': 'http://www.eyou.com/',
  187. '21cn.com': 'http://mail.21cn.com/',
  188. '188.com': 'http://www.188.com/',
  189. 'ustb.edu.cn': 'http://mail.ustb.edu.cn/',
  190. 'foxmail.coom': 'http://www.foxmail.com'
  191. };
  192. //轮播滚动函数
  193. function Carousel(inde, num, show, childcount, obj, next, prev) {
  194. var tapnum = 0; //按钮可点击次数
  195. if(childcount > num) {
  196. next.css("display", "block");
  197. prev.css("display", "none");
  198. } else {
  199. next.css("display", "none");
  200. prev.css("display", "none");
  201. }
  202. next.click(function() {
  203. if(!obj.is(":animated")) {
  204. if(num < childcount) {
  205. tapnum++;
  206. prev.css("display", "block");
  207. if(tapnum == childcount - show) {
  208. next.css("display", "none");
  209. }
  210. num++;
  211. obj.animate({
  212. left: "-=212px"
  213. }, 600);
  214. }
  215. }
  216. });
  217. prev.click(function() {
  218. if(!obj.is(":animated")) {
  219. if(num > inde) {
  220. tapnum--;
  221. next.css("display", "block");
  222. if(tapnum == 0) {
  223. prev.css("display", "none");
  224. }
  225. num--;
  226. obj.animate({
  227. left: "+=212px"
  228. }, 600);
  229. }
  230. }
  231. });
  232. }
  233. //评价字数限制
  234. //字数限制函数
  235. function limitTextCountFn(TextAreaId, countContainerId, count) {
  236. var curLength = $(TextAreaId).val().length;
  237. if(curLength > count) {
  238. var num = $(TextAreaId).val().substr(0, count);
  239. $(TextAreaId).val(num);
  240. } else {
  241. $(countContainerId).text(count - $(TextAreaId).val().length);
  242. }
  243. };
  244. //咨询申请主题字数限制函数
  245. function titleLimitFontCountFn() {
  246. var curLength = $("#consultTitle").val().length;
  247. if(curLength > 20) {
  248. var num = $("#consultTitle").val().substr(0, 20);
  249. $("#consultTitle").val(num);
  250. }
  251. };
  252. function showmenu() {
  253. $("#li_show").css("display", "block");
  254. }
  255. /*选择省份*/
  256. $(document).on("click", "#Province li a", function() {
  257. var aVal = $(this).text();
  258. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  259. $(this).parent().parent().parent().find('input[name=cho_Province]').val(aVal);
  260. if($("#oprovince").text() == "请选择所在省/直辖市" || $("#oprovince").text() == "请选择省/直辖市") {
  261. $("#oprovince").removeClass("mr_select");
  262. $("#ocity").removeClass("mr_select");
  263. } else {
  264. $("#oprovince").addClass("mr_select");
  265. $("#ocity").removeClass("mr_select");
  266. }
  267. });
  268. /*选择城市填充js */
  269. $(document).on("click", "#City li a", function() {
  270. var aVal = $(this).text();
  271. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  272. $(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
  273. if($("#ocity").text() == "请选择所在城市" || $("#ocity").text() == "请选择城市") {
  274. $("#ocity").removeClass("mr_select");
  275. } else {
  276. $("#ocity").addClass("mr_select");
  277. }
  278. });
  279. //咨询 专家信息接口函数
  280. function concultProInfo(professorId) {
  281. $.ajax({
  282. url: "/ajax/professor/editBaseInfo/" + professorId,
  283. type: "get",
  284. data: {
  285. "id": professorId
  286. },
  287. contentType: "application/x-www-form-urlencoded",
  288. success: function(response) {
  289. //console.log(response);
  290. var myData = response["data"];
  291. $("#professorName").html(myData["name"]);
  292. if(myData["title"]) {
  293. $("#professorTitle").html(myData["title"] + ' ');
  294. }
  295. if(myData["department"]) {
  296. $("#profDepartment").html(myData["department"] + ' ');
  297. }
  298. if(myData["orgName"]) {
  299. $("#profOrganization").html(myData["orgName"] + ' ');
  300. }
  301. if(myData["address"]) {
  302. $("#profAdress").html(myData["address"]);
  303. }
  304. console.log(myData["consultCount"])
  305. if(!myData["consultCount"]) {
  306. $("#starLevel").hide();
  307. }
  308. $("#byConsultConut").html(myData["consultCount"]);
  309. $("#sendConsultBtn").attr("proId", myData["id"]);
  310. //星级
  311. var startConut = parseInt(myData["starLevel"]);
  312. if(myData["consultCount"]) {
  313. if(!startConut) {
  314. $(".evastarbox2").hide();
  315. }
  316. }
  317. for(var i = 0; i < startConut; i++) {
  318. $("#starLevel .evastar2").eq(i).addClass("addStar");
  319. }
  320. //认证
  321. var oSty = autho(myData.authType, myData.orgAuth, myData.authStatus);
  322. $("#proModifyN").addClass(oSty.sty);
  323. $("#proModifyN").attr("title", oSty.title);
  324. //头像
  325. if(myData["hasHeadImage"] == 0) {
  326. $("#prohead").attr("src", "images/default-photo.jpg");
  327. } else {
  328. $("#prohead").attr("src", "images/head/" + myData["id"] + "_l.jpg");
  329. }
  330. },
  331. error: function(error) {
  332. $.MsgBox.Alert("message", "请求数据失败");
  333. }
  334. });
  335. };
  336. //发送咨询
  337. function sendConsultHandler(professorId) {
  338. var professorId = professorId;
  339. var consult_type = $(".clicknow").text(); //咨询类型
  340. var consult_title = $("#consultTitle").val(); //咨询主题
  341. var consult_content = $("#consultcontent").val(); //咨询内容
  342. var consultStr = {
  343. "consultType": consult_type,
  344. "consultTitle": consult_title,
  345. "consultContant": consult_content,
  346. "professorId": professorId,
  347. "consultantId": userid
  348. };
  349. if(consult_type == '' || consult_title == '' || consult_content == '') {
  350. $.MsgBox.Alert("消息提醒", "请填写完整");
  351. };
  352. if(consult_type == '') {
  353. $.MsgBox.Alert("消息提醒", "请选择联系目的");
  354. }
  355. if(consult_title == '') {
  356. $.MsgBox.Alert("消息提醒", "请填写咨询目的");
  357. }
  358. if(consult_content == '') {
  359. $.MsgBox.Alert("消息提醒", "请填写咨询内容");
  360. }
  361. if(userid && userid != null && userid != "null" && consult_type != '' &&
  362. consult_title != '' && consult_content != ''
  363. ) {
  364. $.ajax({
  365. "url": "/ajax/consult",
  366. "type": "post",
  367. //传值:咨询类型、主题、内容、专家id、申请人id
  368. "data": consultStr,
  369. "contentType": "application/x-www-form-urlencoded",
  370. "dataType": "json",
  371. "success": function(response) {
  372. console.log(response);
  373. },
  374. "error": function() {
  375. $.MsgBox.Alert("消息提醒", "咨询申请失败");
  376. },
  377. "complete": function() {
  378. //$(".consultapply").remove();
  379. $(".blackcover").remove();
  380. $("body").css("position", "");
  381. $.MsgBox.Alert("消息提醒", "咨询申请成功");
  382. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  383. },
  384. });
  385. }
  386. };
  387. /*标志*/
  388. function autho() {
  389. if(arguments[0] == 1) {
  390. return {
  391. "sty": "authicon-pro",
  392. "title": "科袖认证专家"
  393. }
  394. } else {
  395. if(arguments[1] == 1) {
  396. return {
  397. "sty": "authicon-staff-ok",
  398. "title": "企业认证员工"
  399. }
  400. } else {
  401. if(arguments[2] == 3) {
  402. return {
  403. "sty": "authicon-real",
  404. "title": "实名认证用户"
  405. }
  406. } else {
  407. return {
  408. "sty": "e",
  409. "title": " "
  410. }
  411. }
  412. }
  413. }
  414. }
  415. //获取用户类型
  416. var ifuser = ifUserType();
  417. function ifUserType(pa) {
  418. if(pa) {
  419. var useridtype = pa;
  420. } else {
  421. var useridtype = $.cookie('userid');
  422. }
  423. var authType2, authentication2;
  424. if(useridtype && useridtype != "null" && useridtype != null) {
  425. $.ajax({
  426. "url": "/ajax/professor/auth",
  427. "type": "GET",
  428. "data": {
  429. "id": useridtype
  430. },
  431. "dataType": "json",
  432. "async": false,
  433. "success": function(data) {
  434. if(data.success) {
  435. authType2 = data.data.authType;
  436. authentication2 = data.data.authentication;
  437. }
  438. }
  439. });
  440. }
  441. return {
  442. "authType2": authType2,
  443. "authentication2": authentication2,
  444. }
  445. }
  446. //工作台判断用户类型显示用户权限
  447. if($.cookie('userName') && $.cookie('userName') != "null" && $.cookie('userName') != null) {
  448. if(ifuser.authType2 == 0) {
  449. $("#repalyf").addClass("repalyf");
  450. /*点击未读咨询消息查看*/
  451. $("#gozixu").on("click", function() {
  452. window.location.href = "myConsult.html";
  453. })
  454. } else {
  455. $(".nohide").show();
  456. /*点击未读咨询消息查看*/
  457. $("#gozixu").on("click", function() {
  458. window.location.href = "consult.html";
  459. })
  460. }
  461. }
  462. /*多行文本框样式(带有限制数字)模拟focus效果*/
  463. $(".msgContbox textarea").focus(function() {
  464. $(this).parent().css("border-color", "#ff9900");
  465. }).blur(function() {
  466. $(this).parent().css("border-color", "#E5E5E5");
  467. })
  468. //时间显示规则
  469. function commenTime(startTime) {
  470. //console.log(startTime)
  471. var nowTimg = new Date();
  472. var startdate = new Date();
  473. startdate.setFullYear(parseInt(startTime.substring(0, 4)));
  474. startdate.setMonth(parseInt(startTime.substring(4, 6)) - 1);
  475. startdate.setDate(parseInt(startTime.substring(6, 8)));
  476. startdate.setHours(parseInt(startTime.substring(8, 10)));
  477. startdate.setMinutes(parseInt(startTime.substring(10, 12)));
  478. startdate.setSeconds(parseInt(startTime.substring(12, 14)));
  479. var date3 = nowTimg.getTime() - startdate.getTime(); //时间差的毫秒数
  480. var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  481. var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
  482. if(date3 < 60000) {
  483. return "刚刚";
  484. } else if(date3 >= 60000 && date3 < 3600000) {
  485. return minutes + "分钟前";
  486. } else if(date3 >= 3600000 && date3 < 86400000) {
  487. return hours + "小时前";
  488. } else if(date3 >= 86400000) {
  489. if(nowTimg.getFullYear() == startTime.substring(0, 4)) {
  490. return startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
  491. } else {
  492. return startTime.substring(0, 4) + "年" + startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
  493. }
  494. }
  495. }
  496. /*时间转换*/
  497. function TimeTr(dealtime) {
  498. var myDate = new Date();
  499. var s = dealtime;
  500. var y = s.substr(0, 4);
  501. var m = s.substr(4, 2);
  502. var d = s.substr(6, 2);
  503. var h = s.substr(8, 2);
  504. var minute = s.substr(10, 2);
  505. var formatTime;
  506. if(s.length <= 6) {
  507. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月";
  508. } else if(s.length > 6 && s.length <= 8) {
  509. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
  510. } else {
  511. formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  512. if(y != myDate.getFullYear()) {
  513. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  514. }
  515. }
  516. return formatTime;
  517. }
  518. /*判断是否收藏资源文章或者是否关注专家*/
  519. function ifcollectionAbout(watchObject, num) {
  520. $.ajax('/ajax/watch/hasWatch', {
  521. data: {
  522. "professorId": userid,
  523. "watchObject": watchObject
  524. },
  525. dataType: 'json', //数据格式类型
  526. type: 'get', //http请求类型
  527. timeout: 10000,
  528. async: false,
  529. success: function(data) {
  530. if(data.success && data.data != null) {
  531. if(num == "1") { //已关注专家
  532. $("#attentBtn").addClass("attenedSpan");
  533. $("#attentBtn").text("已关注");
  534. } else { //已收藏资源或文章
  535. $("#collectBtn").removeClass("icon-collect");
  536. $("#collectBtn").addClass("icon-collected");
  537. }
  538. } else {
  539. if(num == "1") { //关注专家
  540. $("#attentBtn").removeClass("attenedSpan");
  541. $("#attentBtn").text("关注");
  542. } else { //收藏资源或文章
  543. $("#collectBtn").addClass("icon-collect");
  544. $("#collectBtn").removeClass("icon-collected");
  545. }
  546. }
  547. },
  548. error: function(data) {
  549. $.MsgBox.Alert('提示', "服务器链接超时");
  550. }
  551. });
  552. }
  553. /*收藏资源、文章或者关注专家*/
  554. function collectionAbout(watchObject, num) {
  555. $.ajax('/ajax/watch', {
  556. data: {
  557. "professorId": userid,
  558. "watchObject": watchObject,
  559. "watchType": num
  560. },
  561. dataType: 'json', //数据格式类型
  562. type: 'POST', //http请求类型
  563. timeout: 10000,
  564. async: false,
  565. success: function(data) {
  566. if(data.success) {
  567. if(num == "1") { //关注专家
  568. $("#attentBtn").addClass("attenedSpan");
  569. $("#attentBtn").text("已关注");
  570. } else { //收藏资源或文章
  571. $("#collectBtn").removeClass("icon-collect");
  572. $("#collectBtn").addClass("icon-collected");
  573. }
  574. }
  575. },
  576. error: function(data) {
  577. $.MsgBox.Alert('提示', "服务器链接超时");
  578. }
  579. });
  580. }
  581. /*取消收藏资源、文章或者取消关注专家*/
  582. function cancelCollectionAbout(watchObject, num) {
  583. $.ajax({
  584. url: '/ajax/watch/delete',
  585. data: {
  586. professorId: userid,
  587. watchObject: watchObject
  588. },
  589. dataType: 'json', //数据格式类型
  590. type: 'post', //http请求类型
  591. timeout: 10000,
  592. async: true,
  593. success: function(data) {
  594. console.log(data.success)
  595. if(data.success) {
  596. if(num == "1") { //关注专家
  597. $("#attentBtn").removeClass("attenedSpan");
  598. $("#attentBtn").text("关注");
  599. } else { //收藏资源或文章
  600. $("#collectBtn").addClass("icon-collect");
  601. $("#collectBtn").removeClass("icon-collected");
  602. }
  603. }
  604. },
  605. error: function(data) {
  606. $.MsgBox.Alert('提示', "服务器链接超时");
  607. }
  608. });
  609. }
  610. //企业规模
  611. var orgSizeShow = {
  612. '1': '50人以内',
  613. '2': '50-100人',
  614. '3': '100-200人',
  615. '4': '200-500人',
  616. '5': '500-1000人',
  617. '6': '1000人以上'
  618. }
  619. //企业类型
  620. var orgTypeShow = {
  621. "2": "上市企业",
  622. "3": "国有企业",
  623. "4": "合资企业",
  624. "5": "私人企业",
  625. "6": "外资企业",
  626. "7": "初创企业"
  627. }
  628. //学位
  629. var eduDegree = {
  630. "1": "博士",
  631. "2": "硕士",
  632. "3": "学士",
  633. "4": "大专",
  634. "5": "其他"
  635. }
  636. function hotKey(sel, num) {
  637. $(sel).bind({
  638. paste: function(e) {
  639. var pastedText;
  640. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  641.             
  642. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  643. else  {            
  644. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  645.           
  646. }
  647. $(this).val(pastedText);
  648. var $this = $(this);
  649. setTimeout(function() {
  650. if($this.val().trim()) {
  651. $this.siblings("button").show();
  652. } else {
  653. $this.siblings("button").hide();
  654. }
  655. }, 1);
  656. e.preventDefault();
  657. },
  658. cut: function(e) {
  659. var $this = $(this);
  660. setTimeout(function() {
  661. if($this.val().trim()) {
  662. $this.siblings("button").show();
  663. } else {
  664. $this.siblings("button").hide();
  665. }
  666. }, 1);
  667. },
  668. blur: function() {
  669. var $this = $(this);
  670. setTimeout(function() {
  671. $this.siblings(".keydrop").hide();
  672. }, 500)
  673. },
  674. focus: function() {
  675. $(this).siblings(".keydrop").show();
  676. },
  677. keyup: function(e) {
  678. if($(this).val().trim()) {
  679. $(this).siblings("button").show();
  680. var lNum = $.trim($(this).val()).length;
  681. if(0 < lNum) {
  682. var $this = $(this)
  683. $("#addKeyword").show();
  684. $.ajax({
  685. "url": "/ajax/dataDict/qaHotKey",
  686. "type": "GET",
  687. "success": function(data) {
  688. console.log(data);
  689. if(data.success) {
  690. if(data.data.length == 0) {
  691. $this.siblings(".keydrop").addClass("displayNone");
  692. $this.siblings(".keydrop").find("ul").html("");
  693. } else {
  694. $this.siblings(".keydrop").removeClass("displayNone");
  695. var oSr = "";
  696. for(var i = 0; i < data.data.length; i++) {
  697. oSr += '<li>' + data.data[i].caption + '<div class="closeThis"></div></li>';
  698. }
  699. $this.siblings(".keydrop").find("ul").html(oSr);
  700. }
  701. } else {
  702. $this.siblings(".keydrop").addClass("displayNone");
  703. $this.siblings(".keydrop").find("ul").html("");
  704. }
  705. },
  706. "data": {
  707. "key": $(this).val()
  708. },
  709. dataType: "json",
  710. 'error': function() {
  711. $.MsgBox.Alert('提示', '服务器连接超时!');
  712. }
  713. });
  714. }
  715. } else {
  716. $(this).siblings("button").hide();
  717. $(this).siblings(".keydrop").addClass("displayNone");
  718. $(this).siblings(".keydrop").find("ul").html("");
  719. }
  720. }
  721. })
  722. $(".keydrop").on("click", "li", function() {
  723. var oValue = $(this).text();
  724. var oJudge = $(this).parents(".col-w-12").siblings().find("ul.ulspace li");
  725. var addNum = $(this).parents(".keydrop").siblings("input").attr("data-num");
  726. for(var i = 0; i < oJudge.length; i++) {
  727. if(oValue == oJudge[i].innerText) {
  728. $.MsgBox.Alert('提示', '添加内容不能重复');
  729. return;
  730. }
  731. }
  732. $(this).parents(".col-w-12").siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  733. $(this).parents(".keydrop").siblings("input").val("");
  734. $(this).parents(".keydrop").siblings("button").hide();
  735. if(oJudge.length == addNum - 1) {
  736. $(this).parents(".keydrop").siblings("input").val("");
  737. $(this).parents(".col-w-12").hide();
  738. }
  739. $(this).parent("ul").html("")
  740. })
  741. if(num == 1) {
  742. return;
  743. } else {
  744. /*添加*/
  745. $(".addButton").click(function() {
  746. var oValue = $(this).siblings("input").val().trim();
  747. var oJudge = $(this).parent().siblings().find("ul.ulspace li");
  748. var addContent = $(this).siblings("input").attr("data-pro");
  749. var addNum = $(this).siblings("input").attr("data-num");
  750. var addfontSizeNum = $(this).siblings("input").attr("data-fontSizeN");
  751. if(!oValue) {
  752. $.MsgBox.Alert('提示', '请先填写内容');
  753. return;
  754. }
  755. if(oValue.length > addfontSizeNum) {
  756. $.MsgBox.Alert('提示', addContent);
  757. return;
  758. }
  759. for(var i = 0; i < oJudge.length; i++) {
  760. if(oValue == oJudge[i].innerText) {
  761. $.MsgBox.Alert('提示', '添加内容不能重复');
  762. return;
  763. }
  764. }
  765. $(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  766. $(this).hide();
  767. $(this).siblings("input").val("");
  768. if(oJudge.length == addNum - 1) {
  769. $(this).val("").parents(".col-w-12").hide();
  770. }
  771. $(this).siblings(".keydrop").find("ul").html("");
  772. })
  773. }
  774. }