portal html css js resource

pwdFindNew.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. $(function() {
  2. loginStatus();//判断个人是否登录
  3. var slef = GetQueryString("slef");
  4. if(slef==1){
  5. $("#gophone").addClass("liactive").prev().removeClass("liactive");
  6. $(".emailmain").addClass("displayNone");
  7. $(".phonemain").removeClass("displayNone");
  8. }
  9. $(".loginWaySort").on("click", "li", function() {
  10. $(this).parents("#container").find("input").val("");
  11. $(this).parents("#container").find(".frmmsg span").text("");
  12. $(this).parents("#container").find("input").removeClass("frmmsg-warning");
  13. $(this).parents("#container").find(".loginSubmit").attr("disabled", true);
  14. $("#getcode").attr("disabled", true);
  15. $(this).addClass("liactive").siblings().removeClass("liactive");
  16. $(".loginWays .waysThis").eq($(this).index()).removeClass("displayNone").siblings().addClass("displayNone");
  17. })
  18. })
  19. var isEmail = false;
  20. var passwordPass = false;
  21. var codePass = false;
  22. var verification = false;
  23. var namePass = false;
  24. /*校验通过邮箱找回点击下一步*/
  25. function checkEmailButtn(_this) {
  26. var email = $(_this).parents(".cmpCoverUl").find("#email").val();
  27. if(email == "") {
  28. $(_this).parents(".cmpCoverUl").find(".loginSubmit").attr("disabled", true);
  29. } else {
  30. $(_this).parents(".cmpCoverUl").find(".loginSubmit").attr("disabled", false);
  31. }
  32. }
  33. /*校验登录按钮显示状态*/
  34. function checkLoginButtn(_this) {
  35. var username = $(_this).parents(".cmpCoverUl").find(".username").val();
  36. var companysc = $(_this).parents(".cmpCoverUl").find(".companysc").val();
  37. if(username == "" || companysc == "") {
  38. $(_this).parents(".cmpCoverUl").find(".loginSubmit").attr("disabled", true);
  39. } else {
  40. $(_this).parents(".cmpCoverUl").find(".loginSubmit").attr("disabled", false);
  41. }
  42. }
  43. /*获取焦点*/
  44. function getFocus(_this) {
  45. $(_this).next().find("span").text("");
  46. $(_this).removeClass("frmmsg-warning");
  47. }
  48. //校验邮箱账户
  49. function emailVal(_this) {
  50. var loginName = $(_this).val();
  51. var gunf = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
  52. if(loginName.length == "") {
  53. $(_this).next().find("span").text("请输入您的邮箱地址");
  54. $(_this).addClass("frmmsg-warning");
  55. } else if(gunf.test(loginName.trim())) {
  56. userRegisterOk(_this);
  57. $(_this).next().find("span").text("");
  58. $(_this).removeClass("frmmsg-warning");
  59. isEmail = true;
  60. }else {
  61. $(_this).next().find("span").text("请输入正确的邮箱地址");
  62. $(_this).addClass("frmmsg-warning");
  63. }
  64. }
  65. //校验登录手机账户
  66. function phoneVal(_this) {
  67. var loginName = $(_this).val();
  68. var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
  69. if(loginName.length == "") {
  70. $(_this).next().find("span").text("请输入您的手机号码");
  71. $(_this).addClass("frmmsg-warning");
  72. } else if(hunPhone.test(loginName.trim())) {
  73. userRegisterOk(_this);
  74. $(_this).next().find("span").text("");
  75. $(_this).removeClass("frmmsg-warning");
  76. namePass = true;
  77. } else {
  78. $(_this).next().find("span").text("请输入正确的手机号码");
  79. $(_this).addClass("frmmsg-warning");
  80. $("#getcode").attr("disabled", true);
  81. }
  82. }
  83. //判断账号是否注册
  84. function userRegisterOk(_this) {
  85. var loginName = $(_this).val();
  86. $.ajax("/ajax/isReg?key=" + loginName, {
  87. type: "GET",
  88. async: true,
  89. success: function($data) {
  90. if($data.data == true) {
  91. $(_this).next().find("span").text("该账号不存在,请检查后重试");
  92. $(_this).addClass("frmmsg-warning");
  93. } else {
  94. $(_this).next().find("span").text("");
  95. $(_this).removeClass("frmmsg-warning");
  96. $("#getcode").attr("disabled", false);
  97. }
  98. },
  99. error: function() {
  100. $.MsgBox.Alert('消息', '服务器请求失败')
  101. },
  102. });
  103. }
  104. //校验登录密码
  105. function passwordVal(_this) {
  106. var passwd = $(_this).val();
  107. var passwd2 = $("#newPassword").val();
  108. if(passwd.length == "") {
  109. $(_this).next().find("span").text("请设置您的登录密码");
  110. $(_this).addClass("frmmsg-warning");
  111. } else if(passwd.length < 6) {
  112. $(_this).next().find("span").text("密码由6-24个字符组成,区分大小写");
  113. $(_this).addClass("frmmsg-warning");
  114. } else if(passwd != passwd2) {
  115. $(_this).next().find("span").text("两次输入不一致,请重新输入");
  116. $(_this).addClass("frmmsg-warning");
  117. } else {
  118. $(_this).next().find("span").text("");
  119. $(_this).removeClass("frmmsg-warning");
  120. passwordPass = true;
  121. }
  122. }
  123. //验证短信验证码
  124. function codeVerification(_this) {
  125. var code = $(_this).val();
  126. var reg = /^\d{4}$/;
  127. if(code.length == "") {
  128. $(_this).next().find("span").text("请输入您收到的短信验证码");
  129. $(_this).addClass("frmmsg-warning");
  130. } else if(!reg.test(code)) {
  131. $(_this).next().find("span").text("验证码为4位数字");
  132. $(_this).addClass("frmmsg-warning");
  133. } else {
  134. $(_this).next().find("span").text("");
  135. $(_this).removeClass("frmmsg-warning");
  136. verification = true;
  137. }
  138. }
  139. //手机发送验证码
  140. function phoneSend(_this) {
  141. doClick(_this);
  142. phoneVerificationCode(_this);
  143. }
  144. function doClick(_this) {
  145. $(_this).attr("disabled", true);
  146. $(_this).text("60s后重新获取");
  147. var clickTime = new Date().getTime();
  148. var Timer = setInterval(function() {
  149. var nowTime = new Date().getTime();
  150. var second = Math.ceil(60 - (nowTime - clickTime) / 1000);
  151. if(second > 0) {
  152. $(_this).text(second + "s后重新获取");
  153. } else {
  154. clearInterval(Timer);
  155. $(_this).text("获取验证码");
  156. $(_this).attr("disabled", false);
  157. }
  158. }, 1000);
  159. }
  160. //手机发送验证码结束
  161. var state;
  162. function phoneVerificationCode(_this) {
  163. var lp_phone = $(_this).parents(".cmpCoverUl").find(".username").val();
  164. $.ajax("/ajax/sendMobileForLogin", {
  165. type: "get",
  166. dataType: 'json',
  167. data: {
  168. "mobilePhone": lp_phone
  169. },
  170. async: true,
  171. success: function(data) {
  172. console.log(JSON.stringify(data))
  173. if(data.success) {
  174. state = data.data;
  175. }
  176. },
  177. error: function() {
  178. $.MsgBox.Alert('消息', '服务器请求失败')
  179. }
  180. });
  181. };
  182. //验证邀请码
  183. function codeVal(_this) {
  184. var code = $(_this).val();
  185. var reg = /^\d{6}$/;
  186. if(code.length == "") {
  187. $(_this).next().find("span").text("请输入您收到的邀请码");
  188. $(_this).addClass("frmmsg-warning");
  189. } else if(!reg.test(code)) {
  190. $(_this).next().find("span").text("邀请码为6位数字");
  191. $(_this).addClass("frmmsg-warning");
  192. } else {
  193. $(_this).next().find("span").text("");
  194. $(_this).removeClass("frmmsg-warning");
  195. codePass = true;
  196. }
  197. }
  198. //判断用户第一次登录,是否填写了个人信息
  199. function firstLogin() {
  200. var professorId = $.cookie('userid');
  201. $.ajax({
  202. "url": "ajax/professor/" + professorId,
  203. "type": "get",
  204. "async": false,
  205. "success": function(data) {
  206. if(data.success) {
  207. if(data.data.authentication != undefined || data.data.authentication != null){
  208. window.history.back();
  209. }else{
  210. location.href = "fillinfo-select.html?id=" + professorId;
  211. }
  212. }
  213. },
  214. "error": function() {
  215. $.MsgBox.Alert('消息', '服务器请求失败')
  216. }
  217. })
  218. }
  219. //手机验证码登录
  220. function VerificationLogin(_this) {
  221. var loginName = $(_this).parents(".cmpCoverUl").find(".username");
  222. var code = $(_this).parents(".cmpCoverUl").find(".passwd");
  223. if(namePass && verification) {
  224. $.ajax("/ajax/mobileLogin", {
  225. type: "POST",
  226. dataType: 'json',
  227. data: {
  228. "state": state,
  229. "mobilePhone": loginName.val(),
  230. "validateCode": code.val()
  231. },
  232. async: false,
  233. success: function(data) {
  234. console.log(data)
  235. if(data.success) {
  236. if(data.data != "null" && data.data != null) {
  237. submitCodeVal();
  238. }
  239. } else {
  240. if(data.code == -1) {
  241. $(_this).parents(".cmpCoverUl").find(".msgCmp03 span").text("验证超时");
  242. } else if(data.code == -3 || data.code == 0) {
  243. $(_this).parents(".cmpCoverUl").find(".msgCmp03 span").text("验证码错误,请检查后重试");
  244. }
  245. }
  246. },
  247. error: function() {
  248. $.MsgBox.Alert('消息', '服务器请求失败');
  249. },
  250. });
  251. }
  252. }
  253. //手机找回密码提交发送
  254. function submitCodeVal(_this){
  255. if(namePass && verification){
  256. $.ajax("/ajax/validCode",{
  257. type:"POST",
  258. async: false,
  259. success:function(data){
  260. if(data.success){
  261. if(data.data == true){
  262. $(".phoneTwo").removeClass("displayNone");
  263. $(".phoneOne").addClass("displayNone");
  264. $("#pstate").val(state);
  265. $("#pmobilePhone").val($(".username").val());
  266. $("#pvc").val($("#companysc").val());
  267. }else{
  268. $(_this).parents(".cmpCoverUl").find(".msgCmp03 span").text("验证码错误,请检查后重试");
  269. }
  270. }else{
  271. $(_this).parents(".cmpCoverUl").find(".msgCmp03 span").text("验证超时");
  272. }
  273. },
  274. error:function(){$.MsgBox.Alert('消息', '服务器请求失败');},
  275. data:{"vc":$("#companysc").val(),"state":state},
  276. dataType: 'json'
  277. });
  278. }
  279. }
  280. //邮箱发送
  281. function findBack(){
  282. if(isEmail){
  283. $.ajax("/ajax/reqRpWithEmail",{
  284. type:"GET",
  285. async: false,
  286. success:function(data){
  287. if(data.success){
  288. $(".emailOne").addClass("displayNone");
  289. $(".emailTow").removeClass("displayNone");
  290. $("#emailShow").text($("#email").val());
  291. }
  292. },
  293. error:function(){$.MsgBox.Alert('消息', '服务器请求失败')},
  294. data:{"mail":$("#email").val()},
  295. dataType: 'json'
  296. });
  297. }
  298. }
  299. function findphone(_this){
  300. if(passwordPass){
  301. $.ajax("/ajax/resetPasswordWithMobilePhone",{
  302. type:"POST",
  303. async: false,
  304. success:function(data){
  305. console.log(data)
  306. if(data.success){
  307. if(data.data == true){
  308. location.href = "pwdResult.html?num=1";
  309. }else{
  310. $(_this).parents(".cmpCoverUl").find(".msgCmp4 span").text("验证码错误,请检查后重试");
  311. }
  312. }else{
  313. $(_this).parents(".cmpCoverUl").find(".msgCmp4 span").text("验证超时");
  314. al
  315. }
  316. },
  317. error:function(){$.MsgBox.Alert('消息', '服务器请求失败')},
  318. data:{"vc":$("#pvc").val(),"state":$("#pstate").val(),"mobilePhone":$("#pmobilePhone").val(),"pw":$("#newPasswordok").val()},
  319. dataType: 'json'
  320. });
  321. }
  322. }
  323. //提交登录
  324. function backPassword(_this, num) {
  325. if(num == 1) {
  326. findBack()
  327. } else if(num == 2) {
  328. var url = $("#emailShow").text().split('@')[1];
  329. for (var j in hash){
  330. if(hash[url]==undefined){
  331. location.href="http://mail." + url;
  332. }else{
  333. $(_this).attr("href", hash[url]);
  334. location.href=hash[url];
  335. }
  336. }
  337. } else if(num == 3) {
  338. submitCodeVal(_this);
  339. }else if(num==4){
  340. findphone(_this);
  341. }
  342. }