login

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>小麦后台管理平台</title>
<link rel="stylesheet" href="js/layui/css/layui.css" />
<link rel="stylesheet" href="css/login.css" />
<link href="img/1-t.png" rel="SHORTCUT ICON" />
</head>
<body class="layui-layout-body" onkeydown="onEnter();">
<div class="layui-fluid" style="padding: 0px;">
<canvas id="particle"></canvas>
<div class="layui-form layui-form-pane layui-admin-login">
<div class="layui-admin-login-header">
<h1>后台登陆</h1>
<p>小麦后台管理平台</p>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
<div class="layui-input-block">
<input name="username" class="layui-input" type="text" placeholder="请输入账号" autocomplete="off" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
<div class="layui-input-block">
<input name="userpassword" class="layui-input" type="password" placeholder="请输入密码" autocomplete="off" />
</div>
</div>
<div class="layui-form-item">
<input type="checkbox" pane name="remember" title="记住密码" lay-skin="primary">
<a href="javascript:;" style="margin-top: 10px;float: right;color: #009688;">忘记密码?</a>
</div>
<div class="layui-form-item">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="login" id="login">
<i class="layui-icon layui-icon-ok-circle"></i>登陆
</button>
</div>
<div class="layui-btn-container">
<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="register">
<i class="layui-icon layui-icon-add-circle"></i>注册
</button>
</div>
</div>
<!--底部-->
<div class="layui-footer">© 2019 小麦管理后台</div>
</div>
</div>
<script src="./js/layui/layui.js"></script>
<script type="text/javascript" src="js/particle.min.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script>
// $("#login").click(function(){
//
// })

layui.use(['layer', 'form'], function() {
var layer = layui.layer,
form = layui.form,
$ = layui.jquery;
//监控表单提交
form.on('submit(login)', function(data) {
var obj = data.field;
$.ajax({
type: "get",
url: "http://localhost:8080/tAdmin/login?addountnumber="+ obj.username +"&password=" + obj.userpassword,
dataType: "json",
success: function(result) {
console.log(result);
if (result.code == 1) {
alert("即将进入超级管理员页面❤");
window.location.href = "./index.html?id="+result.admin.adminId;
} else if(result.code == 2){
alert("即将进入商品管理员页面❤");
window.location.href = "./shopadmin.html?id="+result.admin.adminId;
}else if(result.code == 3){
alert("即将进入客服管理员页面❤");
window.location.href = "./serviceadmin.html?id="+result.admin.adminId;
}else if(result.code == 4){
alert("即将进入信息管理员页面❤");
window.location.href = "./xinxiadmin.html?id="+result.admin.adminId;
}else{
alert("对不起,您没有管理权限");
}
},error: function(res){
console.log(res)
layer.msg(res.responseText, {
icon: 5
});
}
});

});
//监控注册
form.on('submit(register)', function(data) {
layer.open({
title: "用户注册",
type: 2,
content: "./register.html",
area: ['400px', '250px']
});
});
})
//登陆按钮绑定回车
function onEnter() {
if (window.event.keyCode == 13) {
document.getElementsByTagName("button")[0].click();
}
}
var particle = new Particle('#particle', {
effect: 'line'
});
</script>
</body>
</html>

posted @ 2019-01-10 12:12  sjqsjq  阅读(341)  评论(0编辑  收藏  举报