portal html css js resource

common.js 14KB

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