123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603 |
- <!DOCTYPE html>
- <html lang="en" xmlns:th="http://www.thymeleaf.org">
- <head>
- <meta charset="UTF-8">
- <title>后台管理-登陆</title>
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta http-equiv="Access-Control-Allow-Origin" content="*">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="format-detection" content="telephone=no">
- <link rel="icon" th:href="@{/images/logo.ico}">
- <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
- <style th:inline="text">
- .main-body {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 350px;
- background: #fff;
- border-radius: 20px;
- box-shadow: 0 5px 10px rgba(0,0,0,0.2);
- -webkit-transform: translate(-50%, -50%);
- -moz-transform: translate(-50%, -50%);
- -ms-transform: translate(-50%, -50%);
- -o-transform: translate(-50%, -50%);
- overflow: hidden;
- }
- .login-main .login-bottom .center .item input {
- display: inline-block;
- width: 227px;
- height: 22px;
- padding: 0;
- position: absolute;
- border: 0;
- outline: 0;
- font-size: 14px;
- letter-spacing: 0;
- }
- .login-main .login-bottom .center .item .icon-1 {
- background: url("/images/icon-login.png") no-repeat 1px 0;
- }
- .login-main .login-bottom .center .item .icon-2 {
- background: url("/images/icon-login.png") no-repeat -54px 0;
- }
- .login-main .login-bottom .center .item .icon-3 {
- background: url("/images/icon-login.png") no-repeat -106px 0;
- }
- .login-main .login-bottom .center .item .icon-4 {
- background: url("/images/icon-login.png") no-repeat 0 -43px;
- position: absolute;
- right: -10px;
- cursor: pointer;
- }
- .login-main .login-bottom .center .item .icon-5 {
- background: url("/images/icon-login.png") no-repeat -55px -43px;
- }
- .login-main .login-bottom .center .item .icon-6 {
- background: url("/images/icon-login.png") no-repeat 0 -93px;
- position: absolute;
- right: -10px;
- margin-top: 8px;
- cursor: pointer;
- }
- .login-main .login-bottom .tip .icon-nocheck {
- display: inline-block;
- width: 10px;
- height: 10px;
- border-radius: 2px;
- border: solid 1px #9abcda;
- position: relative;
- top: 2px;
- margin: 1px 8px 1px 1px;
- cursor: pointer;
- }
- .login-main .login-bottom .tip .icon-check {
- margin: 0 7px 0 0;
- width: 14px;
- height: 14px;
- border: none;
- background: url("/images/icon-login.png") no-repeat -111px -48px;
- }
- .login-main .login-bottom .center .item .icon {
- display: inline-block;
- width: 33px;
- height: 22px;
- }
- .login-main .login-bottom .center .item {
- width: 260px;
- height: 35px;
- border-bottom: 1px solid #dae1e6;
- margin-bottom: 35px;
- }
- .login-main {
- width: 350px;
- height: 500px;
- position: relative;
- float: left;
- }
- .login-main .login-top {
- height: 150px;
- margin-top: 40px;
- border-radius: 12px 12px 0 0;
- font-family: SourceHanSansCN-Regular;
- font-size: 30px;
- font-weight: 400;
- font-stretch: normal;
- letter-spacing: 0;
- color: #fff;
- line-height: 30px;
- text-align: center;
- overflow: hidden;
- -webkit-transform: rotate(0);
- -moz-transform: rotate(0);
- -ms-transform: rotate(0);
- -o-transform: rotate(0);
- transform: rotate(0);
- }
- .login-main .login-top .avatar{
- width: 100px;
- height: 100px;
- border-radius: 50%;
- overflow: hidden;
- margin: 0 auto 20px;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .login-main .login-top .avatar img{
- width: 90%;
- height: 90%;
- object-fit: cover;
- }
- .login-main .login-top h2{
- font-size: 23px;
- font-weight: 700;
- color: #2980b9;
- margin-bottom: 20px;
- }
- .login-main .login-top .bg1 {
- display: inline-block;
- width: 74px;
- height: 74px;
- background: #fff;
- opacity: .1;
- border-radius: 0 74px 0 0;
- position: absolute;
- left: 0;
- top: 43px;
- }
- .login-main .login-top .bg2 {
- display: inline-block;
- width: 94px;
- height: 94px;
- background: #fff;
- opacity: .1;
- border-radius: 50%;
- position: absolute;
- right: -16px;
- top: -16px;
- }
- .login-main .login-bottom {
- width: 340px;
- background: #fff;
- border-radius: 0 0 12px 12px;
- padding-bottom: 53px;
- }
- .login-main .login-bottom .center {
- width: 260px;
- margin: 0 auto;
- padding-top: 40px;
- padding-bottom: 15px;
- position: relative;
- }
- .login-main .login-bottom .tip {
- clear: both;
- height: 16px;
- line-height: 16px;
- width: 260px;
- margin: 0 auto;
- }
- body {
- background: url("/images/logo-v1.png") 0% 0% / cover no-repeat;
- position: static;
- font-size: 12px;
- }
- input::-webkit-input-placeholder {
- color: #a6aebf;
- }
- input::-moz-placeholder { /* Mozilla Firefox 19+ */
- color: #a6aebf;
- }
- input:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
- color: #a6aebf;
- }
- input:-ms-input-placeholder { /* Internet Explorer 10-11 */
- color: #a6aebf;
- }
- input:-webkit-autofill { /* 取消Chrome记住密码的背景颜色 */
- -webkit-box-shadow: 0 0 0 1000px white inset !important;
- }
- html {
- height: 100%;
- }
- .login-main .login-bottom .tip {
- clear: both;
- height: 16px;
- line-height: 16px;
- width: 260px;
- margin: 0 auto;
- }
- .login-main .login-bottom .tip .login-tip {
- font-family: MicrosoftYaHei;
- font-size: 12px;
- font-weight: 400;
- font-stretch: normal;
- letter-spacing: 0;
- color: #9abcda;
- cursor: pointer;
- margin-top: 5px;
- }
- .login-main .login-bottom .tip .forget-password {
- font-stretch: normal;
- letter-spacing: 0;
- color: #2980b9;
- text-decoration: none;
- position: absolute;
- right: 62px;
- }
- .login-main .login-bottom .login-btn {
- width: 260px;
- height: 40px;
- background-color: #2980b9;
- border-radius: 16px;
- margin: 24px auto 0;
- text-align: center;
- line-height: 40px;
- color: #fff;
- font-size: 14px;
- letter-spacing: 0;
- cursor: pointer;
- border: none;
- }
- .login-main .login-bottom .center .item .validateImg {
- position: absolute;
- right: 1px;
- cursor: pointer;
- height: 36px;
- border: 1px solid #fff;
- }
- .footer {
- left: 0;
- bottom: 0;
- color: #fff;
- width: 100%;
- position: absolute;
- text-align: center;
- line-height: 30px;
- padding-bottom: 10px;
- text-shadow: #000 0.1em 0.1em 0.1em;
- font-size: 14px;
- }
- .padding-5 {
- padding: 5px !important;
- }
- .footer a, .footer span {
- color: #fff;
- }
- .logo{
- position: absolute;
- top: 50px;
- left: 50px;
- display: flex;
- align-items: center;
- }
- .logo img{
- width: 32px;
- height: 32px;
- margin-right: 10px;
- }
- .logo h2{
- font-size: 24px;
- font-weight: 700;
- color: #333;
- }
- @media screen and (max-width: 428px) {
- .login-main {
- width: 360px !important;
- }
- .login-main .login-top {
- width: 360px !important;
- }
- .login-main .login-bottom {
- width: 360px !important;
- }
- }
- </style>
- </head>
- <body>
- <div class="logo">
- <img src="/images/logo.png" alt="User Icon">
- <h2>科研管控平台</h2>
- </div>
- <div class="main-body">
- <div class="login-main">
- <div class="login-top">
- <div class="avatar">
- <img src="/images/logo.png" alt="Avatar">
- </div>
- <h2>Welcome back</h2>
- </div>
- <form class="layui-form login-bottom">
- <div class="center">
- <div class="item">
- <span class="icon icon-2"></span>
- <input type="text" name="username" id="username" lay-verify="required" placeholder="请输入登录账号"
- maxlength="24" autocomplete="current-password" />
- </div>
- <div class="item">
- <span class="icon icon-3"></span>
- <input type="password" name="password" id="password" lay-verify="required" placeholder="请输入密码"
- maxlength="20" autocomplete="current-password">
- <span class="bind-password icon icon-4"></span>
- </div>
- </div>
- <div class="tip">
- <span class="icon-nocheck"></span>
- <span class="login-tip">记住密码</span>
- <!--<a href="javascript:" class="forget-password">忘记密码?</a>-->
- </div>
- <div class="layui-form-item" style="text-align:center; width:100%;height:100%;margin:0px;">
- <button id="btn_login" class="login-btn" lay-submit lay-filter="login">
- <span id="btn_msg">登 录</span>
- <i id="btn_load" class="layui-icon layui-anim layui-anim-rotate layui-anim-loop"
- style="display: none"></i>
- </button>
- </div>
- </form>
- </div>
- </div>
- <div class="footer">
- Copyright© 2023 <span class="padding-5">|</span>
- </div>
- <script>
- const inputs = [
- document.getElementById('username'),
- document.getElementById('password')
- ]
- inputs.forEach(input =>{
- input.addEventListener('input',function () {
- this.value = this.value.replace(/\s+/g,'');
- })
- })
- </script>
- <script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
- <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
- <script th:src="@{/lib/md5/md5.min.js}" charset="utf-8"></script>
- <script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
- <script type="text/javascript" th:inline="javascript">
- AjaxUtil.ctx = /*[[@{/}]]*/'';
- // 在页面加载完毕后调用拦截器函数
- layui.use(['form', 'layNotify', 'layer'], function () {
- var form = layui.form,
- layNotify = layui.layNotify;
- var layer = layui.layer;
- var loginStatus = [[${loginStatus}]];
- if (loginStatus === 'redirect') {
- Message.error("会话已过期,请重新登录!");/*
- layNotify.notice({
- title: "登录提示",
- type: "warning",
- message: "会话已过期,请重新登录"
- });*/
- return false;
- }
- // 登录过期的时候,跳出ifram框架
- if (top.location != self.location) {
- top.location = self.location;
- }
- // 切换密码显示和隐藏
- $('.bind-password').on('click', function () {
- if ($(this).hasClass('icon-5')) {
- $(this).removeClass('icon-5');
- $("input[name='password']").attr('type', 'password');
- } else {
- $(this).addClass('icon-5');
- $("input[name='password']").attr('type', 'text');
- }
- });
- // 切换记住密码的选择
- $('.icon-nocheck').on('click', function () {
- if ($(this).hasClass('icon-check')) {
- $(this).removeClass('icon-check');
- } else {
- $(this).addClass('icon-check');
- }
- });
- if (localStorage.getItem("wowosign") == "rememberMe") {
- console.log("设置成勾选");
- // 设置成勾选
- $('.icon-nocheck').addClass('icon-check');
- }
- if (localStorage.getItem("username") && localStorage.getItem("password")) {
- console.log("浏览器记住,自动填入账号密码," + localStorage.getItem("username"))
- $("#username").val(localStorage.getItem("username"));
- $("#password").val(localStorage.getItem("password"));
- } else {
- console.log("不存在localStorage");
- }
- // // 验证码初始化
- // let kaptcha_key = [[${kaptcha_key}]];
- // getKaptcha(kaptcha_key);
- // 验证码点击事件
- // $("#ver_btn").click(function () {
- // let kaptcha_key = [[${kaptcha_key}]];
- // getKaptcha(kaptcha_key);
- // });
- // 进行登录操作
- form.on('submit(login)', function (data) {
- let formdata = data.field;
- if (formdata.username == '') {
- layer.msg('用户名不能为空');
- return false;
- }
- if (formdata.password == '') {
- layer.msg('密码不能为空');
- return false;
- }
- // if (formdata.captcha == '') {
- // layer.msg('验证码不能为空');
- // return false;
- // }
- // 未选中时,formdata.rememberMe的值为undefined
- if ($('.icon-nocheck').hasClass('icon-check')) {
- localStorage.setItem("username", formdata.username, "7d");
- localStorage.setItem("password", formdata.password, "7d");
- // localStorage.setItem("wowosign", "rememberMe", "7d");
- } else {
- localStorage.removeItem("username");
- localStorage.removeItem("password");
- // localStorage.removeItem("wowosign");
- }
- // 添加一个条件判断
- let password = md5.MD5(formdata.password); // 加密输入的密码
- // 设置按钮为登陆中,此时禁止点击
- logining();
- AjaxUtil.post({
- contentType: "application/x-www-form-urlencoded", // 默认就是这个
- url: AjaxUtil.ctx + "home/doLogin",
- data: {
- "username": formdata.username,
- "password": password
- },
- success: function (res) {
- console.log(res);
- if (res.code === 0) {
- layNotify.notice({
- title: "登录提示",
- type: "success",
- message: res.message
- });
- setTimeout(function () {
- window.location.href = AjaxUtil.ctx + "home/index";
- }, 1500);
- } else {
- loginend();
- layNotify.notice({
- title: "登录提示",
- type: "warning",
- message: res.message
- });
- // document.getElementById("ver_btn").click();
- // 验证码刷新
- /* document.getElementById("captcha").value = '';*/
- document.getElementById("password").value = '';
- console.log(res.message);
- // 阻止后续操作
- }
- },
- error: function (error) {
- loginend();
- redirection();
- layNotify.notice({
- title: "登录提示",
- type: "error",
- message: "请求失败,请联系系统管理员!"
- });
- }
- });
- return false; //阻止表单跳转,layui默认是form提交,阻止掉
- });
- // 键盘回车登录
- $('body').keydown(function () {
- if (13 == event.keyCode) {
- $('#btn_login').trigger('click');
- }
- });
- function redirection() {
- window.location.replace("http://10.208.114.107:8081/home/index")
- }
- // 登陆中
- function logining() {
- document.getElementById("btn_login").setAttribute("disabled", true);//设置不可点击
- document.getElementById("btn_login").style.backgroundColor = '#9abcda';
- document.getElementById("btn_msg").innerText = '登 录 中';
- document.getElementById("btn_load").style.display = "inline-block";
- }
- // 登陆后
- function loginend() {
- document.getElementById("btn_login").removeAttribute("disabled");//去掉不可点击
- document.getElementById("btn_login").style.backgroundColor = '#1E9FFF';
- document.getElementById("btn_msg").innerText = '登 录';
- document.getElementById("btn_load").style.display = "none";
- }
- // function getKaptcha(kaptcha_key) {
- // AjaxUtil.get({
- // url: AjaxUtil.ctx + "kaptcha/getImage?kaptcha_key=" + kaptcha_key,
- // dataType: "text",
- // success: function (result) {
- // $("#ver_btn").attr("src", result);
- // },
- // error: function (error) {
- // layNotify.notice({
- // title: "提示",
- // type: "warning",
- // message: "获取验证码错误,请联系系统管理员!"
- // });
- // }
- // });
- // }
- });
- </script>
- </body>
- </html>
|