<!DOCTYPE html>
<html>
  
  <head>
    @include('admin.common_bak.header')
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-body">
        <form class="layui-form" id="forgot-pass">
          {{ csrf_field() }}
          <input type="hidden" name="_token" value="{{csrf_token()}}">
          <input type="hidden" name="id" value="{{$user->id}}">
          <div class="layui-form-item">
              <label for="L_username" class="layui-form-label">
                  昵称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="L_username" name="name" disabled="" value="{{$user['name']}}" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_pass" class="layui-form-label">
                  <span class="x-red">*</span>新密码
              </label>
              <div class="layui-input-inline">
                  <input type="password" id="L_pass" name="password" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  6到16个字符
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
                  <span class="x-red">*</span>确认密码
              </label>
              <div class="layui-input-inline">
                  <input type="password" id="L_repass" name="repass" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="save" lay-submit="">
                  修改
              </button>
          </div>
      </form>
    </div>
    <script>
            layui.use(['form','layer'], function(){
                $ = layui.jquery;
              var form = layui.form
              ,layer = layui.layer;
              //监听提交
              form.on('submit(save)', function(data){
                //console.log(data);
                var opts = new FormData(data.form);
                fetch_response('POST','/web/password/{{$user->id}}',opts).then(function(res){
                  if(res.code==200){
                    layer.alert("修改成功", {icon: 6},function () {
                        var index = parent.layer.getFrameIndex(window.name);// 获得frame索引
                        parent.layer.close(index);//关闭当前frame
                        //window.parent.location.reload(); //刷新父页面
                    });
                  }else{
                    layer.msg(res.msg,{icon:5});
                  }
                });
                return false;
              });
            });
        </script>
  </body>
</html>