portal html css js resource

common.js 28KB

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