You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
13 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- 设置文档的字符编码为UTF-8 -->
<title>后台管理-登陆</title>
<!-- 设置网页标题为“后台管理-登陆” -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- 设置浏览器兼容模式优先使用最新版本的IE和Chrome内核 -->
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<!-- 允许所有来源的跨域请求 -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- 设置视口宽度等于设备宽度初始缩放比例为1最大缩放比例为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="stylesheet" href="../lib/layui-v2.5.5/css/layui.css"
<!-- LayuiCSS -->
<!--[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>
/* 设置主内容区域的样式,使其居中显示 */
.main-body {top:50%;left:50%;position:absolute;-webkit-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);-o-transform:translate(-50%,-50%);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;}
/* 设置图标1的背景图片位置 */
.login-main .login-bottom .center .item .icon-1 {background:url(../images/icon-login.png) no-repeat 1px 0;}
/* 设置图标2的背景图片位置 */
.login-main .login-bottom .center .item .icon-2 {background:url(../images/icon-login.png) no-repeat -54px 0;}
/* 设置图标3的背景图片位置 */
.login-main .login-bottom .center .item .icon-3 {background:url(../images/icon-login.png) no-repeat -106px 0;}
/* 设置图标4的背景图片位置和样式 */
.login-main .login-bottom .center .item .icon-4 {background:url(../images/icon-login.png) no-repeat 0 -43px;position:absolute;right:-10px;cursor:pointer;}
/* 设置图标5的背景图片位置 */
.login-main .login-bottom .center .item .icon-5 {background:url(../images/icon-login.png) no-repeat -55px -43px;}
/* 设置图标6的背景图片位置和样式 */
.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:288px;height:35px;border-bottom:1px solid #dae1e6;margin-bottom:35px;}
/* 设置登录框的宽度和浮动属性 */
.login-main {width:428px;position:relative;float:left;}
/* 设置顶部区域的高度、背景颜色等样式 */
.login-main .login-top {height:117px;background-color:#148be4;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:117px;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 .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:428px;background:#fff;border-radius:0 0 12px 12px;padding-bottom:53px;}
/* 设置底部中心区域的样式 */
.login-main .login-bottom .center {width:288px;margin:0 auto;padding-top:40px;padding-bottom:15px;position:relative;}
/* 设置提示信息的样式 */
.login-main .login-bottom .tip {clear:both;height:16px;line-height:16px;width:288px;margin:0 auto;}
/* 设置页面背景图片和字体大小 */
body {background:url(../images/login-bg3.jpg) 0% 0% / cover no-repeat;position:static;font-size:12px;}
/* 设置输入框在Webkit浏览器中的占位符样式 */
input::-webkit-input-placeholder {color:#a6aebf;}
/* 设置输入框在Mozilla Firefox浏览器中的占位符样式 */
input::-moz-placeholder {color:#a6aebf;}
/* 设置输入框在旧版Mozilla Firefox浏览器中的占位符样式 */
input:-moz-placeholder {color:#a6aebf;}
/* 设置输入框在Internet Explorer浏览器中的占位符样式 */
input:-ms-input-placeholder {color:#a6aebf;}
/* 取消Chrome记住密码的背景颜色 */
input:-webkit-autofill {-webkit-box-shadow:0 0 0 1000px white inset !important;}
/* 设置html元素的高度为100% */
html {height:100%;}
.login-main .login-bottom .tip {clear:both;height:16px;line-height:16px;width:288px;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;}
.login-main .login-bottom .tip .forget-password {font-stretch:normal;letter-spacing:0;color:#1391ff;text-decoration:none;position:absolute;right:62px;}
.login-main .login-bottom .login-btn {width:288px;height:40px;background-color:#1E9FFF;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 #e6e6e6;}
.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;}
@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="main-body">
<!-- 主内容区域 -->
<div class="login-main">
<!-- 登录界面主体部分 -->
<div class="login-top">
<!-- 顶部标题和装饰背景 -->
<span>高校宿舍管理系统</span>
<!-- 背景装饰1 -->
<span class="bg1"></span>
<!-- 背景装饰2 -->
<span class="bg2"></span>
</div>
<!-- 登录表单 -->
<form class="layui-form login-bottom">
<!-- 居中对齐 -->
<div class="center">
<!-- 用户名输入框 -->
<div class="item">
<!-- 用户名图标 -->
<span class="icon icon-2"></span>
<!-- 用户名输入框验证必填默认值为admin自动完成关闭占位符为请输入登录账号最大长度24 -->
<input type="text" name="userName" lay-verify="required" value="admin" autocomplete="off" placeholder="请输入登录账号" maxlength="24"/>
</div>
<!-- 密码输入框 -->
<div class="item">
<!-- 密码图标 -->
<span class="icon icon-3"></span>
<!-- 密码输入框验证必填默认值为123456自动完成关闭占位符为请输入密码最大长度20 -->
<input type="password" name="password" lay-verify="required" value="123456" autocomplete="off" placeholder="请输入密码" maxlength="20">
<!-- 绑定密码图标 -->
<span class="bind-password icon icon-4"></span>
</div>
<!-- 角色选择下拉框 -->
<div class="item">
<!-- 角色选择图标 -->
<span class="icon icon-2" style="float: left"></span>
<div>
<!-- 角色选择下拉框,验证必填 -->
<select name="type" lay-verify="required">
<!-- 提示选择登陆角色 -->
<option value="">请选择登陆角色</option>
<!-- 管理员选项,默认选中 -->
<option value="0" selected>管理员</option>
<!-- 宿管员选项 -->
<option value="1">宿管员</option>
<!-- 学生选项 -->
<option value="2">学生</option>
</select>
</div>
</div>
</div>
<div class="layui-form-item" style="text-align:center; width:100%;height:100%;margin:0px;">
<button class="login-btn" lay-submit="" lay-filter="login">立即登录</button>
</div>
</form>
</div>
</div>
<div class="footer">
©版权所有 2020 研真教育
</div>
<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../js/lay-config.js" charset="utf-8"></script>
<script>
// 使用layui模块
layui.use(['form','jquery','axios','layer','store'], function () {
var $ = layui.jquery,
form = layui.form,
axios = layui.axios,
layer = layui.layer,
store = layui.store,
layer = layui.layer;
// 如果当前页面不是顶层窗口则将顶层窗口的地址设置为当前页面地址跳出iframe框架
if (top.location != self.location) top.location = self.location;
// 绑定点击事件到密码显示按钮
$('.bind-password').on('click', function () {
// 如果按钮有'icon-5'类,移除该类并设置密码输入框类型为'password'
if ($(this).hasClass('icon-5')) {
$(this).removeClass('icon-5');
$("input[name='password']").attr('type', 'password');
} else {
// 否则添加'icon-5'类并设置密码输入框类型为'text'
$(this).addClass('icon-5');
$("input[name='password']").attr('type', 'text');
}
});
// 进行登录操作
form.on('submit(login)', function (data) {
// 获取表单数据
data = data.field;
axios({
// 设置请求方法为POST
method: 'post',
// 设置请求URL为/login
url: '/login',
// 将表单数据作为请求体发送
data: data
}).then(function(data){
// 如果返回的code为200表示登录成功
if(data.code == 200){
// 存储服务器返回的token
store.setToken(data.data.token)
// 如果返回的用户信息存在,则存储用户信息
if(data.data.user){
store.setLoginInfo(data.data.user,0);
}
// 如果返回的学生信息存在,则存储学生信息
if(data.data.student){
store.setLoginInfo(data.data.student,1);
}
// 跳转到首页
location.href='index.html'
}else{
// 如果登录失败,显示错误信息
layer.msg(data.msg);
}
}).catch(function(error){
// 捕获并处理请求过程中的错误
layer.msg(error);
});
// 阻止表单默认提交行为
return false;
});
</script>
</body>
</html>