sso

modify_pwd.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. $(function() {
  2. //获取验证码
  3. $("#get_code").click(function() {
  4. var phone = $("#phone").val();
  5. var aespass = $('#aespass').val();
  6. if (!checkPhone(phone)) {
  7. return;
  8. }
  9. var postData = {
  10. phone: phone,
  11. aespass: aespass,
  12. }
  13. $("#get_code").attr("disabled", true);
  14. changeNum(60);
  15. postRequest("/getcode", postData, doSuccess, doFail);
  16. function doSuccess(res) {
  17. if (res.state == 0) {
  18. serverErrorMsg(res);
  19. return;
  20. }
  21. layer.msg(res.data.msg);
  22. }
  23. });
  24. //确定
  25. $("#submit").click(function() {
  26. var code = $("#code").val();
  27. if (code != null && code != undefined && code != "") {
  28. var mobile = $("#phone").val();
  29. var password = $("#password").val();
  30. if (canSure(phone, password)) {
  31. var postData = {
  32. mobile: mobile,
  33. password: hex_md5(password),
  34. code: code,
  35. }
  36. postRequest("/password/modify", postData, doSuccess, doFail);
  37. function doSuccess(res) {
  38. if (res.state == 0) {
  39. serverErrorMsg(res);
  40. return;
  41. }
  42. // $(".layerBg").show();
  43. // $(".layerSuccess").show();
  44. window.location.href = "/login"
  45. }
  46. } else {
  47. return;
  48. }
  49. }
  50. });
  51. document.onkeydown = function(event) {
  52. var e = event || window.event || arguments.callee.caller.arguments[0];
  53. if (e && e.keyCode == 13) { // enter 键
  54. $("#submit").click();
  55. }
  56. };
  57. });
  58. function doFail(res) {
  59. serverErrorMsg(res);
  60. }
  61. function checkPhone(phone) {
  62. if (!phone || phone == "") {
  63. layer.msg("手机号码不能为空");
  64. return false;
  65. }
  66. if (!(/^1\d{10}$/.test(phone))) {
  67. layer.msg("手机号码有误,请重填");
  68. return false;
  69. }
  70. return true;
  71. }
  72. function canSure(phone, password) {
  73. if (!phone || phone == "") {
  74. layer.msg("手机号码不能为空");
  75. return false;
  76. }
  77. if (!password) {
  78. layer.msg('密码为空');
  79. return false;
  80. }
  81. if (password.length < 6) {
  82. layer.msg('密码至少要6位数');
  83. return false;
  84. }
  85. return true;
  86. }
  87. function changeNum(num) {
  88. setTimeout(function() {
  89. if (num > 1) {
  90. $('#get_code').html(num + "s");
  91. --num;
  92. changeNum(num);
  93. } else {
  94. $('#get_code').html("发送验证码");
  95. $("#get_code").attr("disabled", false);
  96. }
  97. }, 1000);
  98. }