portal html css js resource

common.js 14KB

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