portal html css js resource

common.js 30KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  1. $(document).ready(function() {
  2. $(".unlogin").show();
  3. $(".onlogin").hide();
  4. var footerHeight = $("footer").outerHeight(true);
  5. $('#container').css("padding-bottom", footerHeight + "px");
  6. $(".footer_tools").css("bottom", (footerHeight+10) + "px");
  7. //窗口大小变更事件
  8. $(window).resize(function() {
  9. footerHeight = $("footer").outerHeight(true);
  10. $('#container').css("padding-bottom", footerHeight + "px");
  11. //console.log(footerHeight)
  12. });
  13. //底部企业入驻
  14. var orgid = $.cookie('orgId');
  15. $("#cmpSet2").on("click", function() {
  16. if(orgid && orgid != "null" && orgid != null) {
  17. location.href = "cmp-portal/cmp-workspaces.html"
  18. } else {
  19. location.href = "cmp-portal/cmp-settled-reg.html"
  20. }
  21. })
  22. });
  23. //搜索框跳转页面
  24. $("#search").on("click", function() {
  25. var searchContent = $("#searchContent").val();
  26. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  27. });
  28. //enter绑定时间
  29. $("#searchContent").keydown(function(e) {
  30. if(e.which == 13) {
  31. var searchContent = $("#searchContent").val();
  32. console.log(searchContent);
  33. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  34. }
  35. })
  36. $("#hsearchContent").keydown(function(e) {
  37. if(e.which == 13) {
  38. var searchContent = $("#hsearchContent").val();
  39. console.log(searchContent);
  40. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  41. }
  42. })
  43. $("#hsearch").on("click", function() {
  44. var searchContent = $("#hsearchContent").val();
  45. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  46. });
  47. /*向下滚动时,header背景变半透明*/
  48. $(document).scroll(function() {
  49. var top = $(document).scrollTop();
  50. if(top == 0) {
  51. $(".navheader").removeClass("navhdown");
  52. } else {
  53. $(".navheader").addClass("navhdown");
  54. }
  55. if(top >= 300) {
  56. $(".content-left").css({
  57. "position": "fixed",
  58. "top": "80px"
  59. })
  60. } else {
  61. $(".content-left").css({
  62. "position": "static"
  63. })
  64. }
  65. });
  66. var userid;
  67. function exit() {
  68. $.cookie('userid', null);
  69. $.cookie('userAuth', null);
  70. $.cookie('userEmail', null);
  71. $.cookie('userMobilePhone', null);
  72. $.cookie('userName', null);
  73. $.cookie('userType', null);
  74. location.href = "index.html"
  75. }
  76. function valUser() {
  77. var userid = $.cookie('userid');
  78. var userAuth = $.cookie('userAuth');
  79. if(userid == undefined || userid.length == 0 || userid == "null" || userAuth == false) {
  80. location.href = "login.html";
  81. }
  82. }
  83. function GetQueryString(name) {
  84. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  85. var r = window.location.search.substr(1).match(reg);
  86. var context = "";
  87. if(r != null)
  88. context = r[2];
  89. reg = null;
  90. r = null;
  91. return context == null || context == "" || context == "undefined" ? "" : decodeURI(context);
  92. }
  93. /* function GetQueryString(name) {
  94. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  95. var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ��
  96. var context = "";
  97. if (r != null)
  98. context = r[2];
  99. reg = null;
  100. r = null;
  101. return context == null || context == "" || context == "undefined" ? "" : context;
  102. }*/
  103. function loginStatus() {
  104. userid = $.cookie('userid');
  105. userAuth = $.cookie('userAuth');
  106. authentication = $.cookie('authentication');
  107. if(userid && userid != "null" && userid != null) {
  108. if(userAuth == "false" && authentication == "null") {
  109. location.href = "loginInviteFirst.html";
  110. }
  111. if(userAuth == "true" && authentication == "null") {
  112. location.href = "fillinfo-select.html";
  113. }
  114. if(userAuth == "true" && authentication != "null") {
  115. $(".onlogin").show();
  116. $(".unlogin").hide();
  117. $(".portrait-p").on("click",function(){
  118. location.href="userInforShow.html?professorId="+userid;
  119. })
  120. $(".portrait-p").attr("src", "/images/head/" + userid + "_m.jpg");
  121. $(".portrait-p").load(function() { //判断图片是否加载,加载不成功默认有默认的图像
  122. })
  123. .error(function() {
  124. $(".portrait-p").attr("src", "/images/default-photo.jpg");
  125. });
  126. }
  127. } else {
  128. $(".unlogin").show();
  129. $(".onlogin").hide();
  130. }
  131. }
  132. //转换格式
  133. function changeTime(dealtime) {
  134. var s = dealtime;
  135. //console.log(s);
  136. if(dealtime.length == 8) {
  137. var y = s.substr(0, 4);
  138. var m = s.substr(4, 2);
  139. var d = s.substr(6, 2);
  140. var formatTime = y + "-" + m + "-" + d;
  141. return formatTime;
  142. } else {
  143. var y = s.substr(0, 4);
  144. var m = s.substr(4, 2);
  145. var d = s.substr(6, 2);
  146. var h = s.substr(8, 2);
  147. var minute = s.substr(10, 2);
  148. var formatTime = y + "-" + m + "-" + d + " " + h + ":" + minute;
  149. return formatTime;
  150. }
  151. }
  152. //******过滤特殊字符*******//
  153. function replaceStr(s) {
  154. var pattern = new RegExp("-");
  155. var rs = "";
  156. for(var i = 0; i < s.length; i++) {
  157. rs = rs + s.substr(i, 1).replace(pattern, '');
  158. }
  159. return rs;
  160. }
  161. //**********************//
  162. //根据内容的多少获取高度给父级设置高度
  163. function limitHeight() {
  164. var Length = $(".limitBox").length;
  165. for(var i = 0; i < Length; i++) {
  166. var limitheight = $(".limitwords").eq(i).height();
  167. console.log(limitheight);
  168. $(".limitBox").eq(i).css("height", limitheight);
  169. }
  170. }
  171. //根据用户输入的Email跳转到相应的电子邮箱首页
  172. var hash = {
  173. 'qq.com': 'http://mail.qq.com',
  174. 'gmail.com': 'http://mail.google.com',
  175. 'sina.com': 'http://mail.sina.com.cn',
  176. '163.com': 'http://mail.163.com',
  177. '126.com': 'http://mail.126.com',
  178. 'yeah.net': 'http://www.yeah.net/',
  179. 'sohu.com': 'http://mail.sohu.com/',
  180. 'tom.com': 'http://mail.tom.com/',
  181. 'sogou.com': 'http://mail.sogou.com/',
  182. '139.com': 'http://mail.10086.cn/',
  183. 'hotmail.com': 'http://www.hotmail.com',
  184. 'live.com': 'http://login.live.com/',
  185. 'live.cn': 'http://login.live.cn/',
  186. 'live.com.cn': 'http://login.live.com.cn',
  187. '189.com': 'http://webmail16.189.cn/webmail/',
  188. 'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
  189. 'yahoo.cn': 'http://mail.cn.yahoo.com/',
  190. 'eyou.com': 'http://www.eyou.com/',
  191. '21cn.com': 'http://mail.21cn.com/',
  192. '188.com': 'http://www.188.com/',
  193. 'ustb.edu.cn': 'http://mail.ustb.edu.cn/',
  194. 'foxmail.coom': 'http://www.foxmail.com'
  195. };
  196. //轮播滚动函数
  197. function Carousel(inde, num, show, childcount, obj, next, prev) {
  198. var tapnum = 0; //按钮可点击次数
  199. if(childcount > num) {
  200. next.css("display", "block");
  201. prev.css("display", "none");
  202. } else {
  203. next.css("display", "none");
  204. prev.css("display", "none");
  205. }
  206. next.click(function() {
  207. if(!obj.is(":animated")) {
  208. if(num < childcount) {
  209. tapnum++;
  210. prev.css("display", "block");
  211. if(tapnum == childcount - show) {
  212. next.css("display", "none");
  213. }
  214. num++;
  215. obj.animate({
  216. left: "-=212px"
  217. }, 600);
  218. }
  219. }
  220. });
  221. prev.click(function() {
  222. if(!obj.is(":animated")) {
  223. if(num > inde) {
  224. tapnum--;
  225. next.css("display", "block");
  226. if(tapnum == 0) {
  227. prev.css("display", "none");
  228. }
  229. num--;
  230. obj.animate({
  231. left: "+=212px"
  232. }, 600);
  233. }
  234. }
  235. });
  236. }
  237. //评价字数限制
  238. //字数限制函数
  239. function limitTextCountFn(TextAreaId, countContainerId, count) {
  240. var curLength = $(TextAreaId).val().length;
  241. if(curLength > count) {
  242. var num = $(TextAreaId).val().substr(0, count);
  243. $(TextAreaId).val(num);
  244. } else {
  245. $(countContainerId).text(count - $(TextAreaId).val().length);
  246. }
  247. };
  248. //咨询申请主题字数限制函数
  249. function titleLimitFontCountFn() {
  250. var curLength = $("#consultTitle").val().length;
  251. if(curLength > 20) {
  252. var num = $("#consultTitle").val().substr(0, 20);
  253. $("#consultTitle").val(num);
  254. }
  255. };
  256. function showmenu() {
  257. $("#li_show").css("display", "block");
  258. }
  259. /*选择省份*/
  260. $(document).on("click", "#Province li a", function() {
  261. var aVal = $(this).text();
  262. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  263. $(this).parent().parent().parent().find('input[name=cho_Province]').val(aVal);
  264. if($("#oprovince").text() == "请选择省/直辖市") {
  265. $("#oprovince").removeClass("mr_select");
  266. $("#ocity").removeClass("mr_select");
  267. } else {
  268. $("#oprovince").addClass("mr_select");
  269. $("#ocity").removeClass("mr_select");
  270. }
  271. });
  272. /*选择城市填充js */
  273. $(document).on("click", "#City li a", function() {
  274. var aVal = $(this).text();
  275. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  276. $(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
  277. if($("#ocity").text() == "请选择城市") {
  278. $("#ocity").removeClass("mr_select");
  279. } else {
  280. $("#ocity").addClass("mr_select");
  281. }
  282. });
  283. /*下拉select选择js */
  284. function seleCo(obj){
  285. var sleTd=$(obj).val();
  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 = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
  523. if(y != myDate.getFullYear()) {
  524. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
  525. }
  526. } else {
  527. formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  528. if(y != myDate.getFullYear()) {
  529. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  530. }
  531. }
  532. return formatTime;
  533. }
  534. /*判断是否收藏资源文章或者是否关注专家*/
  535. function ifcollectionAbout(watchObject, sel,num) {
  536. var that=sel;
  537. $.ajax('/ajax/watch/hasWatch', {
  538. data: {
  539. "professorId": userid,
  540. "watchObject": watchObject
  541. },
  542. dataType: 'json', //数据格式类型
  543. type: 'get', //http请求类型
  544. timeout: 10000,
  545. async: false,
  546. success: function(data) {
  547. if(data.success && data.data != null) {
  548. if(num == "1" || num == "6") { //已关注专家
  549. $(that).addClass("attenedSpan");
  550. $(that).text("已关注");
  551. } else { //已收藏资源或文章
  552. $(that).removeClass("icon-collect");
  553. $(that).addClass("icon-collected");
  554. }
  555. } else {
  556. if(num == "1" || num == "6") { //关注专家
  557. $(that).removeClass("attenedSpan");
  558. $(that).text("关注");
  559. } else { //收藏资源或文章
  560. $(that).addClass("icon-collect");
  561. $(that).removeClass("icon-collected");//
  562. }
  563. }
  564. },
  565. error: function(data) {
  566. $.MsgBox.Alert('提示', "服务器链接超时");
  567. }
  568. });
  569. }
  570. /*收藏资源、文章或者关注专家*/
  571. function collectionAbout(watchObject,sel, num) {
  572. var that=sel;
  573. $.ajax('/ajax/watch', {
  574. data: {
  575. "professorId": userid,
  576. "watchObject": watchObject,
  577. "watchType": num
  578. },
  579. dataType: 'json', //数据格式类型
  580. type: 'POST', //http请求类型
  581. timeout: 10000,
  582. async: false,
  583. success: function(data) {
  584. if(data.success) {
  585. console.log(data)
  586. if(num == "1" || num == "6") {
  587. $(that).addClass("attenedSpan");
  588. $(that).text("已关注");
  589. } else {
  590. $(that).removeClass("icon-collect");
  591. $(that).addClass("icon-collected");
  592. }
  593. }
  594. },
  595. error: function(data) {
  596. $.MsgBox.Alert('提示', "服务器链接超时");
  597. }
  598. });
  599. }
  600. /*取消收藏资源、文章或者取消关注专家*/
  601. function cancelCollectionAbout(watchObject,sel,num) {
  602. var that=sel;
  603. $.ajax({
  604. url: '/ajax/watch/delete',
  605. data: {
  606. professorId: userid,
  607. watchObject: watchObject
  608. },
  609. dataType: 'json', //数据格式类型
  610. type: 'post', //http请求类型
  611. timeout: 10000,
  612. async: true,
  613. success: function(data) {
  614. console.log(data.success)
  615. if(num == "1" || num == "6") { //关注专家
  616. $(that).removeClass("attenedSpan");
  617. $(that).text("关注");
  618. } else { //收藏资源或文章
  619. $(that).addClass("icon-collect");
  620. $(that).removeClass("icon-collected");
  621. }
  622. },
  623. error: function(data) {
  624. $.MsgBox.Alert('提示', "服务器链接超时");
  625. }
  626. });
  627. }
  628. //企业规模
  629. var orgSizeShow = {
  630. '1': '50人以内',
  631. '2': '50-100人',
  632. '3': '100-200人',
  633. '4': '200-500人',
  634. '5': '500-1000人',
  635. '6': '1000人以上'
  636. }
  637. //企业类型
  638. var orgTypeShow = {
  639. "2": "上市企业",
  640. "3": "外资企业",
  641. "4": "合资企业",
  642. "5": "独资企业",
  643. "6": "个体经营",
  644. "7": "政府机构",
  645. "8": "公益组织",
  646. "9": "协会学会",
  647. "10": "新闻媒体",
  648. "11": "教育机构",
  649. "undefined":""
  650. }
  651. //学位
  652. var eduDegree = {
  653. "1": "博士",
  654. "2": "硕士",
  655. "3": "学士",
  656. "4": "大专",
  657. "5": "其他"
  658. }
  659. //栏目
  660. var columnType = {
  661. "1":{
  662. fullName:"个人原创",
  663. shortName:"原创"
  664. },
  665. "2":{
  666. fullName:"企业原创",
  667. shortName:"原创"
  668. },
  669. "3":{
  670. fullName:"前沿动态",
  671. shortName:"前沿"
  672. },
  673. "4":{
  674. fullName:"学术经验",
  675. shortName:"经验"
  676. },
  677. "5":{
  678. fullName:"分析检测",
  679. shortName:"检测"
  680. },
  681. "6":{
  682. fullName:"会议培训",
  683. shortName:"会议"
  684. },
  685. "7":{
  686. fullName:"科袖访谈",
  687. shortName:"访谈"
  688. },
  689. "8":{
  690. fullName:"招聘招生",
  691. shortName:"招聘"
  692. },
  693. "9":{
  694. fullName:"重大新闻",
  695. shortName:"新闻"
  696. }
  697. }
  698. //需求的费用预算
  699. var demandCost = {
  700. '1': '1万元以内',
  701. '2': '1-5万元',
  702. '3': '5-10万元',
  703. '4': '10-20万元',
  704. '5': '20-50万元',
  705. '6': '50万元以上'
  706. }
  707. //需求的预期时长
  708. var demandDuration = {
  709. '1': '1个月内',
  710. '2': '1-3个月',
  711. '3': '3-6个月',
  712. '4': '6-12个月',
  713. '5': '1年以上'
  714. }
  715. //反馈意见成功
  716. function backSuccessed(){
  717. $(".correctCon").val("");
  718. $(".correctSubmit").attr("disabled",true);
  719. $(".correctSubmit").parents(".correctBlock").fadeOut();
  720. $.MsgBox.Alert('提示', '感谢您的反馈,我们马上处理。');
  721. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  722. }
  723. function hotKey(sel, num) {
  724. $(sel).bind({
  725. paste: function(e) {
  726. var pastedText;
  727. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  728. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  729. else  {            
  730. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  731. }
  732. $(this).val(pastedText);
  733. var $this = $(this);
  734. setTimeout(function() {
  735. if($this.val().trim()) {
  736. $this.siblings("button").show();
  737. } else {
  738. $this.siblings("button").hide();
  739. }
  740. }, 1);
  741. e.preventDefault();
  742. },
  743. cut: function(e) {
  744. var $this = $(this);
  745. setTimeout(function() {
  746. if($this.val().trim()) {
  747. $this.siblings("button").show();
  748. } else {
  749. $this.siblings("button").hide();
  750. }
  751. }, 1);
  752. },
  753. blur: function() {
  754. var $this = $(this);
  755. setTimeout(function() {
  756. $this.siblings(".keydrop").hide();
  757. }, 500)
  758. },
  759. focus: function() {
  760. $(this).siblings(".keydrop").show();
  761. },
  762. keyup: function(e) {
  763. var ti=$(this).val();
  764. var $t=this;
  765. $t.comr=ti;
  766. var $this=$(this);
  767. if($(this).val().trim()) {
  768. $(this).siblings("button").show();
  769. var lNum = $.trim($(this).val()).length;
  770. if(0 < lNum) {
  771. setTimeout(function(){
  772. if( ti===$t.comr && ti!== $t.comrEnd) {
  773. var tt=ti;
  774. $t.comrEnd=tt;
  775. $("#addKeyword").show();
  776. $.ajax({
  777. "url": "/ajax/dataDict/qaHotKey",
  778. "type": "GET",
  779. "success": function(data) {
  780. console.log(data);
  781. if(data.success) {
  782. if($t.comrEnd==tt) {
  783. if(data.data.length == 0) {
  784. $this.siblings(".keydrop").addClass("displayNone");
  785. $this.siblings(".keydrop").find("ul").html("");
  786. } else {
  787. $this.siblings(".keydrop").removeClass("displayNone");
  788. var oSr = "";
  789. for(var i = 0; i < Math.min(data.data.length,5); i++) {
  790. oSr += '<li>' + data.data[i].caption + '<div class="closeThis"></div></li>';
  791. }
  792. $this.siblings(".keydrop").find("ul").html(oSr);
  793. }
  794. }
  795. } else {
  796. $this.siblings(".keydrop").addClass("displayNone");
  797. $this.siblings(".keydrop").find("ul").html("");
  798. }
  799. },
  800. "data": {
  801. "key": $this.val()
  802. },
  803. dataType: "json",
  804. 'error': function() {
  805. $.MsgBox.Alert('提示', '服务器连接超时!');
  806. }
  807. });
  808. }
  809. },500);
  810. }
  811. } else {
  812. $(this).siblings("button").hide();
  813. $(this).siblings(".keydrop").addClass("displayNone");
  814. $(this).siblings(".keydrop").find("ul").html("");
  815. }
  816. }
  817. })
  818. $(".keydrop").on("click", "li", function() {
  819. var oValue = $(this).text();
  820. var oJudge = $(this).parents(".col-w-12").siblings().find("ul.ulspace li");
  821. var addNum = $(this).parents(".keydrop").siblings("input").attr("data-num");
  822. for(var i = 0; i < oJudge.length; i++) {
  823. if(oValue == oJudge[i].innerText) {
  824. $.MsgBox.Alert('提示', '添加内容不能重复');
  825. return;
  826. }
  827. }
  828. $(this).parents(".col-w-12").siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  829. $(this).parents(".keydrop").siblings("input").val("");
  830. $(this).parents(".keydrop").siblings("button").hide();
  831. if(oJudge.length == addNum - 1) {
  832. $(this).parents(".keydrop").siblings("input").val("");
  833. $(this).parents(".col-w-12").hide();
  834. }
  835. $(this).parent("ul").html("")
  836. })
  837. if(num == 1) {
  838. return;
  839. } else {
  840. /*添加*/
  841. $(".addButton").click(function() {
  842. var oValue = $(this).siblings("input").val().trim();
  843. var oJudge = $(this).parent().siblings().find("ul.ulspace li");
  844. var addContent = $(this).siblings("input").attr("data-pro");
  845. var addNum = $(this).siblings("input").attr("data-num");
  846. var addfontSizeNum = $(this).siblings("input").attr("data-fontSizeN");
  847. if(!oValue) {
  848. $.MsgBox.Alert('提示', '请先填写内容');
  849. return;
  850. }
  851. if(oValue.length > addfontSizeNum) {
  852. $.MsgBox.Alert('提示', addContent);
  853. return;
  854. }
  855. for(var i = 0; i < oJudge.length; i++) {
  856. if(oValue == oJudge[i].innerText) {
  857. $.MsgBox.Alert('提示', '添加内容不能重复');
  858. return;
  859. }
  860. }
  861. $(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  862. $(this).hide();
  863. $(this).siblings("input").val("");
  864. if(oJudge.length == addNum - 1) {
  865. $(this).val("").parents(".col-w-12").hide();
  866. }
  867. $(this).siblings(".keydrop").find("ul").html("");
  868. })
  869. }
  870. }
  871. //带有限制字数的多行文本框
  872. function limitObj(obj,maxNum){
  873. $(obj).bind({
  874. paste: function(e) {
  875. if($(this).val().length==""){
  876. $(this).parent().siblings(".btnModel").attr("disabled", true);
  877. }else{
  878. $(this).parent().siblings(".btnModel").attr("disabled", false);
  879. }
  880. var pastedText;
  881. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  882. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  883. else  {            
  884. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  885. }
  886. $(this).val(pastedText);
  887. setTimeout(function() {
  888. $(this).siblings().find("em").text($(obj).val().length);
  889. }, 1);
  890. e.preventDefault();
  891. },
  892. cut: function(e) {
  893. if($(this).val().length==""){
  894. $(this).parent().siblings(".btnModel").attr("disabled", true);
  895. }else{
  896. $(this).parent().siblings(".btnModel").attr("disabled", false);
  897. }
  898. setTimeout(function() {
  899. $(obj).siblings().find("em").text($(obj).val().length);
  900. }, 1);
  901. },
  902. keyup: function(e) {
  903. if($(this).val().length==""){
  904. $(this).parent().siblings(".btnModel").attr("disabled", true);
  905. }else{
  906. $(this).parent().siblings(".btnModel").attr("disabled", false);
  907. }
  908. if($(this).val().length > maxNum) {
  909. $(obj).val($(obj).val().substring(0, maxNum));
  910. e.preventDefault();
  911. }
  912. setTimeout(function() {
  913. $(obj).siblings().find("em").text($(obj).val().length);
  914. }, 1);
  915. }
  916. });
  917. }
  918. 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", "-", "_"];
  919. var d64 = {
  920. "0": 0,
  921. "1": 1,
  922. "2": 2,
  923. "3": 3,
  924. "4": 4,
  925. "5": 5,
  926. "6": 6,
  927. "7": 7,
  928. "8": 8,
  929. "9": 9,
  930. "A": 10,
  931. "B": 11,
  932. "C": 12,
  933. "D": 13,
  934. "E": 14,
  935. "F": 15,
  936. "G": 16,
  937. "H": 17,
  938. "I": 18,
  939. "J": 19,
  940. "K": 20,
  941. "L": 21,
  942. "M": 22,
  943. "N": 23,
  944. "O": 24,
  945. "P": 25,
  946. "Q": 26,
  947. "R": 27,
  948. "S": 28,
  949. "T": 29,
  950. "U": 30,
  951. "V": 31,
  952. "W": 32,
  953. "X": 33,
  954. "Y": 34,
  955. "Z": 35,
  956. "a": 36,
  957. "b": 37,
  958. "c": 38,
  959. "d": 39,
  960. "e": 40,
  961. "f": 41,
  962. "g": 42,
  963. "h": 43,
  964. "i": 44,
  965. "j": 45,
  966. "k": 46,
  967. "l": 47,
  968. "m": 48,
  969. "n": 49,
  970. "o": 50,
  971. "p": 51,
  972. "q": 52,
  973. "r": 53,
  974. "s": 54,
  975. "t": 55,
  976. "u": 56,
  977. "v": 57,
  978. "w": 58,
  979. "x": 59,
  980. "y": 60,
  981. "z": 61,
  982. "-": 62,
  983. "_": 63
  984. };
  985. function s16to64(s) {
  986. var out, idx, n1, n2, n3;
  987. idx = s.length - 1;
  988. out = "";
  989. while(idx >= 0) {
  990. n1 = d64[s.charAt(idx--)];
  991. if(idx < 0) {
  992. out = r64[n1] + out;
  993. break;
  994. }
  995. n2 = d64[s.charAt(idx--)];
  996. if(idx < 0) {
  997. out = r64[(n2 >>> 2)] + r64[((n2 & 0x3) << 4) + n1] + out;
  998. break;
  999. }
  1000. n3 = d64[s.charAt(idx--)];
  1001. out = r64[(n2 >>> 2) + (n3 << 2)] + r64[((n2 & 0x3) << 4) + n1] + out;
  1002. }
  1003. return out;
  1004. }
  1005. function s64to16(s) {
  1006. var out, idx, n1, n2;
  1007. idx = s.length - 1;
  1008. out = "";
  1009. while(idx >= 0) {
  1010. n1 = d64[s.charAt(idx--)];
  1011. if(idx < 0) {
  1012. out = r64[n1 >>> 4] + r64[n1 & 0xF] + out;
  1013. break;
  1014. }
  1015. n2 = d64[s.charAt(idx--)];
  1016. out = r64[(n2 >>> 2)] + r64[(n1 >>> 4) + ((n2 & 0x3) << 2)] + r64[n1 & 0xF] + out;
  1017. }
  1018. if(out.length>32) {
  1019. return out.substring(1);
  1020. }
  1021. return out;
  1022. }
  1023. //发现上方轮播
  1024. var bannerRotate = {// banner rotating
  1025. _time: 3000,
  1026. _i: 0,
  1027. _interval: null,
  1028. _navId: "#slide-tab",
  1029. _navBox: "#slide-list",
  1030. bannerShow: function() {
  1031. $(this._navId).find("li").removeClass("slide-tab-item-active");
  1032. $(this._navId).find("li:eq("+this._i+")").addClass("slide-tab-item-active");
  1033. $(this._navBox).find("li").removeClass("slide-item-active");
  1034. $(this._navBox).find("li:eq("+this._i+")").addClass("slide-item-active");
  1035. },
  1036. bannerStart:function() {
  1037. var _this = this;
  1038. _this._interval = setInterval(function() {
  1039. if(_this._i >= 4) {
  1040. _this._i = 0;
  1041. }
  1042. else {
  1043. _this._i++;
  1044. }
  1045. _this.bannerShow();
  1046. }, _this._time);
  1047. },
  1048. bannerInit: function() {
  1049. var _this = this;
  1050. _this.bannerStart();
  1051. $(_this._navId).find("li").bind("mouseover", function() {
  1052. clearInterval(_this._interval);
  1053. _this._i = $(this).index();
  1054. _this.bannerShow();
  1055. _this.bannerStart();
  1056. });
  1057. }
  1058. };
  1059. var currentdate;
  1060. function getNowFormatDate(num) {
  1061. var date = new Date();
  1062. var seperator1 = "-";
  1063. var seperator2 = ":";
  1064. var month = date.getMonth() + 1;
  1065. var strDate = date.getDate();
  1066. var getHours = date.getHours();
  1067. var getMinutes = date.getMinutes();
  1068. if (month >= 1 && month <= 9) {
  1069. month = "0" + month;
  1070. }
  1071. if (strDate >= 0 && strDate <= 9) {
  1072. strDate = "0" + strDate;
  1073. }
  1074. if (getMinutes >= 0 && getMinutes <= 9) {
  1075. getMinutes = "0" + getMinutes;
  1076. }
  1077. if (getHours >= 0 && getHours <= 9) {
  1078. getHours = "0" + getHours;
  1079. }
  1080. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
  1081. + " " + getHours + seperator2 + getMinutes
  1082. if(num==1){
  1083. currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
  1084. }
  1085. return currentdate;
  1086. }