| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <!DOCTYPE html>
- <html xmlns:th="http://www.thymeleaf.org"
- xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
- layout:decorate="~{admin/common/common}">
- <head>
- </head>
- <body layout:fragment="content">
- <article class="page-container">
- <form class="form form-horizontal" id="form-edit">
- <input type="hidden" th:name="id" th:id="uid" th:value="${id}"/>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-4"><span class="c-red">*</span>手机号:(重新登录后生效)</label>
- <div class="formControls col-xs-8 col-sm-6">
- <input type="text" class="input-text" placeholder="请输入想要修改成的手机号" id="phone" name="phone" />
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-4"><span class="c-red">*</span>验证码:</label>
- <div class="formControls col-xs-8 col-sm-4">
- <input type="text" class="input-text" placeholder="请输入验证码" id="verification_code" name="verification_code" />
- </div>
- <div class="formControls col-xs-4 col-sm-2">
- <input id="verificationCode" class="btn btn-primary radius" onclick="getVerificationCode()" value="获取验证码" type="button"/>
- </div>
- </div>
-
- <div class="row cl">
- <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
- <input class="btn btn-primary radius" type="submit" value=" 提交 ">
- <button onClick="removeIframe();" class="btn btn-default radius" type="button"> 取消 </button>
- </div>
- </div>
- </form>
- </article>
-
- <script th:inline="javascript">
- /**
- * 取消
- */
- function removeIframe() {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- }
-
- //获取验证码
- function getVerificationCode() {
- var phone = $("#phone").val();
- var v_regex = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
- if (phone) {
- if (v_regex.test(phone)) {
- //checkPhoneNumber(phone)
- startCountDown();
- sendVerificationCode(phone);
- } else {
- errorMessage('手机号码格式不正确!');
- }
- } else {
- errorMessage('请输入手机号码!');
- }
- }
- //发送验证码
- function sendVerificationCode(phone) {
- $.ajax({
- contentType: "application/json;charset=utf-8",
- dataType: "json",
- url: pagePath + "/home/sendVerificationCode",
- type: "get",
- sync: true,
- data: {
- phone: phone
- },
- success: function (result) {
- if (result.success) {
- succeedMessage(result.message);
- //startCountDown();
- } else {
- errorMessage(result.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- }
- //验证码倒计时
- function startCountDown() {
- var second = 60;//时间默认值
- $("#verificationCode").attr("disabled", true);
- var timer = null;
- timer = setInterval(function () {
- $("#verificationCode").val(second + "秒后重发")
- second--;
- if (second < 0) {
- $("#verificationCode").attr("disabled", false);
- $("#verificationCode").val("获取验证码")
- clearInterval(timer);
- }
- }, 1000);
- }
-
- $(function(){
- var userId = [[${id}]];
- $("#form-edit").validate({
- rules:{
- phone: {
- required: true,
- isMobile: true,
- }
- },
- onkeyup:false,
- focusCleanup:true,
- success:"valid",
- submitHandler:function(form){
- $(form).ajaxSubmit({
- type: 'put',
- url: pagePath+"/admin/user/updateUser/"+userId,
- dataType:"json",
- success: function(data){
- if(data.status == "success"){
- succeedMessage(data.message);
- setTimeClose();
- }else {
- // $(form).find(":submit").attr("disabled", false);
- errorMessage(data.message);
- }
- }
- });
- return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
- },
- errorPlacement: function(error, element) {
-
- if(element.attr('id') == 'content'){
- error.addClass(' label_error')
- }
- error.appendTo(element.parent());
- }
- });
- });
-
- </script>
- </body>
- </html>
|