changeMobile.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3. <div th:replace="~{mobile/header :: header}"></div>
  4. <body>
  5. <header>
  6. <a class="back" href="javascript:history.go(-1);"> <i class="iconfont icon-fanhui"></i></a>
  7. <span >更改手机号</span>
  8. </header>
  9. <!-- 内容 -->
  10. <section class="content has_header">
  11. <div class="form">
  12. <div class="form_item">
  13. <input type="text" readonly id="oldMobile" placeholder="原始号码:">
  14. </div>
  15. <div class="form_item">
  16. <input type="text" id="newMobile" placeholder="新号码:">
  17. </div>
  18. <div class="form-btn">
  19. <button class="btn btn_yellow" onclick="submit()">提交</button>
  20. <button class="btn btn_yellow" onclick="javascript:history.go(-1);">取消</button>
  21. </div>
  22. </div>
  23. </section>
  24. <script>
  25. $(function(){
  26. bindInfo();
  27. });
  28. function bindInfo(){
  29. $.ajax({
  30. type: "Get",
  31. dataType: "json",
  32. url: pagePath+"/mobile/account/getUserMobile",
  33. data: {
  34. },
  35. success: function (result) {
  36. if (result.success) {
  37. var user = result.obj;
  38. $("#oldMobile").val(user.phone);
  39. } else {
  40. sadMessage(result.message);
  41. }
  42. },
  43. error: function () {
  44. sadMessage("系统错误!");
  45. }
  46. });
  47. }
  48. function submit(){
  49. var newMobileObj = $("#newMobile");
  50. $.ajax({
  51. type: "POST",
  52. dataType: "json",
  53. url: pagePath+"/mobile/account/updateMobile",
  54. data: {
  55. "mobile":$("#newMobile").val()
  56. },
  57. beforeSend: function () {
  58. if (!validateMobile(newMobileObj.val())) {
  59. sadMessage("请输入正确的手机号!");
  60. newMobileObj.focus();
  61. return false;
  62. }
  63. },
  64. success: function (result) {
  65. if (result.success) {
  66. smileMessage(result.message);
  67. location.href(history.go(-1));
  68. } else {
  69. sadMessage(result.message);
  70. }
  71. },
  72. error: function () {
  73. sadMessage("系统错误!");
  74. }
  75. });
  76. }
  77. function validateMobile(value){
  78. var length = value.length;
  79. var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
  80. return length == 11 && value.test(mobile);
  81. }
  82. </script>
  83. </body>
  84. </html>