portal html css js resource

common.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. $(document).ready(function(){
  2. var footerHeight = $("footer").outerHeight(true);
  3. $('#container').css("padding-bottom", footerHeight +"px" );
  4. //窗口大小变更事件
  5. $(window).resize(function() {
  6. footerHeight=$("footer").outerHeight(true);
  7. $('#container').css("padding-bottom", footerHeight +"px" );
  8. //console.log(footerHeight)
  9. });
  10. });
  11. /*向下滚动时,header背景变半透明*/
  12. $(document).scroll(function() {
  13. var top = $(document).scrollTop();
  14. if (top == 0) {
  15. $("#header").addClass("firstL");
  16. $(".personal-infor").css("opacity", "1");
  17. } else {
  18. $("#header").addClass("firstB").removeClass("firstL");
  19. // $("#header").removeClass("firstL").addClass("firstH");
  20. $(".personal-infor").css("opacity", "0.8");
  21. }
  22. if (top != 0) {
  23. $(".searchbox").fadeIn(1000);
  24. } else {
  25. $(".searchbox").fadeOut(1000);
  26. }
  27. //小搜索框滚动大于等于350,显示在头部
  28. if (top >= 350) {
  29. $("#serc-index").fadeIn(1000);
  30. } else {
  31. $("#serc-index").fadeOut(1000);
  32. }
  33. if (top >= 300) {
  34. $(".content-left").css({
  35. "position": "fixed",
  36. "top": "80px"
  37. })
  38. } else {
  39. $(".content-left").css({
  40. "position": "static"
  41. })
  42. }
  43. });
  44. var userid;
  45. function exit(){
  46. $.cookie('userid', null);
  47. $.cookie('userAuth', null);
  48. $.cookie('userEmail', null);
  49. $.cookie('userMobilePhone', null);
  50. $.cookie('userName', null);
  51. $.cookie('userType', null);
  52. location.href="index.html"
  53. }
  54. function valUser(){
  55. var userid = $.cookie('userid');
  56. var userAuth = $.cookie('userAuth');
  57. if(userid == undefined || userid.length==0 || userid == "null" || userAuth == false){
  58. location.href="login.html";
  59. }
  60. }
  61. function GetQueryString(name) {
  62. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  63. var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ��
  64. var context = "";
  65. if (r != null)
  66. context = r[2];
  67. reg = null;
  68. r = null;
  69. return context == null || context == "" || context == "undefined" ? "" : decodeURI(context);
  70. }
  71. /* function GetQueryString(name) {
  72. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  73. var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ��
  74. var context = "";
  75. if (r != null)
  76. context = r[2];
  77. reg = null;
  78. r = null;
  79. return context == null || context == "" || context == "undefined" ? "" : context;
  80. }*/
  81. function loginStatus(){
  82. userid = $.cookie('userid');
  83. userAuth = $.cookie('userAuth');
  84. userName = $.cookie('userName');
  85. if(userid == null && userName == null && userAuth == "false"){
  86. $(".onlogin").hide();
  87. $(".unlogin").show();
  88. }else if(userid != null && userAuth == "false" && userName != null){
  89. location.href="login-first.html";
  90. }else if(userid != null && userAuth == "true" && userName == ""){
  91. location.href="information-add.html";
  92. }else{
  93. $(".onlogin").show();
  94. $(".unlogin").hide();
  95. $(".portrait-p").attr("src","/images/head/"+userid+"_m.jpg");
  96. $(".portrait-p").load(function(){//判断图片是否加载,加载不成功默认有默认的图像
  97. })
  98. .error(function(){
  99. $(".portrait-p").attr("src","/images/default-photo.jpg");
  100. });
  101. }
  102. }
  103. //底部导航code显示隐藏
  104. $(".codehover").hover(function(){
  105. $(".codehover .code").stop(true, false).fadeOut();
  106. $(this).find(".code").stop(true, false).fadeIn();
  107. },function(){
  108. $(this).find(".code").stop(true, false).hide();
  109. })
  110. //转换格式
  111. function changeTime(dealtime){
  112. var s = dealtime;
  113. //console.log(s);
  114. if(dealtime.length==8){
  115. var y = s.substr(0,4);
  116. var m = s.substr(4,2);
  117. var d = s.substr(6,2);
  118. var formatTime = y+"-"+m+"-"+d;
  119. return formatTime;
  120. }
  121. else
  122. {
  123. var y = s.substr(0,4);
  124. var m = s.substr(4,2);
  125. var d = s.substr(6,2);
  126. var h = s.substr(8,2);
  127. var minute = s.substr(10,2);
  128. var formatTime = y+"-"+m+"-"+d+" "+h+":"+minute;
  129. return formatTime;
  130. }
  131. }
  132. //******过滤特殊字符*******//
  133. function replaceStr(s)
  134. {
  135. var pattern = new RegExp("-");
  136. var rs = "";
  137. for (var i = 0; i < s.length; i++) {
  138. rs = rs+s.substr(i, 1).replace(pattern, '');
  139. }
  140. return rs;
  141. }
  142. //**********************//
  143. //根据内容的多少获取高度给父级设置高度
  144. function limitHeight(){
  145. var Length = $(".limitBox").length;
  146. for(var i=0; i<Length;i++){
  147. var limitheight = $(".limitwords").eq(i).height();
  148. console.log(limitheight);
  149. $(".limitBox").eq(i).css("height",limitheight);
  150. }
  151. }
  152. //根据用户输入的Email跳转到相应的电子邮箱首页
  153. var hash={
  154. 'qq.com': 'http://mail.qq.com',
  155. 'gmail.com': 'http://mail.google.com',
  156. 'sina.com': 'http://mail.sina.com.cn',
  157. '163.com': 'http://mail.163.com',
  158. '126.com': 'http://mail.126.com',
  159. 'yeah.net': 'http://www.yeah.net/',
  160. 'sohu.com': 'http://mail.sohu.com/',
  161. 'tom.com': 'http://mail.tom.com/',
  162. 'sogou.com': 'http://mail.sogou.com/',
  163. '139.com': 'http://mail.10086.cn/',
  164. 'hotmail.com': 'http://www.hotmail.com',
  165. 'live.com': 'http://login.live.com/',
  166. 'live.cn': 'http://login.live.cn/',
  167. 'live.com.cn': 'http://login.live.com.cn',
  168. '189.com': 'http://webmail16.189.cn/webmail/',
  169. 'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
  170. 'yahoo.cn': 'http://mail.cn.yahoo.com/',
  171. 'eyou.com': 'http://www.eyou.com/',
  172. '21cn.com': 'http://mail.21cn.com/',
  173. '188.com': 'http://www.188.com/',
  174. 'ustb.edu.cn': 'http://mail.ustb.edu.cn/',
  175. 'foxmail.coom': 'http://www.foxmail.com'
  176. };
  177. //轮播滚动函数
  178. function Carousel(inde, num,show, childcount, obj, next, prev) {
  179. var tapnum=0; //按钮可点击次数
  180. if( childcount > num ){
  181. next.css("display","block");
  182. prev.css("display","none");
  183. }
  184. next.click(function() {
  185. if (!obj.is(":animated")) {
  186. if (num < childcount) {
  187. tapnum++;
  188. prev.css("display","block");
  189. if(tapnum == childcount-show){
  190. next.css("display","none");
  191. }
  192. num++;
  193. obj.animate({
  194. left: "-=212px"
  195. }, 600);
  196. }
  197. }
  198. });
  199. prev.click(function() {
  200. if (!obj.is(":animated")) {
  201. if (num > inde) {
  202. tapnum--;
  203. next.css("display","block");
  204. if(tapnum == 0){
  205. prev.css("display","none");
  206. }
  207. num--;
  208. obj.animate({
  209. left: "+=212px"
  210. }, 600);
  211. }
  212. }
  213. });
  214. }
  215. //评价字数限制
  216. //字数限制函数
  217. function limitTextCountFn(TextAreaId,countContainerId,count){
  218. var curLength=$(TextAreaId).val().length;
  219. if(curLength > count){
  220. var num=$(TextAreaId).val().substr(0,count);
  221. $(TextAreaId).val(num);
  222. }
  223. else {
  224. $(countContainerId).text(count - $(TextAreaId).val().length);
  225. }
  226. };
  227. //咨询申请主题字数限制函数
  228. function titleLimitFontCountFn(){
  229. var curLength= $("#consultTitle").val().length;
  230. if(curLength>20){
  231. var num = $("#consultTitle").val().substr(0,20);
  232. $("#consultTitle").val(num);
  233. }
  234. };
  235. //模拟下拉菜单
  236. function selectThis(value){
  237. $("#div_select").text(value);
  238. $("#div_select2").val(value);
  239. $("#li_show").css("display","none");
  240. if(value=="找专家"){
  241. $("#searchContent").attr("placeholder","搜索专家、机构、研究方向");
  242. }else{
  243. $("#searchContent").attr("placeholder","搜索资源、应用用途");
  244. }
  245. }
  246. function selectThis2(value){
  247. $("#div_select").text(value);
  248. $("#div_select2").val(value);
  249. $("#li_show").css("display","none");
  250. if(value=="找专家"){
  251. $("#searchContent").attr("placeholder","输入专家姓名、机构、研究方向等关键字");
  252. }else{
  253. $("#searchContent").attr("placeholder","输入资源名称、应用用途等关键字");
  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. if(myData.authType) {//专家
  306. $("#proModify").addClass('authicon authicon-cu');
  307. } else {//普通用户
  308. if(myData.authStatus==3) {//身份已认证
  309. if(myData.authentication == 1) {//科研工作者
  310. $("#proModify").addClass('authicon2 authicon-mana');
  311. } else if(myData.authentication == 2) {//企业专家
  312. $("#proModify").addClass('authicon2 authicon-staff');
  313. } else {//学生
  314. $("#proModify").addClass('authicon2 authicon-stu');
  315. }
  316. }else{//身份未认证
  317. }
  318. };
  319. //头像
  320. if(myData["hasHeadImage"] == 0){
  321. $("#prohead").attr("src","images/default-photo.jpg");
  322. }
  323. else {
  324. $("#prohead").attr("src","images/head/"+myData["id"]+"_l.jpg");
  325. }
  326. },
  327. error:function(error){
  328. $.MsgBox.Alert("message","请求数据失败");
  329. }
  330. });
  331. };
  332. //发送咨询
  333. function sendConsultHandler(professorId){
  334. var professorId = professorId;
  335. var consult_type = $(".clicknow").text();//咨询类型
  336. var consult_title = $("#consultTitle").val();//咨询主题
  337. var consult_content = $("#consultcontent").val();//咨询内容
  338. var consultStr = {
  339. "consultType":consult_type,
  340. "consultTitle":consult_title,
  341. "consultContant":consult_content,
  342. "professorId":professorId,
  343. "consultantId":userid
  344. };
  345. if(consult_type == '' || consult_title == '' || consult_content == ''){
  346. $.MsgBox.Alert("消息提醒","请填写完整");
  347. };
  348. if(consult_type == ''){
  349. $.MsgBox.Alert("消息提醒","请选择联系目的");
  350. }
  351. if(consult_title == ''){
  352. $.MsgBox.Alert("消息提醒","请填写咨询目的");
  353. }
  354. if(consult_content == ''){
  355. $.MsgBox.Alert("消息提醒","请填写咨询内容");
  356. }
  357. if(userid && userid != null && userid != "null" && consult_type != '' &&
  358. consult_title != '' && consult_content != ''
  359. ){
  360. $.ajax({
  361. "url" :"/ajax/consult",
  362. "type" : "post",
  363. //传值:咨询类型、主题、内容、专家id、申请人id
  364. "data" : consultStr,
  365. "contentType" : "application/x-www-form-urlencoded",
  366. "dataType" : "json",
  367. "success" : function(response) {
  368. console.log(response);
  369. },
  370. "error":function (){
  371. $.MsgBox.Alert("消息提醒","咨询申请失败");
  372. },
  373. "complete":function(){
  374. //$(".consultapply").remove();
  375. $(".blackcover").remove();
  376. $("body").css("position","");
  377. $.MsgBox.Alert("消息提醒","咨询申请成功");
  378. },
  379. });
  380. }
  381. };
  382. //获取用户类型
  383. var ifuser = ifUserType();
  384. function ifUserType(pa){
  385. if(pa) {
  386. var useridtype =pa;
  387. }else{
  388. var useridtype = $.cookie('userid');
  389. }
  390. var authType2,authentication2;
  391. if (useridtype && useridtype != "null" && useridtype != null) {
  392. $.ajax({
  393. "url" :"/ajax/professor/auth",
  394. "type" : "GET",
  395. "data" :{"id":useridtype} ,
  396. "dataType" : "json",
  397. "async":false,
  398. "success" : function(data) {
  399. if(data.success){
  400. authType2 = data.data.authType;
  401. authentication2 = data.data.authentication;
  402. }
  403. }
  404. });
  405. }
  406. return{
  407. "authType2":authType2,
  408. "authentication2":authentication2,
  409. }
  410. }
  411. //工作台判断用户类型显示用户权限
  412. if ($.cookie('userid') && $.cookie('userid') != "null" && $.cookie('userid') != null) {
  413. if(ifuser.authType2==0){
  414. $("#repalyf").addClass("repalyf");
  415. /*点击未读咨询消息查看*/
  416. $("#gozixu").on("click", function() {
  417. window.location.href = "demand.html";
  418. })
  419. }else{
  420. $(".nohide").show();
  421. /*点击未读咨询消息查看*/
  422. $("#gozixu").on("click", function() {
  423. window.location.href = "consult.html";
  424. })
  425. }
  426. }