portal html css js resource

account-set.js 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. $(function(){
  2. loginStatus();//判断个人是否登录
  3. valUser();
  4. var setta = GetQueryString("seta");
  5. if(setta==2){
  6. $(".account-set a").eq(1).addClass("bgcolor").siblings().removeClass("bgcolor");
  7. $(".contentbox .content-set").eq(1).show().siblings().hide();
  8. }
  9. var userid = $.cookie("userid");
  10. //个人信息头像获取
  11. $("#headimg").attr("src", "/images/head/" + userid + "_l.jpg");
  12. $("#headimg").load(function() {
  13. }).error(function() {
  14. $("#headimg").attr("src", "/images/default-photo.jpg");
  15. })
  16. //获取用户用户名
  17. $.ajax({
  18. "url":"/ajax/professor/info/"+userid,
  19. "type":"get",
  20. "success":function($data){
  21. if($data.data)
  22. {
  23. $('#username').text($data.data.name);
  24. }
  25. }
  26. })
  27. $("#hsearch").on("click",function (){
  28. var searchContent = $("#hsearchContent").val();
  29. location.href = "search.html?searchContent="+searchContent;
  30. });
  31. });
  32. /*专家信息左导航背景点击切换*/
  33. $(".leftsidebar").click(function(){
  34. var index = $(this).index()-1;
  35. $(this).addClass("bgcolor").siblings().removeClass("bgcolor");
  36. $(".content-set").eq(index).show().siblings().hide();
  37. });
  38. /*编辑标签变色html里隐藏了*/
  39. $("#container .edit").hover(function(){
  40. $(this).addClass("edit-position-left")
  41. },function(){
  42. $(this).removeClass("edit-position-left")
  43. });
  44. //邮箱绑定,手机绑定,点击关闭隐藏这两个部分
  45. $(".times").click(function(){
  46. $(".cover,.coverset,.cover2").hide();
  47. });
  48. //邮箱绑定,手机绑定,点击返回,隐藏这两个部分
  49. $(".back-btn").click(function(){
  50. $(".cover").hide();
  51. $(".cover2").hide();
  52. });
  53. //这个标签已经隐藏了,点击手机账号绑定
  54. $(".replace2").click(function(){
  55. $(".cover2").show();
  56. });
  57. //这个标签已经隐藏了,点击邮箱账号绑定
  58. $(".replace1").click(function(){
  59. $(".cover").show();
  60. });
  61. //点击邮箱账号绑定
  62. $(".replace5").click(function(){
  63. $(".cover").show();
  64. })
  65. //点击手机账号绑定
  66. $(".replace6").click(function(){
  67. $(".cover2").show();
  68. });
  69. //判断是否绑定了邮箱
  70. var emailCookie = $.cookie("userEmail");
  71. var phoneCookie = $.cookie("userMobilePhone");
  72. if(emailCookie != "" && emailCookie != null && emailCookie != "null" ){
  73. //alert(emailCookieshow);
  74. emailhome(emailCookie);
  75. $("#emailShow").text(emailCookieshow);
  76. $(".replace1").hide();
  77. $(".replace3").show();
  78. }else{
  79. $(".replace1").show();
  80. $(".replace3").hide();
  81. }
  82. //判断是否绑定了手机号
  83. if(phoneCookie != "" && phoneCookie != null && phoneCookie != "null" ){
  84. $("#phoneShow").text(phoneCookie.substring(0, 3) + "****" + phoneCookie.substring(7, 11));
  85. $(".replace2").hide();
  86. $(".replace4").show();
  87. }else{
  88. $(".replace2").show();
  89. $(".replace4").hide();
  90. }
  91. function emailhome(emailset){
  92. //var emailCookieshow;
  93. var emailq = emailset.replace(/@.*/, "");
  94. var emailh = emailset.replace(emailq, "");
  95. if(emailq.length>=6){
  96. emailCookieshow = emailq.substring(emailq.length-4, 0) + "****" + emailh;
  97. }
  98. if(emailq.length==5){
  99. emailCookieshow = emailq.substring(emailq.length-3, 0) + "***" + emailh;
  100. }
  101. if(emailq.length==4){
  102. emailCookieshow = emailq.substring(emailq.length-2, 0) + "**" + emailh;
  103. }
  104. if(emailq.length==3){
  105. emailCookieshow = emailq.substring(emailq.length-1, 0) + "*" + emailh;
  106. }
  107. if(emailq.length<3){
  108. emailCookieshow = emailq+emailh;
  109. }
  110. return emailCookieshow;
  111. }
  112. var oldPass = false;
  113. var isPass = false;
  114. var isPass2 = false;
  115. function valOld(){
  116. var oldPassword = $("#oldPassword").val();
  117. if(oldPassword.length==0){
  118. $(".msg1").text("请输入密码");
  119. oldPass = false;
  120. }else if(oldPassword.length < 6){
  121. $(".msg1").text("密码不少于6位,请输入正确的密码");
  122. }else{
  123. $(".msg1").text("");
  124. oldPass = true;
  125. }
  126. }
  127. function valNew(){
  128. var newPassword = $("#newPassword").val();
  129. var oldPassword = $("#oldPassword").val();
  130. if(newPassword.length==0){
  131. $(".msg2").text("密码不能为空");
  132. }else if(newPassword.length<6){
  133. $(".msg2").text("密码长度过短,至少六位");
  134. }else if(newPassword2 == newPassword){
  135. $(".msg2").text("新旧密码不能一致");
  136. } else{
  137. isPass = true;
  138. $(".msg2").text("");
  139. }
  140. }
  141. function valNew2(){
  142. var newPassword = $("#newPassword").val();
  143. var newPassword2 = $("#newPassword2").val();
  144. if(newPassword2.length==0){
  145. $(".msg3").text("密码不能为空");
  146. }else if(newPassword2 != newPassword){
  147. $(".msg3").text("两次输入密码不一致");
  148. }else{
  149. isPass2 = true;
  150. $(".msg3").text("");
  151. }
  152. }
  153. function restPassword(){
  154. valOld();
  155. valNew();
  156. valNew2();
  157. if(oldPass == true && isPass == true && isPass2 == true){
  158. $.ajax("/ajax/cp",{
  159. type:"POST",
  160. async: false,
  161. success:function(data){
  162. if(data.success){
  163. if(data.data == true){
  164. $.MsgBox.Alert("消息提醒","设置成功,请重新登录");
  165. /*location.href="login.html";*/
  166. }else{
  167. $.MsgBox.Alert("消息提醒","设置失败,请检查密码是否正确!");
  168. }
  169. }else{
  170. $.MsgBox.Alert("消息提醒","系统异常!");
  171. // alert("系统异常!");
  172. }
  173. },
  174. error:function(){$.MsgBox.Alert('message','fail')},
  175. data:{"id":$.cookie("userid"),"npw":$("#newPassword2").val(),"onw":$("#oldPassword").val()},
  176. dataType: 'json'
  177. });
  178. }else{
  179. /*alert("请校验密码");*/
  180. }
  181. }
  182. //重新绑定邮箱
  183. var emailPass = false;
  184. var emailOk = false;
  185. //页面需要验证展示的位置,先用alert替代
  186. function valEmail(){
  187. var email = $("#email").val();
  188. //var gunf=/^\w+@\w+\.((cn)|(com)|(com\.cn))$/;
  189. var gunf= /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
  190. if(gunf.test(email.trim())){
  191. userRegisterOk();
  192. emailPass = true;
  193. emailSuccess();
  194. }else{
  195. /*alert("请输入正确是邮箱地址");*/
  196. $(".msg11 span").text("请输入正确的邮箱地址。");
  197. emailPass = false;
  198. }
  199. }
  200. //获取邮箱,填写地址
  201. function emailSuccess()
  202. {
  203. var mailVal =$('#email').val();
  204. $(".sett").each(function() {
  205. var url = mailVal.split('@')[1];
  206. for (var j in hash){
  207. $(this).attr("href", hash[url]);
  208. }
  209. });
  210. }
  211. //判断邮箱是否绑定
  212. function userRegisterOk(){
  213. var email = $("#email").val();
  214. //console.log(email);
  215. $.ajax("/ajax/isReg?key="+email,{
  216. type:"GET",
  217. async: false,
  218. success:function($data){
  219. //console.log($data);
  220. if($data.data==true){
  221. $(".msg11").text("");
  222. emailOk = true;
  223. }else{
  224. $(".msg11").text("该邮箱已绑定账号,请使用其他邮箱地址。");
  225. emailOk = false;
  226. }
  227. },
  228. error:function(){
  229. $.MsgBox.Alert('消息','服务器请求失败')},
  230. }
  231. );
  232. }
  233. var mailCode = GetQueryString('sc');
  234. //获取邮箱验证码传值注册
  235. if(mailCode!=''){
  236. $(".account-set a").eq(1).addClass("bgcolor").siblings().removeClass("bgcolor");
  237. $(".contentbox .content-set").eq(1).show().siblings().hide();
  238. $.ajax("/ajax/bindMail/"+mailCode,{
  239. type:"get",
  240. async: true,
  241. success:function(data){
  242. $.MsgBox.Alert('消息提醒','邮箱绑定成功')
  243. userpe();
  244. },
  245. error:function(){
  246. $.MsgBox.Alert('消息提醒','邮箱绑定失败')
  247. },
  248. data:{},
  249. dataType: 'json'}
  250. );
  251. }
  252. //查询用户手机号和邮箱
  253. function userpe(){
  254. $.ajax("/ajax/qaUser",{
  255. type:"get",
  256. async: true,
  257. success:function(data){
  258. //console.log(data)
  259. $.MsgBox.Alert('消息提醒','邮箱绑定成功')
  260. var emaild = data.data.email;
  261. emailhome(emaild);
  262. $.cookie('userEmail',emaild,{path:"/"});
  263. $("#emailShow").text(emailCookieshow);
  264. },
  265. error:function(){
  266. $.MsgBox.Alert('消息提醒','邮箱绑定失败')
  267. },
  268. data:{"id":$.cookie("userid")},
  269. dataType: 'json'}
  270. );
  271. }
  272. //点击邮箱激活
  273. function bindEmail(){
  274. valEmail();
  275. var email = $("#email").val();
  276. if(emailPass == true && emailOk == true){
  277. $.ajax("/ajax/reqBindMail",{
  278. type:"GET",
  279. async: false,
  280. success:function(data){
  281. //console.log(data);
  282. if(data.success){
  283. //console.log(data);
  284. if(data.data == true){
  285. //$.cookie('userEmail',email);
  286. $(".cover").hide();
  287. $("#vovernext").show();
  288. $(".emalvel").text(email);
  289. }else{
  290. $.MsgBox.Alert("消息提醒","邮箱发布失败!");
  291. }
  292. }else{
  293. $.MsgBox.Alert("消息提醒","服务器链接超时!");
  294. }
  295. },
  296. error:function(){$.MsgBox.Alert('message','fail')},
  297. data:{"userid":$.cookie("userid"),"mail":$("#email").val()},
  298. dataType: 'json'
  299. });
  300. }else{
  301. /*alert("请输入正确是邮箱地址");*/
  302. }
  303. }
  304. $("#bindgo").on("click",function(){
  305. var mailVal =$('.sett').attr("href");
  306. location.href=mailVal;
  307. })
  308. //判断手机是否绑定
  309. function phoneRegisterOk(){
  310. var phoneVal = $("#phone").val();
  311. $.ajax("/ajax/isReg?key="+phoneVal,{
  312. type:"GET",
  313. async: false,
  314. success:function($data){
  315. //console.log($data);
  316. if($data.data==true){
  317. $(".msg12").text("");
  318. phonePass = true;
  319. }else{
  320. $(".msg12").text("该手机已绑定账号,请使用其他手机号码。");
  321. }
  322. },
  323. error:function(){
  324. $.MsgBox.Alert('消息','服务器请求失败')},
  325. }
  326. );
  327. }
  328. //验证手机号是否合法
  329. var phonePass = false;
  330. function valPhone(){
  331. var phoneVal = $("#phone").val();
  332. var hunPhone=/^1[3|4|5|7|8]\d{9}$/;
  333. if(hunPhone.test(phoneVal.trim())){
  334. phoneRegisterOk();
  335. }else{
  336. phonePass = false;
  337. /*alert("手机格式正确,请输入正确的手机号码");*/
  338. $(".msg12").text("请输入正确的手机号码");
  339. }
  340. }
  341. //验证手机验证码
  342. var codePass = false;
  343. function valCode(){
  344. var phoneCode = $("#phoneCode").val();
  345. if(phoneCode.length==0){
  346. /*alert("请输入验证码");*/
  347. $(".msg13").text("请输入验证码");
  348. }else{
  349. if(!isNaN(phoneCode)){
  350. codePass = true;
  351. }else{
  352. codePass=false;
  353. $(".msg13").text("请填写数字");
  354. /*alert("请填写数字");*/
  355. }
  356. }
  357. }
  358. //发送手机验证码
  359. var phoneState;
  360. function sendPhoneCode(){
  361. valPhone();
  362. if(phonePass == true){
  363. $.ajax("/ajax/vcWithBind",{
  364. type:"GET",
  365. async: false,
  366. success:function(data){
  367. //console.log(data);
  368. if(data.success){
  369. if(data.data == null){
  370. $(".msg13").text("验证码发送失败,请确认手机号码正确!");
  371. /*alert("验证码发送失败,请确认手机号码正确!");*/
  372. }else{
  373. phoneState = data.data;
  374. $(".msg13").text("发送成功,请检查验证码");
  375. }
  376. }else{
  377. $.MsgBox.Alert("消息提醒","系统异常!");
  378. // alert("系统异常!");
  379. }
  380. },
  381. error:function(){$.MsgBox.Alert('message','fail')},
  382. data:{"userid":$.cookie("userid"),"mobilePhone":$("#phone").val()},
  383. dataType: 'json'
  384. });
  385. }else{
  386. /*alert("请输入正确是手机号码");*/
  387. }
  388. }
  389. //绑定手机号
  390. function bindPhone(){
  391. valCode();
  392. if(codePass == true){
  393. /*alert($.cookie("userid"));
  394. alert($("#phone").val());
  395. alert(phoneState);
  396. alert($("#phoneCode").val());*/
  397. var phoneVal = $("#phone").val();
  398. $.ajax("/ajax/bindMobilePhone",{
  399. type:"POST",
  400. async: false,
  401. success:function(data){
  402. if(data.success){
  403. /*alert(2);*/
  404. if(data.data == true){
  405. $.cookie('userMobilePhone',phoneVal,{path:"/"});
  406. $(".cover2").hide();
  407. $.MsgBox.Alert("消息提醒","手机绑定成功!");
  408. setTimeout(function(){
  409. location.href="account-set.html?seta=2";
  410. },1500);
  411. }else{
  412. $.MsgBox.Alert("消息提醒","短信验证不正确,请检查后重新输入。");
  413. }
  414. }else{
  415. $.MsgBox.Alert("消息提醒","系统异常!");
  416. // alert("系统异常!");
  417. }
  418. },
  419. error:function(){$.MsgBox.Alert('message','fail')},
  420. data:{"userid":$.cookie("userid"),"mobilePhone":$("#phone").val(),"validateCode":$("#phoneCode").val(),"state": phoneState},
  421. dataType: 'json'
  422. });
  423. }else{
  424. /*alert("请输入验证码是否正确");*/
  425. }
  426. }