Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bind_mobile.htm 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>绑定邮箱-{eyou:global name='web_name' /}</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
  9. {eyou:static file="users/skin/css/basic.css" /}
  10. {eyou:static file="users/skin/css/eyoucms.css" /}
  11. {eyou:include file="users/skin/css/diy_css.htm" /}
  12. {eyou:static file="/public/static/common/js/jquery.min.js"/}
  13. {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
  14. {eyou:static file="/public/static/common/js/tag_global.js"/}
  15. {eyou:static file="/public/static/common/js/mobile_global.js"/}
  16. <style type="text/css">
  17. #theForm .form-group{
  18. margin:20px 0px 10px;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <div class="changepass">
  24. <form name='theForm' id="theForm" method="post">
  25. <div class="modal-body">
  26. <div class="form-group">
  27. <div class="input-group">
  28. <input type="text" name="mobile" id="mobile" {eyou:eq name='$users.is_mobile' value='0'} value="{$users.mobile}" {/eyou:eq} required class="form-control" placeholder="新的手机号码" maxlength="11">
  29. </div>
  30. </div>
  31. <div class="form-group">
  32. <div class="input-group yxrz">
  33. <input type="text" class="form-control" id="mobile_code" name="mobile_code" placeholder="手机验证码">
  34. <input type="button" id="mobile_button" onclick="get_mobile_code();" class="btn btn-primary" value="获取验证码" />
  35. </div>
  36. </div>
  37. </div>
  38. <div class="modal-footer">
  39. <button type="button" class="btn btn-primary" style="width: 100%;" onclick="SubmitData();">确定</button>
  40. </div>
  41. </form>
  42. </div>
  43. <script type="text/javascript">
  44. function get_mobile_code() {
  45. var mobile = $("#mobile").val();
  46. // 手机号是否为空
  47. if (!mobile) {
  48. $("#mobile").focus();
  49. layer.msg('请输入新的手机号码!', {time: 1500});
  50. return false;
  51. }
  52. // 手机格式不正确
  53. var reg = /^1[0-9]{10}$/i;
  54. if (!reg.test(mobile)) {
  55. $("#mobile").focus();
  56. layer.msg('请输入正确的新的手机号码!', {time: 1500});
  57. return false;
  58. }
  59. // 设置为不可点击
  60. $("#mobile_button").val('获取中…').attr('disabled', 'disabled');
  61. layer_loading('正在处理');
  62. $.ajax({
  63. url: '{$RootDir}/index.php?m=api&c=Ajax&a=SendMobileCode&_ajax=1',
  64. data: {mobile: mobile, is_mobile: true, source: 1},
  65. type:'post',
  66. dataType:'json',
  67. success:function(res){
  68. if (res.code == 1) {
  69. countdown();
  70. layer.msg(res.msg, {time: 1500});
  71. } else {
  72. $("#mobile_button").val('获取验证码').removeAttr("disabled");
  73. showErrorAlert(res.msg);
  74. }
  75. },
  76. error : function(e) {
  77. $("#mobile_button").val('获取验证码').removeAttr("disabled");
  78. showErrorAlert(e.responseText);
  79. }
  80. });
  81. }
  82. function countdown() {
  83. // 倒计时
  84. var setTime;
  85. var time = 120;
  86. setTime = setInterval(function() {
  87. if(0 >= time){
  88. clearInterval(setTime);
  89. return;
  90. }
  91. time--;
  92. $("#mobile_button").val(time+'秒').attr('disabled', 'disabled');
  93. if(time == 0) $("#mobile_button").val('获取验证码').removeAttr("disabled");
  94. }, 1000);
  95. };
  96. function SubmitData() {
  97. var mobile = $("#mobile").val();
  98. var reg = /^1[0-9]{10}$/i;
  99. // 邮箱格式不正确
  100. if(!reg.test(mobile)) {
  101. layer.msg('请正确输入手机号码!', {time: 2000});
  102. return false;
  103. }
  104. var mobile_code = $("#mobile_code").val();
  105. if(!mobile_code) {
  106. layer.msg('手机验证码不能为空!', {time: 2000});
  107. return false;
  108. }
  109. var _parent = parent;
  110. var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  111. layer_loading('正在处理');
  112. $.ajax({
  113. url: '{$RootDir}/index.php?m=user&c=Users&a=bind_mobile&_ajax=1',
  114. data: $('#theForm').serialize(),
  115. type:'post',
  116. dataType:'json',
  117. success:function(res){
  118. layer.closeAll();
  119. if (res.code == 1) {
  120. parent.layer.close(parentObj);
  121. parent.layer.msg(res.msg, {time: 1500}, function() {
  122. _parent.window.location.reload();
  123. });
  124. } else {
  125. showErrorAlert(res.msg);
  126. }
  127. },
  128. error : function(e) {
  129. layer.closeAll();
  130. showErrorAlert(e.responseText);
  131. }
  132. });
  133. };
  134. </script>
  135. </body>
  136. </html>