portal html css js resource

common.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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. //Model模态框打开关闭
  12. function modelOpen(){
  13. $(".blackcover").fadeIn();
  14. $(".modelContain").slideDown();
  15. $("body").addClass("modelOpen");
  16. }
  17. function modelClose(){
  18. $(".modelContain").slideUp();
  19. $(".blackcover").fadeOut();
  20. $("body").removeClass("modelOpen");
  21. }
  22. var userid;
  23. function exit(){
  24. $.cookie('userid', null);
  25. $.cookie('userAuth', null);
  26. $.cookie('userEmail', null);
  27. $.cookie('userMobilePhone', null);
  28. $.cookie('userName', null);
  29. $.cookie('userType', null);
  30. location.href="../index.html"
  31. }
  32. function valUser(){
  33. var userid = $.cookie('userid');
  34. var userAuth = $.cookie('userAuth');
  35. if(userid == undefined || userid.length==0 || userid == "null" || userAuth == false){
  36. location.href="login.html";
  37. }
  38. }
  39. function GetQueryString(name) {
  40. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  41. var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ��
  42. var context = "";
  43. if (r != null)
  44. context = r[2];
  45. reg = null;
  46. r = null;
  47. return context == null || context == "" || context == "undefined" ? "" : decodeURI(context);
  48. }
  49. /* function GetQueryString(name) {
  50. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  51. var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ��
  52. var context = "";
  53. if (r != null)
  54. context = r[2];
  55. reg = null;
  56. r = null;
  57. return context == null || context == "" || context == "undefined" ? "" : context;
  58. }*/
  59. function loginStatus(){
  60. userid = $.cookie('userid');
  61. userAuth = $.cookie('userAuth');
  62. userName = $.cookie('userName');
  63. if(userid == null && userName == null && userAuth == "false"){
  64. $(".onlogin").hide();
  65. $(".unlogin").show();
  66. }else if(userid != null && userAuth == "false" && userName != null){
  67. location.href="login-first.html";
  68. }else if(userid != null && userAuth == "true" && userName == ""){
  69. location.href="information-add.html";
  70. }else{
  71. $(".onlogin").show();
  72. $(".unlogin").hide();
  73. $(".portrait-p").attr("src","/images/head/"+userid+"_m.jpg");
  74. $(".portrait-p").load(function(){//判断图片是否加载,加载不成功默认有默认的图像
  75. })
  76. .error(function(){
  77. $(".portrait-p").attr("src","/images/default-photo.jpg");
  78. });
  79. }
  80. }
  81. //底部导航code显示隐藏
  82. $(".codehover").hover(function(){
  83. $(".codehover .code").stop(true, false).fadeOut();
  84. $(this).find(".code").stop(true, false).fadeIn();
  85. },function(){
  86. $(this).find(".code").stop(true, false).hide();
  87. })
  88. //转换格式
  89. function changeTime(dealtime){
  90. var s = dealtime;
  91. //console.log(s);
  92. if(dealtime.length==8){
  93. var y = s.substr(0,4);
  94. var m = s.substr(4,2);
  95. var d = s.substr(6,2);
  96. var formatTime = y+"-"+m+"-"+d;
  97. return formatTime;
  98. }
  99. else
  100. {
  101. var y = s.substr(0,4);
  102. var m = s.substr(4,2);
  103. var d = s.substr(6,2);
  104. var h = s.substr(8,2);
  105. var minute = s.substr(10,2);
  106. var formatTime = y+"-"+m+"-"+d+" "+h+":"+minute;
  107. return formatTime;
  108. }
  109. }
  110. //******过滤特殊字符*******//
  111. function replaceStr(s)
  112. {
  113. var pattern = new RegExp("-");
  114. var rs = "";
  115. for (var i = 0; i < s.length; i++) {
  116. rs = rs+s.substr(i, 1).replace(pattern, '');
  117. }
  118. return rs;
  119. }
  120. //**********************//
  121. //根据内容的多少获取高度给父级设置高度
  122. function limitHeight(){
  123. var Length = $(".limitBox").length;
  124. for(var i=0; i<Length;i++){
  125. var limitheight = $(".limitwords").eq(i).height();
  126. console.log(limitheight);
  127. $(".limitBox").eq(i).css("height",limitheight);
  128. }
  129. }
  130. //根据用户输入的Email跳转到相应的电子邮箱首页
  131. var hash={
  132. 'qq.com': 'http://mail.qq.com',
  133. 'gmail.com': 'http://mail.google.com',
  134. 'sina.com': 'http://mail.sina.com.cn',
  135. '163.com': 'http://mail.163.com',
  136. '126.com': 'http://mail.126.com',
  137. 'yeah.net': 'http://www.yeah.net/',
  138. 'sohu.com': 'http://mail.sohu.com/',
  139. 'tom.com': 'http://mail.tom.com/',
  140. 'sogou.com': 'http://mail.sogou.com/',
  141. '139.com': 'http://mail.10086.cn/',
  142. 'hotmail.com': 'http://www.hotmail.com',
  143. 'live.com': 'http://login.live.com/',
  144. 'live.cn': 'http://login.live.cn/',
  145. 'live.com.cn': 'http://login.live.com.cn',
  146. '189.com': 'http://webmail16.189.cn/webmail/',
  147. 'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
  148. 'yahoo.cn': 'http://mail.cn.yahoo.com/',
  149. 'eyou.com': 'http://www.eyou.com/',
  150. '21cn.com': 'http://mail.21cn.com/',
  151. '188.com': 'http://www.188.com/',
  152. 'ustb.edu.cn': 'http://mail.ustb.edu.cn/',
  153. 'foxmail.coom': 'http://www.foxmail.com'
  154. };
  155. //轮播滚动函数
  156. function Carousel(inde, num,show, childcount, obj, next, prev) {
  157. var tapnum=0; //按钮可点击次数
  158. if( childcount > num ){
  159. next.css("display","block");
  160. prev.css("display","none");
  161. }
  162. next.click(function() {
  163. if (!obj.is(":animated")) {
  164. if (num < childcount) {
  165. tapnum++;
  166. prev.css("display","block");
  167. if(tapnum == childcount-show){
  168. next.css("display","none");
  169. }
  170. num++;
  171. obj.animate({
  172. left: "-=212px"
  173. }, 600);
  174. }
  175. }
  176. });
  177. prev.click(function() {
  178. if (!obj.is(":animated")) {
  179. if (num > inde) {
  180. tapnum--;
  181. next.css("display","block");
  182. if(tapnum == 0){
  183. prev.css("display","none");
  184. }
  185. num--;
  186. obj.animate({
  187. left: "+=212px"
  188. }, 600);
  189. }
  190. }
  191. });
  192. }
  193. //评价字数限制
  194. //字数限制函数
  195. function limitTextCountFn(TextAreaId,countContainerId,count){
  196. var curLength=$(TextAreaId).val().length;
  197. if(curLength > count){
  198. var num=$(TextAreaId).val().substr(0,count);
  199. $(TextAreaId).val(num);
  200. }
  201. else {
  202. $(countContainerId).text(count - $(TextAreaId).val().length);
  203. }
  204. };
  205. //咨询申请主题字数限制函数
  206. function titleLimitFontCountFn(){
  207. var curLength= $("#consultTitle").val().length;
  208. if(curLength>20){
  209. var num = $("#consultTitle").val().substr(0,20);
  210. $("#consultTitle").val(num);
  211. }
  212. };
  213. //模拟下拉菜单
  214. function selectThis(value){
  215. $("#div_select").text(value);
  216. $("#div_select2").val(value);
  217. $("#li_show").css("display","none");
  218. if(value=="找专家"){
  219. $("#searchContent").attr("placeholder","搜索专家、机构、研究方向");
  220. }else{
  221. $("#searchContent").attr("placeholder","搜索资源、应用用途");
  222. }
  223. }
  224. function selectThis2(value){
  225. $("#div_select").text(value);
  226. $("#div_select2").val(value);
  227. $("#li_show").css("display","none");
  228. if(value=="找专家"){
  229. $("#searchContent").attr("placeholder","输入专家姓名、机构、研究方向等关键字");
  230. }else{
  231. $("#searchContent").attr("placeholder","输入资源名称、应用用途等关键字");
  232. }
  233. }
  234. function showmenu(){
  235. $("#li_show").css("display","block");
  236. }
  237. /*选择城市填充js */
  238. $(document).on("click","#City li a", function(){
  239. var aVal = $(this).text();
  240. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  241. $(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
  242. });
  243. //咨询 专家信息接口函数
  244. function concultProInfo(professorId){
  245. $.ajax({
  246. url:"/ajax/professor/editBaseInfo/"+professorId,
  247. type:"get",
  248. data : {"id":professorId},
  249. contentType : "application/x-www-form-urlencoded",
  250. success:function(response){
  251. //console.log(response);
  252. var myData = response["data"];
  253. $("#professorName").html(myData["name"]);
  254. if(myData["title"]){
  255. $("#professorTitle").html(myData["title"]+' ');
  256. }
  257. if(myData["department"]){
  258. $("#profDepartment").html(myData["department"]+' ');
  259. }
  260. if(myData["orgName"]){
  261. $("#profOrganization").html(myData["orgName"]+' ');
  262. }
  263. if(myData["address"]){
  264. $("#profAdress").html(myData["address"]);
  265. }
  266. console.log(myData["consultCount"])
  267. if(!myData["consultCount"]){
  268. $("#starLevel").hide();
  269. }
  270. $("#byConsultConut").html(myData["consultCount"]);
  271. $("#sendConsultBtn").attr("proId",myData["id"]);
  272. //星级
  273. var startConut = parseInt(myData["starLevel"]);
  274. if(myData["consultCount"]){
  275. if(!startConut){
  276. $(".evastarbox2").hide();
  277. }
  278. }
  279. for(var i = 0; i < startConut; i ++){
  280. $("#starLevel .evastar2").eq(i).addClass("addStar");
  281. }
  282. //认证
  283. if(myData.authType) {//专家
  284. $("#proModify").addClass('authicon authicon-cu');
  285. } else {//普通用户
  286. if(myData.authStatus) {//身份已认证
  287. if(myData.authentication == 1) {//科研工作者
  288. $("#proModify").addClass('authicon2 authicon-mana');
  289. } else if(myData.authentication == 2) {//企业专家
  290. $("#proModify").addClass('authicon2 authicon-staff');
  291. } else {//学生
  292. $("#proModify").addClass('authicon2 authicon-stu');
  293. }
  294. }else{//身份未认证
  295. }
  296. };
  297. //头像
  298. if(myData["hasHeadImage"] == 0){
  299. $("#prohead").attr("src","images/default-photo.jpg");
  300. }
  301. else {
  302. $("#prohead").attr("src","images/head/"+myData["id"]+"_l.jpg");
  303. }
  304. },
  305. error:function(error){
  306. $.MsgBox.Alert("message","请求数据失败");
  307. }
  308. });
  309. };
  310. //发送咨询
  311. function sendConsultHandler(professorId){
  312. var professorId = professorId;
  313. var consult_type = $(".clicknow").text();//咨询类型
  314. var consult_title = $("#consultTitle").val();//咨询主题
  315. var consult_content = $("#consultcontent").val();//咨询内容
  316. var consultStr = {
  317. "consultType":consult_type,
  318. "consultTitle":consult_title,
  319. "consultContant":consult_content,
  320. "professorId":professorId,
  321. "consultantId":userid
  322. };
  323. if(consult_type == '' || consult_title == '' || consult_content == ''){
  324. $.MsgBox.Alert("消息提醒","请填写完整");
  325. };
  326. if(consult_type == ''){
  327. $.MsgBox.Alert("消息提醒","请选择联系目的");
  328. }
  329. if(consult_title == ''){
  330. $.MsgBox.Alert("消息提醒","请填写咨询目的");
  331. }
  332. if(consult_content == ''){
  333. $.MsgBox.Alert("消息提醒","请填写咨询内容");
  334. }
  335. if(userid && userid != null && userid != "null" && consult_type != '' &&
  336. consult_title != '' && consult_content != ''
  337. ){
  338. $.ajax({
  339. "url" :"/ajax/consult",
  340. "type" : "post",
  341. //传值:咨询类型、主题、内容、专家id、申请人id
  342. "data" : consultStr,
  343. "contentType" : "application/x-www-form-urlencoded",
  344. "dataType" : "json",
  345. "success" : function(response) {
  346. console.log(response);
  347. },
  348. "error":function (){
  349. $.MsgBox.Alert("消息提醒","咨询申请失败");
  350. },
  351. "complete":function(){
  352. //$(".consultapply").remove();
  353. $(".blackcover").remove();
  354. $("body").css("position","static");
  355. $.MsgBox.Alert("消息提醒","咨询申请成功");
  356. },
  357. });
  358. }
  359. };
  360. //获取用户类型
  361. var ifuser = ifUserType();
  362. function ifUserType(pa){
  363. if(pa) {
  364. var useridtype =pa;
  365. }else{
  366. var useridtype = $.cookie('userid');
  367. }
  368. var authType2,authentication2;
  369. if (useridtype && useridtype != "null" && useridtype != null) {
  370. $.ajax({
  371. "url" :"/ajax/professor/auth",
  372. "type" : "GET",
  373. "data" :{"id":useridtype} ,
  374. "dataType" : "json",
  375. "async":false,
  376. "success" : function(data) {
  377. if(data.success){
  378. authType2 = data.data.authType;
  379. authentication2 = data.data.authentication;
  380. }
  381. }
  382. });
  383. }
  384. return{
  385. "authType2":authType2,
  386. "authentication2":authentication2,
  387. }
  388. }