portal html css js resource

common.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. $(document).ready(function(){
  2. $(".unlogin").show();
  3. $(".onlogin").hide();
  4. //加载页面时,判断是否登陆
  5. /*var userid = $.cookie("userid");
  6. if (userid && userid != "null" && userid != null) {
  7. $(".myWorkspace").attr("href","workspaces.html?"+userid);
  8. loginStatus();
  9. }*/
  10. var footerHeight = $("footer").outerHeight(true);
  11. $('#container').css("padding-bottom", footerHeight +"px" );
  12. //窗口大小变更事件
  13. $(window).resize(function() {
  14. footerHeight=$("footer").outerHeight(true);
  15. $('#container').css("padding-bottom", footerHeight +"px" );
  16. //console.log(footerHeight)
  17. });
  18. //底部企业入驻
  19. var orgid = $.cookie('orgId');
  20. $("#cmpSet2").on("click",function(){
  21. if (orgid && orgid != "null" && orgid != null) {
  22. location.href="cmp-portal/cmp-workspaces.html"
  23. }else{
  24. location.href="cmp-portal/cmp-settled-reg.html"
  25. }
  26. })
  27. });
  28. //搜索框跳转页面
  29. function synContent(type) {
  30. if (type == 1) {
  31. $("#searchContent").val($("#hsearchContent").val());
  32. } else {
  33. $("#hsearchContent").val($("#searchContent").val());
  34. }
  35. }
  36. $("#hsearchContent").blur(function() {
  37. synContent(1);
  38. });
  39. $("#searchContent").blur(function() {
  40. synContent(2);
  41. });
  42. var lookFor = 0;
  43. $("#lookFor ul li").on("click",function(){
  44. lookFor=$(this).index();
  45. console.log(lookFor);
  46. });
  47. $("#search").on("click", function() {
  48. var searchContent = $("#searchContent").val();
  49. location.href = "search.html?searchContent=" + encodeURI(searchContent)+"&lookFor=" + lookFor;
  50. });
  51. //enter绑定时间
  52. $("#searchContent").keydown(function(e){
  53. if(e.which==13) {
  54. synContent(2);
  55. var searchContent = $("#searchContent").val();
  56. console.log(searchContent);
  57. location.href = "search.html?searchContent=" + encodeURI(searchContent)+"&lookFor=" + lookFor;
  58. }
  59. })
  60. $("#hsearchContent").keydown(function(e){
  61. if(e.which==13) {
  62. synContent(1);
  63. var searchContent = $("#hsearchContent").val();
  64. console.log(searchContent);
  65. location.href = "search.html?searchContent=" + encodeURI(searchContent);
  66. }
  67. })
  68. $("#hsearch").on("click", function() {
  69. var searchContent = $("#hsearchContent").val();
  70. location.href = "search.html?searchContent=" + encodeURI(searchContent);
  71. });
  72. /*向下滚动时,header背景变半透明*/
  73. $(document).scroll(function() {
  74. var top = $(document).scrollTop();
  75. // if (top == 0) {
  76. // $("#header").addClass("firstL");
  77. // } else {
  78. // $("#header").addClass("firstB").removeClass("firstL");
  79. //// $("#header").removeClass("firstL").addClass("firstH");
  80. //
  81. // }
  82. // if (top != 0) {
  83. // $(".searchbox").fadeIn(1000);
  84. //
  85. // } else {
  86. // $(".searchbox").fadeOut(1000);
  87. // }
  88. //小搜索框滚动大于等于350,显示在头部
  89. // if (top >= 350) {
  90. // $("#serc-index").fadeIn(1000);
  91. //
  92. // } else {
  93. // $("#serc-index").fadeOut(1000);
  94. //
  95. // }
  96. if (top >= 300) {
  97. $(".content-left").css({
  98. "position": "fixed",
  99. "top": "80px"
  100. })
  101. } else {
  102. $(".content-left").css({
  103. "position": "static"
  104. })
  105. }
  106. });
  107. var userid;
  108. function exit(){
  109. $.cookie('userid', null);
  110. $.cookie('userAuth', null);
  111. $.cookie('userEmail', null);
  112. $.cookie('userMobilePhone', null);
  113. $.cookie('userName', null);
  114. $.cookie('userType', null);
  115. location.href="index.html"
  116. }
  117. function valUser(){
  118. var userid = $.cookie('userid');
  119. var userAuth = $.cookie('userAuth');
  120. if(userid == undefined || userid.length==0 || userid == "null" || userAuth == false){
  121. location.href="login.html";
  122. }
  123. }
  124. function GetQueryString(name) {
  125. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  126. var r = window.location.search.substr(1).match(reg);
  127. var context = "";
  128. if (r != null)
  129. context = r[2];
  130. reg = null;
  131. r = null;
  132. return context == null || context == "" || context == "undefined" ? "" : decodeURI(context);
  133. }
  134. /* function GetQueryString(name) {
  135. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  136. var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ��
  137. var context = "";
  138. if (r != null)
  139. context = r[2];
  140. reg = null;
  141. r = null;
  142. return context == null || context == "" || context == "undefined" ? "" : context;
  143. }*/
  144. function loginStatus(){
  145. userid = $.cookie('userid');
  146. userAuth = $.cookie('userAuth');
  147. userName = $.cookie('userName');
  148. if(userid == null && userName == null && userAuth == "false"){
  149. $(".unlogin").show();
  150. $(".onlogin").hide();
  151. }else if(userid != null && userAuth == "false" && userName != null){
  152. location.href="login-first.html";
  153. }else if(userid != null && userAuth == "true" && userName == ""){
  154. location.href="information-add.html";
  155. }else{
  156. if (userid && userid != "null" && userid != null) {
  157. $(".onlogin").show();
  158. $(".unlogin").hide();
  159. $(".portrait-p").attr("src","/images/head/"+userid+"_m.jpg");
  160. $(".portrait-p").load(function(){//判断图片是否加载,加载不成功默认有默认的图像
  161. })
  162. .error(function(){
  163. $(".portrait-p").attr("src","/images/default-photo.jpg");
  164. });
  165. }
  166. }
  167. }
  168. //转换格式
  169. function changeTime(dealtime){
  170. var s = dealtime;
  171. //console.log(s);
  172. if(dealtime.length==8){
  173. var y = s.substr(0,4);
  174. var m = s.substr(4,2);
  175. var d = s.substr(6,2);
  176. var formatTime = y+"-"+m+"-"+d;
  177. return formatTime;
  178. }
  179. else
  180. {
  181. var y = s.substr(0,4);
  182. var m = s.substr(4,2);
  183. var d = s.substr(6,2);
  184. var h = s.substr(8,2);
  185. var minute = s.substr(10,2);
  186. var formatTime = y+"-"+m+"-"+d+" "+h+":"+minute;
  187. return formatTime;
  188. }
  189. }
  190. //******过滤特殊字符*******//
  191. function replaceStr(s)
  192. {
  193. var pattern = new RegExp("-");
  194. var rs = "";
  195. for (var i = 0; i < s.length; i++) {
  196. rs = rs+s.substr(i, 1).replace(pattern, '');
  197. }
  198. return rs;
  199. }
  200. //**********************//
  201. //根据内容的多少获取高度给父级设置高度
  202. function limitHeight(){
  203. var Length = $(".limitBox").length;
  204. for(var i=0; i<Length;i++){
  205. var limitheight = $(".limitwords").eq(i).height();
  206. console.log(limitheight);
  207. $(".limitBox").eq(i).css("height",limitheight);
  208. }
  209. }
  210. //根据用户输入的Email跳转到相应的电子邮箱首页
  211. var hash={
  212. 'qq.com': 'http://mail.qq.com',
  213. 'gmail.com': 'http://mail.google.com',
  214. 'sina.com': 'http://mail.sina.com.cn',
  215. '163.com': 'http://mail.163.com',
  216. '126.com': 'http://mail.126.com',
  217. 'yeah.net': 'http://www.yeah.net/',
  218. 'sohu.com': 'http://mail.sohu.com/',
  219. 'tom.com': 'http://mail.tom.com/',
  220. 'sogou.com': 'http://mail.sogou.com/',
  221. '139.com': 'http://mail.10086.cn/',
  222. 'hotmail.com': 'http://www.hotmail.com',
  223. 'live.com': 'http://login.live.com/',
  224. 'live.cn': 'http://login.live.cn/',
  225. 'live.com.cn': 'http://login.live.com.cn',
  226. '189.com': 'http://webmail16.189.cn/webmail/',
  227. 'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
  228. 'yahoo.cn': 'http://mail.cn.yahoo.com/',
  229. 'eyou.com': 'http://www.eyou.com/',
  230. '21cn.com': 'http://mail.21cn.com/',
  231. '188.com': 'http://www.188.com/',
  232. 'ustb.edu.cn': 'http://mail.ustb.edu.cn/',
  233. 'foxmail.coom': 'http://www.foxmail.com'
  234. };
  235. //轮播滚动函数
  236. function Carousel(inde, num,show, childcount, obj, next, prev) {
  237. var tapnum=0; //按钮可点击次数
  238. if( childcount > num ){
  239. next.css("display","block");
  240. prev.css("display","none");
  241. }
  242. next.click(function() {
  243. if (!obj.is(":animated")) {
  244. if (num < childcount) {
  245. tapnum++;
  246. prev.css("display","block");
  247. if(tapnum == childcount-show){
  248. next.css("display","none");
  249. }
  250. num++;
  251. obj.animate({
  252. left: "-=212px"
  253. }, 600);
  254. }
  255. }
  256. });
  257. prev.click(function() {
  258. if (!obj.is(":animated")) {
  259. if (num > inde) {
  260. tapnum--;
  261. next.css("display","block");
  262. if(tapnum == 0){
  263. prev.css("display","none");
  264. }
  265. num--;
  266. obj.animate({
  267. left: "+=212px"
  268. }, 600);
  269. }
  270. }
  271. });
  272. }
  273. //评价字数限制
  274. //字数限制函数
  275. function limitTextCountFn(TextAreaId,countContainerId,count){
  276. var curLength=$(TextAreaId).val().length;
  277. if(curLength > count){
  278. var num=$(TextAreaId).val().substr(0,count);
  279. $(TextAreaId).val(num);
  280. }
  281. else {
  282. $(countContainerId).text(count - $(TextAreaId).val().length);
  283. }
  284. };
  285. //咨询申请主题字数限制函数
  286. function titleLimitFontCountFn(){
  287. var curLength= $("#consultTitle").val().length;
  288. if(curLength>20){
  289. var num = $("#consultTitle").val().substr(0,20);
  290. $("#consultTitle").val(num);
  291. }
  292. };
  293. //模拟下拉菜单
  294. function selectThis(value){
  295. $("#div_select").text(value);
  296. $("#div_select2").val(value);
  297. $("#li_show").css("display","none");
  298. if(value=="找专家"){
  299. $("#searchContent").attr("placeholder","搜索专家、机构、研究方向");
  300. }else{
  301. $("#searchContent").attr("placeholder","搜索资源、应用用途");
  302. }
  303. }
  304. function selectThis2(value){
  305. $("#div_select").text(value);
  306. $("#div_select2").val(value);
  307. $("#li_show").css("display","none");
  308. if(value=="找专家"){
  309. $("#searchContent").attr("placeholder","输入专家姓名、机构、研究方向等关键字");
  310. }else{
  311. $("#searchContent").attr("placeholder","输入资源名称、应用用途等关键字");
  312. }
  313. }
  314. function showmenu(){
  315. $("#li_show").css("display","block");
  316. }
  317. /*选择城市填充js */
  318. $(document).on("click","#City li a", function(){
  319. var aVal = $(this).text();
  320. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  321. $(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
  322. });
  323. //咨询 专家信息接口函数
  324. function concultProInfo(professorId){
  325. $.ajax({
  326. url:"/ajax/professor/editBaseInfo/"+professorId,
  327. type:"get",
  328. data : {"id":professorId},
  329. contentType : "application/x-www-form-urlencoded",
  330. success:function(response){
  331. //console.log(response);
  332. var myData = response["data"];
  333. $("#professorName").html(myData["name"]);
  334. if(myData["title"]){
  335. $("#professorTitle").html(myData["title"]+' ');
  336. }
  337. if(myData["department"]){
  338. $("#profDepartment").html(myData["department"]+' ');
  339. }
  340. if(myData["orgName"]){
  341. $("#profOrganization").html(myData["orgName"]+' ');
  342. }
  343. if(myData["address"]){
  344. $("#profAdress").html(myData["address"]);
  345. }
  346. console.log(myData["consultCount"])
  347. if(!myData["consultCount"]){
  348. $("#starLevel").hide();
  349. }
  350. $("#byConsultConut").html(myData["consultCount"]);
  351. $("#sendConsultBtn").attr("proId",myData["id"]);
  352. //星级
  353. var startConut = parseInt(myData["starLevel"]);
  354. if(myData["consultCount"]){
  355. if(!startConut){
  356. $(".evastarbox2").hide();
  357. }
  358. }
  359. for(var i = 0; i < startConut; i ++){
  360. $("#starLevel .evastar2").eq(i).addClass("addStar");
  361. }
  362. //认证
  363. if(myData.authType) {//专家
  364. $("#proModify").addClass('authicon authicon-cu');
  365. } else {//普通用户
  366. if(myData.authStatus==3) {//身份已认证
  367. if(myData.authentication == 1) {//科研工作者
  368. $("#proModify").addClass('authicon2 authicon-mana');
  369. } else if(myData.authentication == 2) {//企业专家
  370. $("#proModify").addClass('authicon2 authicon-staff');
  371. } else {//学生
  372. $("#proModify").addClass('authicon2 authicon-stu');
  373. }
  374. }else{//身份未认证
  375. }
  376. };
  377. //头像
  378. if(myData["hasHeadImage"] == 0){
  379. $("#prohead").attr("src","images/default-photo.jpg");
  380. }
  381. else {
  382. $("#prohead").attr("src","images/head/"+myData["id"]+"_l.jpg");
  383. }
  384. },
  385. error:function(error){
  386. $.MsgBox.Alert("message","请求数据失败");
  387. }
  388. });
  389. };
  390. //发送咨询
  391. function sendConsultHandler(professorId){
  392. var professorId = professorId;
  393. var consult_type = $(".clicknow").text();//咨询类型
  394. var consult_title = $("#consultTitle").val();//咨询主题
  395. var consult_content = $("#consultcontent").val();//咨询内容
  396. var consultStr = {
  397. "consultType":consult_type,
  398. "consultTitle":consult_title,
  399. "consultContant":consult_content,
  400. "professorId":professorId,
  401. "consultantId":userid
  402. };
  403. if(consult_type == '' || consult_title == '' || consult_content == ''){
  404. $.MsgBox.Alert("消息提醒","请填写完整");
  405. };
  406. if(consult_type == ''){
  407. $.MsgBox.Alert("消息提醒","请选择联系目的");
  408. }
  409. if(consult_title == ''){
  410. $.MsgBox.Alert("消息提醒","请填写咨询目的");
  411. }
  412. if(consult_content == ''){
  413. $.MsgBox.Alert("消息提醒","请填写咨询内容");
  414. }
  415. if(userid && userid != null && userid != "null" && consult_type != '' &&
  416. consult_title != '' && consult_content != ''
  417. ){
  418. $.ajax({
  419. "url" :"/ajax/consult",
  420. "type" : "post",
  421. //传值:咨询类型、主题、内容、专家id、申请人id
  422. "data" : consultStr,
  423. "contentType" : "application/x-www-form-urlencoded",
  424. "dataType" : "json",
  425. "success" : function(response) {
  426. console.log(response);
  427. },
  428. "error":function (){
  429. $.MsgBox.Alert("消息提醒","咨询申请失败");
  430. },
  431. "complete":function(){
  432. //$(".consultapply").remove();
  433. $(".blackcover").remove();
  434. $("body").css("position","");
  435. $.MsgBox.Alert("消息提醒","咨询申请成功");
  436. },
  437. });
  438. }
  439. };
  440. /*标志*/
  441. function autho() {
  442. if(arguments[0] == 1) {
  443. return {
  444. "sty": "authicon-pro",
  445. "title": "科袖认证专家"
  446. }
  447. } else {
  448. if(arguments[1] == 1) {
  449. return {
  450. "sty": "authicon-staff-ok",
  451. "title": "企业认证员工"
  452. }
  453. } else {
  454. if(arguments[2] == 3) {
  455. return {
  456. "sty": "authicon-real",
  457. "title": "实名认证用户"
  458. }
  459. }
  460. }
  461. }
  462. }
  463. //获取用户类型
  464. var ifuser = ifUserType();
  465. function ifUserType(pa){
  466. if(pa) {
  467. var useridtype =pa;
  468. }else{
  469. var useridtype = $.cookie('userid');
  470. }
  471. var authType2,authentication2;
  472. if (useridtype && useridtype != "null" && useridtype != null) {
  473. $.ajax({
  474. "url" :"/ajax/professor/auth",
  475. "type" : "GET",
  476. "data" :{"id":useridtype} ,
  477. "dataType" : "json",
  478. "async":false,
  479. "success" : function(data) {
  480. if(data.success){
  481. authType2 = data.data.authType;
  482. authentication2 = data.data.authentication;
  483. }
  484. }
  485. });
  486. }
  487. return{
  488. "authType2":authType2,
  489. "authentication2":authentication2,
  490. }
  491. }
  492. //工作台判断用户类型显示用户权限
  493. if ($.cookie('userName') && $.cookie('userName') != "null" && $.cookie('userName') != null) {
  494. if(ifuser.authType2==0){
  495. $("#repalyf").addClass("repalyf");
  496. /*点击未读咨询消息查看*/
  497. $("#gozixu").on("click", function() {
  498. window.location.href = "myConsult.html";
  499. })
  500. }else{
  501. $(".nohide").show();
  502. /*点击未读咨询消息查看*/
  503. $("#gozixu").on("click", function() {
  504. window.location.href = "consult.html";
  505. })
  506. }
  507. }