portal html css js resource

common.js 28KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105
  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() == "请选择省/直辖市") {
  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() == "请选择城市") {
  274. $("#ocity").removeClass("mr_select");
  275. } else {
  276. $("#ocity").addClass("mr_select");
  277. }
  278. });
  279. /*下拉select选择js */
  280. function seleCo(obj){
  281. var sleTd=$(obj).val();
  282. // alert(sleTd)
  283. if(sleTd==0){
  284. $(obj).css("color","#999");
  285. }else{
  286. $(obj).css("color","#666");
  287. }
  288. }
  289. //咨询 专家信息接口函数
  290. function concultProInfo(professorId) {
  291. $.ajax({
  292. url: "/ajax/professor/editBaseInfo/" + professorId,
  293. type: "get",
  294. data: {
  295. "id": professorId
  296. },
  297. contentType: "application/x-www-form-urlencoded",
  298. success: function(response) {
  299. //console.log(response);
  300. var myData = response["data"];
  301. $("#professorName").html(myData["name"]);
  302. if(myData["title"]) {
  303. $("#professorTitle").html(myData["title"] + ' ');
  304. }
  305. if(myData["department"]) {
  306. $("#profDepartment").html(myData["department"] + ' ');
  307. }
  308. if(myData["orgName"]) {
  309. $("#profOrganization").html(myData["orgName"] + ' ');
  310. }
  311. if(myData["address"]) {
  312. $("#profAdress").html(myData["address"]);
  313. }
  314. console.log(myData["consultCount"])
  315. if(!myData["consultCount"]) {
  316. $("#starLevel").hide();
  317. }
  318. $("#byConsultConut").html(myData["consultCount"]);
  319. $("#sendConsultBtn").attr("proId", myData["id"]);
  320. //星级
  321. var startConut = parseInt(myData["starLevel"]);
  322. if(myData["consultCount"]) {
  323. if(!startConut) {
  324. $(".evastarbox2").hide();
  325. }
  326. }
  327. for(var i = 0; i < startConut; i++) {
  328. $("#starLevel .evastar2").eq(i).addClass("addStar");
  329. }
  330. //认证
  331. var oSty = autho(myData.authType, myData.orgAuth, myData.authStatus);
  332. $("#proModifyN").addClass(oSty.sty);
  333. $("#proModifyN").attr("title", oSty.title);
  334. //头像
  335. if(myData["hasHeadImage"] == 0) {
  336. $("#prohead").attr("src", "images/default-photo.jpg");
  337. } else {
  338. $("#prohead").attr("src", "images/head/" + myData["id"] + "_l.jpg");
  339. }
  340. },
  341. error: function(error) {
  342. $.MsgBox.Alert("message", "请求数据失败");
  343. }
  344. });
  345. };
  346. //发送咨询
  347. function sendConsultHandler(professorId) {
  348. var professorId = professorId;
  349. var consult_type = $(".clicknow").text(); //咨询类型
  350. var consult_title = $("#consultTitle").val(); //咨询主题
  351. var consult_content = $("#consultcontent").val(); //咨询内容
  352. var consultStr = {
  353. "consultType": consult_type,
  354. "consultTitle": consult_title,
  355. "consultContant": consult_content,
  356. "professorId": professorId,
  357. "consultantId": userid
  358. };
  359. if(consult_type == '' || consult_title == '' || consult_content == '') {
  360. $.MsgBox.Alert("消息提醒", "请填写完整");
  361. };
  362. if(consult_type == '') {
  363. $.MsgBox.Alert("消息提醒", "请选择联系目的");
  364. }
  365. if(consult_title == '') {
  366. $.MsgBox.Alert("消息提醒", "请填写咨询目的");
  367. }
  368. if(consult_content == '') {
  369. $.MsgBox.Alert("消息提醒", "请填写咨询内容");
  370. }
  371. if(userid && userid != null && userid != "null" && consult_type != '' &&
  372. consult_title != '' && consult_content != ''
  373. ) {
  374. $.ajax({
  375. "url": "/ajax/consult",
  376. "type": "post",
  377. //传值:咨询类型、主题、内容、专家id、申请人id
  378. "data": consultStr,
  379. "contentType": "application/x-www-form-urlencoded",
  380. "dataType": "json",
  381. "success": function(response) {
  382. console.log(response);
  383. },
  384. "error": function() {
  385. $.MsgBox.Alert("消息提醒", "咨询申请失败");
  386. },
  387. "complete": function() {
  388. //$(".consultapply").remove();
  389. $(".blackcover").remove();
  390. $("body").css("position", "");
  391. $.MsgBox.Alert("消息提醒", "咨询申请成功");
  392. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  393. },
  394. });
  395. }
  396. };
  397. /*标志*/
  398. function autho() {
  399. if(arguments[0] == 1) {
  400. return {
  401. "sty": "authicon-pro",
  402. "title": "科袖认证专家"
  403. }
  404. } else {
  405. if(arguments[1] == 1) {
  406. return {
  407. "sty": "authicon-staff-ok",
  408. "title": "企业认证员工"
  409. }
  410. } else {
  411. if(arguments[2] == 3) {
  412. return {
  413. "sty": "authicon-real",
  414. "title": "实名认证用户"
  415. }
  416. } else {
  417. return {
  418. "sty": "e",
  419. "title": " "
  420. }
  421. }
  422. }
  423. }
  424. }
  425. //获取用户类型
  426. var ifuser = ifUserType();
  427. function ifUserType(pa) {
  428. if(pa) {
  429. var useridtype = pa;
  430. } else {
  431. var useridtype = $.cookie('userid');
  432. }
  433. var authType2, authentication2;
  434. if(useridtype && useridtype != "null" && useridtype != null) {
  435. $.ajax({
  436. "url": "/ajax/professor/auth",
  437. "type": "GET",
  438. "data": {
  439. "id": useridtype
  440. },
  441. "dataType": "json",
  442. "async": false,
  443. "success": function(data) {
  444. if(data.success) {
  445. authType2 = data.data.authType;
  446. authentication2 = data.data.authentication;
  447. }
  448. }
  449. });
  450. }
  451. return {
  452. "authType2": authType2,
  453. "authentication2": authentication2,
  454. }
  455. }
  456. //工作台判断用户类型显示用户权限
  457. if($.cookie('userName') && $.cookie('userName') != "null" && $.cookie('userName') != null) {
  458. if(ifuser.authType2 == 0) {
  459. $("#repalyf").addClass("repalyf");
  460. /*点击未读咨询消息查看*/
  461. $("#gozixu").on("click", function() {
  462. window.location.href = "myConsult.html";
  463. })
  464. } else {
  465. $(".nohide").show();
  466. /*点击未读咨询消息查看*/
  467. $("#gozixu").on("click", function() {
  468. window.location.href = "consult.html";
  469. })
  470. }
  471. }
  472. /*多行文本框样式(带有限制数字)模拟focus效果*/
  473. $(".msgContbox textarea").focus(function() {
  474. $(this).parent().css("border-color", "#ff9900");
  475. }).blur(function() {
  476. $(this).parent().css("border-color", "#E5E5E5");
  477. })
  478. //时间显示规则
  479. function commenTime(startTime) {
  480. //console.log(startTime)
  481. var nowTimg = new Date();
  482. var startdate = new Date();
  483. startdate.setFullYear(parseInt(startTime.substring(0, 4)));
  484. startdate.setMonth(parseInt(startTime.substring(4, 6)) - 1);
  485. startdate.setDate(parseInt(startTime.substring(6, 8)));
  486. startdate.setHours(parseInt(startTime.substring(8, 10)));
  487. startdate.setMinutes(parseInt(startTime.substring(10, 12)));
  488. startdate.setSeconds(parseInt(startTime.substring(12, 14)));
  489. var date3 = nowTimg.getTime() - startdate.getTime(); //时间差的毫秒数
  490. var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  491. var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
  492. if(date3 < 60000) {
  493. return "刚刚";
  494. } else if(date3 >= 60000 && date3 < 3600000) {
  495. return minutes + "分钟前";
  496. } else if(date3 >= 3600000 && date3 < 86400000) {
  497. return hours + "小时前";
  498. } else if(date3 >= 86400000) {
  499. if(nowTimg.getFullYear() == startTime.substring(0, 4)) {
  500. 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);
  501. } else {
  502. 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);
  503. }
  504. }
  505. }
  506. /*时间转换*/
  507. function TimeTr(dealtime) {
  508. var myDate = new Date();
  509. var s = dealtime;
  510. var y = s.substr(0, 4);
  511. var m = s.substr(4, 2);
  512. var d = s.substr(6, 2);
  513. var h = s.substr(8, 2);
  514. var minute = s.substr(10, 2);
  515. var formatTime;
  516. if(s.length <= 6) {
  517. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月";
  518. } else if(s.length > 6 && s.length <= 8) {
  519. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
  520. } else {
  521. formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  522. if(y != myDate.getFullYear()) {
  523. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  524. }
  525. }
  526. return formatTime;
  527. }
  528. /*判断是否收藏资源文章或者是否关注专家*/
  529. function ifcollectionAbout(watchObject, sel,num) {
  530. var that=sel;
  531. $.ajax('/ajax/watch/hasWatch', {
  532. data: {
  533. "professorId": userid,
  534. "watchObject": watchObject
  535. },
  536. dataType: 'json', //数据格式类型
  537. type: 'get', //http请求类型
  538. timeout: 10000,
  539. async: false,
  540. success: function(data) {
  541. if(data.success && data.data != null) {
  542. if(num == "1" || num == "6") { //已关注专家
  543. $(that).addClass("attenedSpan");
  544. $(that).text("已关注");
  545. } else { //已收藏资源或文章
  546. $(that).removeClass("icon-collect");
  547. $(that).addClass("icon-collected");
  548. }
  549. } else {
  550. if(num == "1" || num == "6") { //关注专家
  551. $(that).removeClass("attenedSpan");
  552. $(that).text("关注");
  553. } else { //收藏资源或文章
  554. $(that).addClass("icon-collect");
  555. $(that).removeClass("icon-collected");//
  556. }
  557. }
  558. },
  559. error: function(data) {
  560. $.MsgBox.Alert('提示', "服务器链接超时");
  561. }
  562. });
  563. }
  564. /*收藏资源、文章或者关注专家*/
  565. function collectionAbout(watchObject,sel, num) {
  566. var that=sel;
  567. $.ajax('/ajax/watch', {
  568. data: {
  569. "professorId": userid,
  570. "watchObject": watchObject,
  571. "watchType": num
  572. },
  573. dataType: 'json', //数据格式类型
  574. type: 'POST', //http请求类型
  575. timeout: 10000,
  576. async: false,
  577. success: function(data) {
  578. if(data.success) {
  579. if(num == "1" || num == "6") {
  580. $(that).addClass("attenedSpan");
  581. $(that).text("已关注");
  582. } else {
  583. $(that).removeClass("icon-collect");
  584. $(that).addClass("icon-collected");
  585. }
  586. }
  587. },
  588. error: function(data) {
  589. $.MsgBox.Alert('提示', "服务器链接超时");
  590. }
  591. });
  592. }
  593. /*取消收藏资源、文章或者取消关注专家*/
  594. function cancelCollectionAbout(watchObject,sel,num) {
  595. var that=sel;
  596. $.ajax({
  597. url: '/ajax/watch/delete',
  598. data: {
  599. professorId: userid,
  600. watchObject: watchObject
  601. },
  602. dataType: 'json', //数据格式类型
  603. type: 'post', //http请求类型
  604. timeout: 10000,
  605. async: true,
  606. success: function(data) {
  607. console.log(data.success)
  608. if(num == "1" || num == "6") { //关注专家
  609. $(that).removeClass("attenedSpan");
  610. $(that).text("关注");
  611. } else { //收藏资源或文章
  612. $(that).addClass("icon-collect");
  613. $(that).removeClass("icon-collected");
  614. }
  615. },
  616. error: function(data) {
  617. $.MsgBox.Alert('提示', "服务器链接超时");
  618. }
  619. });
  620. }
  621. //企业规模
  622. var orgSizeShow = {
  623. '1': '50人以内',
  624. '2': '50-100人',
  625. '3': '100-200人',
  626. '4': '200-500人',
  627. '5': '500-1000人',
  628. '6': '1000人以上'
  629. }
  630. //企业类型
  631. var orgTypeShow = {
  632. "2": "上市企业",
  633. "3": "外资企业",
  634. "4": "合资企业",
  635. "5": "独资企业",
  636. "6": "个体经营",
  637. "7": "政府机构",
  638. "8": "公益组织",
  639. "9": "协会学会",
  640. "10": "新闻媒体",
  641. "11": "教育机构",
  642. "undefined":""
  643. }
  644. //学位
  645. var eduDegree = {
  646. "1": "博士",
  647. "2": "硕士",
  648. "3": "学士",
  649. "4": "大专",
  650. "5": "其他"
  651. }
  652. //栏目
  653. var columnType = {
  654. "1":{
  655. fullName:"个人原创",
  656. shortName:"原创"
  657. },
  658. "2":{
  659. fullName:"企业原创",
  660. shortName:"原创"
  661. },
  662. "3":{
  663. fullName:"前沿动态",
  664. shortName:"前沿"
  665. },
  666. "4":{
  667. fullName:"学术经验",
  668. shortName:"经验"
  669. },
  670. "5":{
  671. fullName:"分析检测",
  672. shortName:"检测"
  673. },
  674. "6":{
  675. fullName:"会议培训",
  676. shortName:"会议"
  677. },
  678. "7":{
  679. fullName:"科袖访谈",
  680. shortName:"访谈"
  681. },
  682. "8":{
  683. fullName:"招聘招生",
  684. shortName:"招聘"
  685. },
  686. "9":{
  687. fullName:"重大新闻",
  688. shortName:"新闻"
  689. }
  690. }
  691. //反馈意见成功
  692. function backSuccessed(){
  693. $(".correctCon").val("");
  694. $(".correctSubmit").attr("disabled",true);
  695. $(".correctSubmit").parents(".correctBlock").fadeOut();
  696. $.MsgBox.Alert('提示', '感谢您的反馈,我们马上处理。');
  697. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  698. }
  699. function hotKey(sel, num) {
  700. $(sel).bind({
  701. paste: function(e) {
  702. var pastedText;
  703. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  704. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  705. else  {            
  706. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  707. }
  708. $(this).val(pastedText);
  709. var $this = $(this);
  710. setTimeout(function() {
  711. if($this.val().trim()) {
  712. $this.siblings("button").show();
  713. } else {
  714. $this.siblings("button").hide();
  715. }
  716. }, 1);
  717. e.preventDefault();
  718. },
  719. cut: function(e) {
  720. var $this = $(this);
  721. setTimeout(function() {
  722. if($this.val().trim()) {
  723. $this.siblings("button").show();
  724. } else {
  725. $this.siblings("button").hide();
  726. }
  727. }, 1);
  728. },
  729. blur: function() {
  730. var $this = $(this);
  731. setTimeout(function() {
  732. $this.siblings(".keydrop").hide();
  733. }, 500)
  734. },
  735. focus: function() {
  736. $(this).siblings(".keydrop").show();
  737. },
  738. keyup: function(e) {
  739. var ti=$(this).val();
  740. var $t=this;
  741. $t.comr=ti;
  742. var $this=$(this);
  743. if($(this).val().trim()) {
  744. $(this).siblings("button").show();
  745. var lNum = $.trim($(this).val()).length;
  746. if(0 < lNum) {
  747. setTimeout(function(){
  748. if( ti===$t.comr && ti!== $t.comrEnd) {
  749. var tt=ti;
  750. $t.comrEnd=tt;
  751. $("#addKeyword").show();
  752. $.ajax({
  753. "url": "/ajax/dataDict/qaHotKey",
  754. "type": "GET",
  755. "success": function(data) {
  756. console.log(data);
  757. if(data.success) {
  758. if($t.comrEnd==tt) {
  759. if(data.data.length == 0) {
  760. $this.siblings(".keydrop").addClass("displayNone");
  761. $this.siblings(".keydrop").find("ul").html("");
  762. } else {
  763. $this.siblings(".keydrop").removeClass("displayNone");
  764. var oSr = "";
  765. for(var i = 0; i < Math.min(data.data.length,5); i++) {
  766. oSr += '<li>' + data.data[i].caption + '<div class="closeThis"></div></li>';
  767. }
  768. $this.siblings(".keydrop").find("ul").html(oSr);
  769. }
  770. }
  771. } else {
  772. $this.siblings(".keydrop").addClass("displayNone");
  773. $this.siblings(".keydrop").find("ul").html("");
  774. }
  775. },
  776. "data": {
  777. "key": $this.val()
  778. },
  779. dataType: "json",
  780. 'error': function() {
  781. $.MsgBox.Alert('提示', '服务器连接超时!');
  782. }
  783. });
  784. }
  785. },500);
  786. }
  787. } else {
  788. $(this).siblings("button").hide();
  789. $(this).siblings(".keydrop").addClass("displayNone");
  790. $(this).siblings(".keydrop").find("ul").html("");
  791. }
  792. }
  793. })
  794. $(".keydrop").on("click", "li", function() {
  795. var oValue = $(this).text();
  796. var oJudge = $(this).parents(".col-w-12").siblings().find("ul.ulspace li");
  797. var addNum = $(this).parents(".keydrop").siblings("input").attr("data-num");
  798. for(var i = 0; i < oJudge.length; i++) {
  799. if(oValue == oJudge[i].innerText) {
  800. $.MsgBox.Alert('提示', '添加内容不能重复');
  801. return;
  802. }
  803. }
  804. $(this).parents(".col-w-12").siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  805. $(this).parents(".keydrop").siblings("input").val("");
  806. $(this).parents(".keydrop").siblings("button").hide();
  807. if(oJudge.length == addNum - 1) {
  808. $(this).parents(".keydrop").siblings("input").val("");
  809. $(this).parents(".col-w-12").hide();
  810. }
  811. $(this).parent("ul").html("")
  812. })
  813. if(num == 1) {
  814. return;
  815. } else {
  816. /*添加*/
  817. $(".addButton").click(function() {
  818. var oValue = $(this).siblings("input").val().trim();
  819. var oJudge = $(this).parent().siblings().find("ul.ulspace li");
  820. var addContent = $(this).siblings("input").attr("data-pro");
  821. var addNum = $(this).siblings("input").attr("data-num");
  822. var addfontSizeNum = $(this).siblings("input").attr("data-fontSizeN");
  823. if(!oValue) {
  824. $.MsgBox.Alert('提示', '请先填写内容');
  825. return;
  826. }
  827. if(oValue.length > addfontSizeNum) {
  828. $.MsgBox.Alert('提示', addContent);
  829. return;
  830. }
  831. for(var i = 0; i < oJudge.length; i++) {
  832. if(oValue == oJudge[i].innerText) {
  833. $.MsgBox.Alert('提示', '添加内容不能重复');
  834. return;
  835. }
  836. }
  837. $(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  838. $(this).hide();
  839. $(this).siblings("input").val("");
  840. if(oJudge.length == addNum - 1) {
  841. $(this).val("").parents(".col-w-12").hide();
  842. }
  843. $(this).siblings(".keydrop").find("ul").html("");
  844. })
  845. }
  846. }
  847. //带有限制字数的多行文本框
  848. function limitObj(obj,maxNum){
  849. $(obj).bind({
  850. paste: function(e) {
  851. if($(this).val().length==""){
  852. $(this).parent().siblings(".btnModel").attr("disabled", true);
  853. }else{
  854. $(this).parent().siblings(".btnModel").attr("disabled", false);
  855. }
  856. var pastedText;
  857. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  858. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  859. else  {            
  860. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  861. }
  862. $(this).val(pastedText);
  863. setTimeout(function() {
  864. $(this).siblings().find("em").text($(obj).val().length);
  865. }, 1);
  866. e.preventDefault();
  867. },
  868. cut: function(e) {
  869. if($(this).val().length==""){
  870. $(this).parent().siblings(".btnModel").attr("disabled", true);
  871. }else{
  872. $(this).parent().siblings(".btnModel").attr("disabled", false);
  873. }
  874. setTimeout(function() {
  875. $(obj).siblings().find("em").text($(obj).val().length);
  876. }, 1);
  877. },
  878. keyup: function(e) {
  879. if($(this).val().length==""){
  880. $(this).parent().siblings(".btnModel").attr("disabled", true);
  881. }else{
  882. $(this).parent().siblings(".btnModel").attr("disabled", false);
  883. }
  884. if($(this).val().length > maxNum) {
  885. $(obj).val($(obj).val().substring(0, maxNum));
  886. e.preventDefault();
  887. }
  888. setTimeout(function() {
  889. $(obj).siblings().find("em").text($(obj).val().length);
  890. }, 1);
  891. }
  892. });
  893. }
  894. var r64 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "-", "_"];
  895. var d64 = {
  896. "0": 0,
  897. "1": 1,
  898. "2": 2,
  899. "3": 3,
  900. "4": 4,
  901. "5": 5,
  902. "6": 6,
  903. "7": 7,
  904. "8": 8,
  905. "9": 9,
  906. "A": 10,
  907. "B": 11,
  908. "C": 12,
  909. "D": 13,
  910. "E": 14,
  911. "F": 15,
  912. "G": 16,
  913. "H": 17,
  914. "I": 18,
  915. "J": 19,
  916. "K": 20,
  917. "L": 21,
  918. "M": 22,
  919. "N": 23,
  920. "O": 24,
  921. "P": 25,
  922. "Q": 26,
  923. "R": 27,
  924. "S": 28,
  925. "T": 29,
  926. "U": 30,
  927. "V": 31,
  928. "W": 32,
  929. "X": 33,
  930. "Y": 34,
  931. "Z": 35,
  932. "a": 36,
  933. "b": 37,
  934. "c": 38,
  935. "d": 39,
  936. "e": 40,
  937. "f": 41,
  938. "g": 42,
  939. "h": 43,
  940. "i": 44,
  941. "j": 45,
  942. "k": 46,
  943. "l": 47,
  944. "m": 48,
  945. "n": 49,
  946. "o": 50,
  947. "p": 51,
  948. "q": 52,
  949. "r": 53,
  950. "s": 54,
  951. "t": 55,
  952. "u": 56,
  953. "v": 57,
  954. "w": 58,
  955. "x": 59,
  956. "y": 60,
  957. "z": 61,
  958. "-": 62,
  959. "_": 63
  960. };
  961. function s16to64(s) {
  962. var out, idx, n1, n2, n3;
  963. idx = s.length - 1;
  964. out = "";
  965. while(idx >= 0) {
  966. n1 = d64[s.charAt(idx--)];
  967. if(idx < 0) {
  968. out = r64[n1] + out;
  969. break;
  970. }
  971. n2 = d64[s.charAt(idx--)];
  972. if(idx < 0) {
  973. out = r64[(n2 >>> 2)] + r64[((n2 & 0x3) << 4) + n1] + out;
  974. break;
  975. }
  976. n3 = d64[s.charAt(idx--)];
  977. out = r64[(n2 >>> 2) + (n3 << 2)] + r64[((n2 & 0x3) << 4) + n1] + out;
  978. }
  979. return out;
  980. }
  981. function s64to16(s) {
  982. var out, idx, n1, n2;
  983. idx = s.length - 1;
  984. out = "";
  985. while(idx >= 0) {
  986. n1 = d64[s.charAt(idx--)];
  987. if(idx < 0) {
  988. out = r64[n1 >>> 4] + r64[n1 & 0xF] + out;
  989. break;
  990. }
  991. n2 = d64[s.charAt(idx--)];
  992. out = r64[(n2 >>> 2)] + r64[(n1 >>> 4) + ((n2 & 0x3) << 2)] + r64[n1 & 0xF] + out;
  993. }
  994. if(out.length>32) {
  995. return out.substring(1);
  996. }
  997. return out;
  998. }
  999. //发现上方轮播
  1000. var bannerRotate = {// banner rotating
  1001. _time: 3000,
  1002. _i: 0,
  1003. _interval: null,
  1004. _navId: "#slide-tab",
  1005. _navBox: "#slide-list",
  1006. bannerShow: function() {
  1007. $(this._navId).find("li").removeClass("slide-tab-item-active");
  1008. $(this._navId).find("li:eq("+this._i+")").addClass("slide-tab-item-active");
  1009. $(this._navBox).find("li").removeClass("slide-item-active");
  1010. $(this._navBox).find("li:eq("+this._i+")").addClass("slide-item-active");
  1011. },
  1012. bannerStart:function() {
  1013. var _this = this;
  1014. _this._interval = setInterval(function() {
  1015. if(_this._i >= 4) {
  1016. _this._i = 0;
  1017. }
  1018. else {
  1019. _this._i++;
  1020. }
  1021. _this.bannerShow();
  1022. }, _this._time);
  1023. },
  1024. bannerInit: function() {
  1025. var _this = this;
  1026. _this.bannerStart();
  1027. $(_this._navId).find("li").bind("mouseover", function() {
  1028. clearInterval(_this._interval);
  1029. _this._i = $(this).index();
  1030. _this.bannerShow();
  1031. _this.bannerStart();
  1032. });
  1033. }
  1034. };