<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>沃流量-定向流量管理子模块-s3</title>
    <link rel="stylesheet" href="${ctxPath}/plugins/layui/css/layui.css">
    <script src="${ctxPath}/plugins/layui/layui.js"></script>
  <script src="${ctxPath}/plugins/jquery/jquery.min.js"></script>
  <script src="${ctxPath}/js/lib-js.js"></script>
   <script src="${ctxPath}/js/pass.js" ></script>
    <!-- 让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]-->
    <style rel="stylesheet" type="text/css">
        .layui-tab-title li:first-child > i {
            display: none;
        }
    </style>

</head>
<body class="layui-layout-body">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend class="center-pill">沃流量-定向流量管理子模块-s3</legend>
</fieldset>
<form class="layui-form" action="${ctxPath}/login.do" method="post" id = "subform" lay-filter="example">
  <div class="layui-form-item">
    <label class="layui-form-label">用户名</label>
    <div class="layui-input-block">
      <input type="text" name="code" lay-verify="title" autocomplete="off"  id="code"
      	placeholder="请输入用户名" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-block">
      <input type="password" name="password" lay-verify="required" placeholder="请输入密码" autocomplete="off" id = "password" lay-filter="pwd"
       class="layui-input">
    </div>
  </div>
    <div class="layui-form-item">
        <label class="layui-form-label">验证码</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required"  name="checkcode" placeholder="请输入验证码" autocomplete="off" id="checkcode"
                   class="layui-input">
        </div>
       </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <img id="checkcodeImg" src="${ctxPath}/image/code" >
            <a href="javascript:void(0);" onclick="changeImg();" style="color:#000000;">看不清？</a>
        </div>
    </div>
    <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="demo1" id = "subBtn"  >立即登录</button>
    </div>
  </div>

  </form>
<script type="text/javascript">
 layui.config({
    base: './js/util/' //配置 layui 第三方扩展组件存放的基础目录
}).extend({
}).use(["form","jquery"], function () {
    var form  = layui.form
    ,layer = layui.layer //弹层
    ,$= layui.jquery;
     form.verify({
         password: [/^[\S]{8,25}$/,'密码必须8到25位，且不能出现空格']
     });
     var error ='${error}';
     if(error!='0000'){
         alert(error);
     }

    });
     function changeImg(){
            var img = document.getElementById("checkcodeImg");
            img.src = "${ctxPath}/image/code?"+Math.random();

     };
       function getMess(message, data){
        var keyHex = CryptoJS.enc.Utf8.parse(data);
        var encrypted = CryptoJS.DES.encrypt(message, keyHex, {
            mode: CryptoJS.mode.ECB,
            padding: CryptoJS.pad.Pkcs7
        });
        return encrypted.ciphertext.toString().toUpperCase();
    };

 /**
  * 通用表单提交(AJAX方式)
  */
 $('#subform').submit(function() {
     if(!$('#password').val()){
         alert("请输入密码");
         return false;
     }
     if(!$('#code').val()){
         alert("请输入用户名");
         return false;
     }
     if(!$('#checkcode').val()){
         alert("请输入验证码");
         return false;
     }
     //加密
     var data = getPass();
     var password = getMess($('#password').val(),data);
     $("#password").val(password);
     return true;
 });









</script>
</body>
</html>