portal html css js resource

common.js 11KB

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