<extend name="Public/bases" />
<block name="body" >
  <link href="__CSS__/user.css" rel="stylesheet" >
  <script src="__JS__/jquery-1.11.3.min.js"></script>
  <script type="text/javascript" src="__JS__/getRem.js"></script>
  <link rel="stylesheet" type="text/css" href="__CSS__/reset.css">
  <link rel="stylesheet" type="text/css" href="__CSS__/name.css">
  <section class="trunker">
    <section class="container">
      <form id="form"  action="" method="post" onsubmit="return false" class="">
        <div class="name">
          <!-- 子页公共头部 -->
          <div class="subpage-heard">设置新密码
            <a href="javascript:window.history.go(-1);" class="arrows"></a>
          </div>
          <div class="name-info">

            <div class="name-input">
              <div class="name-inputBox">
                <img src="__IMG__/xiugaimima.png" alt="">
                <div>新密码</div>
              </div>
              <input type="password" placeholder="请输入新密码" style="padding: 0" name="new_pwd" id="new_pwd" value="" >
            </div>

            <div class="name-input">
              <div class="name-inputBox">
                <img src="__IMG__/xiugaimima.png" alt="">
                <div>确认密码</div>
              </div>
              <input type="password" placeholder="请输入确认密码" style="padding: 0" name="new_pwd_confirm" id="new_pwd_confirm" value="">
            </div>
            <input type="hidden" id="phone" name="phone" value="{:I('phone')}">
            <div class="save submit">保存修改</div>
          </div>
        </div>
      </form>
    </section>
  </section>
  <div class="popmsg pop-dialog"></div>
  <script src="__JS__/pop.lwx.min.js"></script>
  <script src="__JS__/common.js"></script>
  <script>
    $(function() {
      var pmsg = $('.popmsg').pop();
      $(".submit").click(function(){
        var new_pwd = $.trim($("#new_pwd").val());
        var phone = $.trim($("#phone").val());
        var new_pwd_confirm = $.trim($("#new_pwd_confirm").val());
        if(new_pwd.length < 6 || new_pwd.length > 12){
          pmsg.msg('密码长度6-12个字符');
          return false;
        }
        if(new_pwd != new_pwd_confirm){
          pmsg.msg('两次密码输入不一致');
          return false;
        }

        $.ajax({
          url:"{:U('forget1')}",
          type:"POST",
          dataType:"json",
          data:{
            phone:phone,
            new_pwd:new_pwd
          },
          success:function(result){
            pmsg.msg(result.info);
            if(result.status == 1){
              setTimeout(function () {
                window.location.href = result.url;
              }, 2000);
            }
          },
          error:function(){
            alert("服务器异常");
          }
        })
      })

    });
  </script>
</block>