| | |
| | | <label class="layui-icon layui-icon-password layadmin-user-login-icon"></label> |
| | | <input id="password" class="layui-input" type="password" name="password" lay-verify="password" placeholder="密码"> |
| | | </div> |
| | | <div id="code-box" class="layui-form-item"> |
| | | <div id="code-box" class="layui-form-item" style=""> |
| | | <label id="code-label" class="layui-icon layui-icon-vercode layadmin-user-login-icon"></label> |
| | | <input id="code" class="layui-input" type="text" name="password" lay-verify="code" placeholder="验证码"> |
| | | <img id="codeImg" title="看不清?点击换一张。"> |
| | |
| | | <script type="text/javascript" src="../static/js/tools/md5.js"></script> |
| | | <script type="text/javascript"> |
| | | |
| | | // 验证码开关 |
| | | var codeSwitch = 'Y'; |
| | | $.ajax({ |
| | | url: baseUrl+"/code/switch.action", |
| | | async: false, |
| | | success: function (res) { |
| | | if (res.data === 'N'){ |
| | | codeSwitch = res.data; |
| | | $('#code-box').css("display", "none"); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | // 初始化验证码 |
| | | initCode(); |
| | | $('#codeImg').click(function () { |
| | | initCode(); |
| | | }); |
| | | function initCode() { |
| | | var random = Math.random(); |
| | | $('#codeImg').attr("src", baseUrl+"/code.action?sd="+random); |
| | |
| | | }); |
| | | }, 100); |
| | | } |
| | | initCode(); |
| | | $('#codeImg').click(function () { |
| | | initCode(); |
| | | }); |
| | | |
| | | layui.use(['form','layer'],function () { |
| | | var form = layui.form, |
| | |
| | | return; |
| | | } |
| | | var code = $("#code").val(); |
| | | if (code === "") { |
| | | if (code === "" && codeSwitch === 'Y') { |
| | | layer.msg("请输入验证码", {offset: '150px'}); |
| | | return; |
| | | } |
| | | if (sessionStorage.getItem("code").toUpperCase() !== code.toUpperCase()){ |
| | | if (sessionStorage.getItem("code").toUpperCase() !== code.toUpperCase()&&codeSwitch==='Y'){ |
| | | layer.msg("验证码错误", {offset: '150px'}); |
| | | return; |
| | | } |