portal html css js resource

common.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. $(document).ready(function(){
  2. $(".unlogin").show();
  3. $(".onlogin").hide();
  4. var footerHeight = $("footer").outerHeight(true);
  5. $('#container').css("padding-bottom", footerHeight +"px" );
  6. //窗口大小变更事件
  7. $(window).resize(function() {
  8. footerHeight=$("footer").outerHeight(true);
  9. $('#container').css("padding-bottom", footerHeight +"px" );
  10. //console.log(footerHeight)
  11. });
  12. //底部企业入驻
  13. var orgid = $.cookie('orgId');
  14. $("#cmpSet2").on("click",function(){
  15. if (orgid && orgid != "null" && orgid != null) {
  16. location.href="cmp-portal/cmp-workspaces.html"
  17. }else{
  18. location.href="cmp-portal/cmp-settled-reg.html"
  19. }
  20. })
  21. });
  22. //搜索框跳转页面
  23. $("#search").on("click", function() {
  24. var searchContent = $("#searchContent").val();
  25. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  26. });
  27. //enter绑定时间
  28. $("#searchContent").keydown(function(e){
  29. if(e.which==13) {
  30. var searchContent = $("#searchContent").val();
  31. console.log(searchContent);
  32. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  33. }
  34. })
  35. $("#hsearchContent").keydown(function(e){
  36. if(e.which==13) {
  37. var searchContent = $("#hsearchContent").val();
  38. console.log(searchContent);
  39. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  40. }
  41. })
  42. $("#hsearch").on("click", function() {
  43. var searchContent = $("#hsearchContent").val();
  44. location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
  45. });
  46. /*向下滚动时,header背景变半透明*/
  47. $(document).scroll(function() {
  48. var top = $(document).scrollTop();
  49. if (top == 0) {
  50. $(".navheader").removeClass("navhdown");
  51. } else {
  52. $(".navheader").addClass("navhdown");
  53. }
  54. if (top >= 300) {
  55. $(".content-left").css({
  56. "position": "fixed",
  57. "top": "80px"
  58. })
  59. } else {
  60. $(".content-left").css({
  61. "position": "static"
  62. })
  63. }
  64. });
  65. var userid;
  66. function exit(){
  67. $.cookie('userid', null);
  68. $.cookie('userAuth', null);
  69. $.cookie('userEmail', null);
  70. $.cookie('userMobilePhone', null);
  71. $.cookie('userName', null);
  72. $.cookie('userType', null);
  73. location.href="index.html"
  74. }
  75. function valUser(){
  76. var userid = $.cookie('userid');
  77. var userAuth = $.cookie('userAuth');
  78. if(userid == undefined || userid.length==0 || userid == "null" || userAuth == false){
  79. location.href="login.html";
  80. }
  81. }
  82. function GetQueryString(name) {
  83. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  84. var r = window.location.search.substr(1).match(reg);
  85. var context = "";
  86. if (r != null)
  87. context = r[2];
  88. reg = null;
  89. r = null;
  90. return context == null || context == "" || context == "undefined" ? "" : decodeURI(context);
  91. }
  92. /* function GetQueryString(name) {
  93. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  94. var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ��
  95. var context = "";
  96. if (r != null)
  97. context = r[2];
  98. reg = null;
  99. r = null;
  100. return context == null || context == "" || context == "undefined" ? "" : context;
  101. }*/
  102. function loginStatus(){
  103. userid = $.cookie('userid');
  104. userAuth = $.cookie('userAuth');
  105. authentication = $.cookie('authentication');
  106. if(userid && userid != "null" && userid != null){
  107. if(userAuth == "false" && authentication == "null"){
  108. location.href="loginInviteFirst.html";
  109. }
  110. if(userAuth == "true" && authentication == "null"){
  111. location.href="fillinfo-select.html";
  112. }
  113. if(userAuth == "true" && authentication != "null"){
  114. $(".onlogin").show();
  115. $(".unlogin").hide();
  116. $(".portrait-p").attr("src","/images/head/"+userid+"_m.jpg");
  117. $(".portrait-p").load(function(){//判断图片是否加载,加载不成功默认有默认的图像
  118. })
  119. .error(function(){
  120. $(".portrait-p").attr("src","/images/default-photo.jpg");
  121. });
  122. }
  123. }else{
  124. $(".unlogin").show();
  125. $(".onlogin").hide();
  126. }
  127. }
  128. //转换格式
  129. function changeTime(dealtime){
  130. var s = dealtime;
  131. //console.log(s);
  132. if(dealtime.length==8){
  133. var y = s.substr(0,4);
  134. var m = s.substr(4,2);
  135. var d = s.substr(6,2);
  136. var formatTime = y+"-"+m+"-"+d;
  137. return formatTime;
  138. }
  139. else
  140. {
  141. var y = s.substr(0,4);
  142. var m = s.substr(4,2);
  143. var d = s.substr(6,2);
  144. var h = s.substr(8,2);
  145. var minute = s.substr(10,2);
  146. var formatTime = y+"-"+m+"-"+d+" "+h+":"+minute;
  147. return formatTime;
  148. }
  149. }
  150. //******过滤特殊字符*******//
  151. function replaceStr(s)
  152. {
  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. }
  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. /*选择城市填充js */
  260. $(document).on("click","#City 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_City]').val(aVal);
  264. });
  265. //咨询 专家信息接口函数
  266. function concultProInfo(professorId){
  267. $.ajax({
  268. url:"/ajax/professor/editBaseInfo/"+professorId,
  269. type:"get",
  270. data : {"id":professorId},
  271. contentType : "application/x-www-form-urlencoded",
  272. success:function(response){
  273. //console.log(response);
  274. var myData = response["data"];
  275. $("#professorName").html(myData["name"]);
  276. if(myData["title"]){
  277. $("#professorTitle").html(myData["title"]+' ');
  278. }
  279. if(myData["department"]){
  280. $("#profDepartment").html(myData["department"]+' ');
  281. }
  282. if(myData["orgName"]){
  283. $("#profOrganization").html(myData["orgName"]+' ');
  284. }
  285. if(myData["address"]){
  286. $("#profAdress").html(myData["address"]);
  287. }
  288. console.log(myData["consultCount"])
  289. if(!myData["consultCount"]){
  290. $("#starLevel").hide();
  291. }
  292. $("#byConsultConut").html(myData["consultCount"]);
  293. $("#sendConsultBtn").attr("proId",myData["id"]);
  294. //星级
  295. var startConut = parseInt(myData["starLevel"]);
  296. if(myData["consultCount"]){
  297. if(!startConut){
  298. $(".evastarbox2").hide();
  299. }
  300. }
  301. for(var i = 0; i < startConut; i ++){
  302. $("#starLevel .evastar2").eq(i).addClass("addStar");
  303. }
  304. //认证
  305. var oSty=autho(myData.authType,myData.orgAuth,myData.authStatus);
  306. $("#proModifyN").addClass(oSty.sty);
  307. $("#proModifyN").attr("title",oSty.title);
  308. //头像
  309. if(myData["hasHeadImage"] == 0){
  310. $("#prohead").attr("src","images/default-photo.jpg");
  311. }
  312. else {
  313. $("#prohead").attr("src","images/head/"+myData["id"]+"_l.jpg");
  314. }
  315. },
  316. error:function(error){
  317. $.MsgBox.Alert("message","请求数据失败");
  318. }
  319. });
  320. };
  321. //发送咨询
  322. function sendConsultHandler(professorId){
  323. var professorId = professorId;
  324. var consult_type = $(".clicknow").text();//咨询类型
  325. var consult_title = $("#consultTitle").val();//咨询主题
  326. var consult_content = $("#consultcontent").val();//咨询内容
  327. var consultStr = {
  328. "consultType":consult_type,
  329. "consultTitle":consult_title,
  330. "consultContant":consult_content,
  331. "professorId":professorId,
  332. "consultantId":userid
  333. };
  334. if(consult_type == '' || consult_title == '' || consult_content == ''){
  335. $.MsgBox.Alert("消息提醒","请填写完整");
  336. };
  337. if(consult_type == ''){
  338. $.MsgBox.Alert("消息提醒","请选择联系目的");
  339. }
  340. if(consult_title == ''){
  341. $.MsgBox.Alert("消息提醒","请填写咨询目的");
  342. }
  343. if(consult_content == ''){
  344. $.MsgBox.Alert("消息提醒","请填写咨询内容");
  345. }
  346. if(userid && userid != null && userid != "null" && consult_type != '' &&
  347. consult_title != '' && consult_content != ''
  348. ){
  349. $.ajax({
  350. "url" :"/ajax/consult",
  351. "type" : "post",
  352. //传值:咨询类型、主题、内容、专家id、申请人id
  353. "data" : consultStr,
  354. "contentType" : "application/x-www-form-urlencoded",
  355. "dataType" : "json",
  356. "success" : function(response) {
  357. console.log(response);
  358. },
  359. "error":function (){
  360. $.MsgBox.Alert("消息提醒","咨询申请失败");
  361. },
  362. "complete":function(){
  363. //$(".consultapply").remove();
  364. $(".blackcover").remove();
  365. $("body").css("position","");
  366. $.MsgBox.Alert("消息提醒","咨询申请成功");
  367. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  368. },
  369. });
  370. }
  371. };
  372. /*标志*/
  373. function autho() {
  374. if(arguments[0] == 1) {
  375. return {
  376. "sty": "authicon-pro",
  377. "title": "科袖认证专家"
  378. }
  379. } else {
  380. if(arguments[1] == 1) {
  381. return {
  382. "sty": "authicon-staff-ok",
  383. "title": "企业认证员工"
  384. }
  385. } else {
  386. if(arguments[2] == 3) {
  387. return {
  388. "sty": "authicon-real",
  389. "title": "实名认证用户"
  390. }
  391. } else {
  392. return {
  393. "sty": "e",
  394. "title": " "
  395. }
  396. }
  397. }
  398. }
  399. }
  400. //获取用户类型
  401. var ifuser = ifUserType();
  402. function ifUserType(pa){
  403. if(pa) {
  404. var useridtype =pa;
  405. }else{
  406. var useridtype = $.cookie('userid');
  407. }
  408. var authType2,authentication2;
  409. if (useridtype && useridtype != "null" && useridtype != null) {
  410. $.ajax({
  411. "url" :"/ajax/professor/auth",
  412. "type" : "GET",
  413. "data" :{"id":useridtype} ,
  414. "dataType" : "json",
  415. "async":false,
  416. "success" : function(data) {
  417. if(data.success){
  418. authType2 = data.data.authType;
  419. authentication2 = data.data.authentication;
  420. }
  421. }
  422. });
  423. }
  424. return{
  425. "authType2":authType2,
  426. "authentication2":authentication2,
  427. }
  428. }
  429. //工作台判断用户类型显示用户权限
  430. if ($.cookie('userName') && $.cookie('userName') != "null" && $.cookie('userName') != null) {
  431. if(ifuser.authType2==0){
  432. $("#repalyf").addClass("repalyf");
  433. /*点击未读咨询消息查看*/
  434. $("#gozixu").on("click", function() {
  435. window.location.href = "myConsult.html";
  436. })
  437. }else{
  438. $(".nohide").show();
  439. /*点击未读咨询消息查看*/
  440. $("#gozixu").on("click", function() {
  441. window.location.href = "consult.html";
  442. })
  443. }
  444. }
  445. /*多行文本框样式(带有限制数字)模拟focus效果*/
  446. $(".msgContbox textarea").focus(function(){
  447. $(this).parent().css("border-color","#ff9900");
  448. }).blur(function(){
  449. $(this).parent().css("border-color","#E5E5E5");
  450. })
  451. //时间显示规则
  452. function commenTime(startTime){
  453. var nowTimg = new Date();
  454. var startdate = new Date();
  455. startdate.setFullYear(parseInt(startTime.substring(0,4)));
  456. startdate.setMonth(parseInt(startTime.substring(4,6))-1);
  457. startdate.setDate(parseInt(startTime.substring(6,8)));
  458. startdate.setHours(parseInt(startTime.substring(8,10)));
  459. startdate.setMinutes(parseInt(startTime.substring(10,12)));
  460. startdate.setSeconds(parseInt(startTime.substring(12,14)));
  461. var date3=nowTimg.getTime()-startdate.getTime(); //时间差的毫秒数
  462. var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  463. var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
  464. if(date3 < 60000){
  465. return "刚刚";
  466. }else if(date3 >= 60000 && date3 < 3600000){
  467. return minutes + "分钟前";
  468. }else if(date3 >= 3600000 && date3 < 86400000){
  469. return hours + "小时前";
  470. }else if(date3 >= 86400000 && date3 < 172800000){
  471. return "昨天 " + startTime.substring(8,10) + ":" +startTime.substring(10,12);
  472. }else if(date3 >= 172800000 && date3 < 31536000000){
  473. 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);
  474. }
  475. else{
  476. 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);
  477. }
  478. }
  479. /*时间转换*/
  480. function TimeTr(dealtime) {
  481. var myDate = new Date();
  482. var s = dealtime;
  483. var y = s.substr(0, 4);
  484. var m = s.substr(4, 2);
  485. var d = s.substr(6, 2);
  486. var h = s.substr(8, 2);
  487. var minute = s.substr(10, 2);
  488. var formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "")+ "日 " + h + ":" + minute;
  489. if(y != myDate.getFullYear()){
  490. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "")+ "日 " + h + ":" + minute;
  491. }
  492. return formatTime;
  493. }