portal html css js resource

common.js 34KB

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