95 lines
3.6 KiB
Plaintext
95 lines
3.6 KiB
Plaintext
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||
|
pageEncoding="UTF-8"%>
|
||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||
|
<title>首页</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="layui-anim layui-anim-scaleSpring">
|
||
|
<div class="layui-container">
|
||
|
<div class="layui-row" style="margin-top: 255px;">
|
||
|
<div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
|
||
|
<form class="layui-form layui-form-pane">
|
||
|
<label class="layui-form-label">账号</label>
|
||
|
<div class="layui-input-block">
|
||
|
<input type="text" id="uname" required lay-verify="required"
|
||
|
placeholder="请输入账号" autocomplete="off" class="layui-input">
|
||
|
</div>
|
||
|
<label class="layui-form-label" style="margin-top: 10px">密码</label>
|
||
|
<div class="layui-input-block" style="margin-top: 10px">
|
||
|
<input type="password" id="pass" required lay-verify="required"
|
||
|
placeholder="请输入密码" autocomplete="off" class="layui-input">
|
||
|
</div>
|
||
|
<div class="layui-form-item" style="margin-top: 10px">
|
||
|
<div class="layui-input-block">
|
||
|
<input type="button" class="layui-btn" lay-submit lay-filter="formDemo" onclick="login()" value="登录"/>
|
||
|
<input type="button" class="layui-btn layui-btn-primary" onclick="reg()" value="注册"/>
|
||
|
</div>
|
||
|
</div>
|
||
|
</form>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
<link rel="stylesheet" href="../layui/css/layui.css">
|
||
|
<script type="text/javascript" src="../layui/layui.all.js"></script>
|
||
|
<script type="text/javascript" src="../js/jquery-3.2.1.js"></script>
|
||
|
<script type="text/javascript">
|
||
|
var layer = layui.layer;
|
||
|
function reg() {
|
||
|
layui.use('layer', function(){
|
||
|
layer.open({
|
||
|
title: '用户注册'
|
||
|
,content: '<input type="text" id="regUname" required lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">'
|
||
|
+'<input type="text" id="uuname" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input" style="margin-top: 10px">'
|
||
|
+'<input type="password" id="regPass" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input" style="margin-top: 10px">'
|
||
|
+'<input type="password" id="repass" required lay-verify="required" placeholder="请再输入一次密码" autocomplete="off" class="layui-input" style="margin-top: 10px">'
|
||
|
+'<a href="#" style="color: #0000FF">阅读用户协议</a>'
|
||
|
,btn: ['提交','取消']
|
||
|
,btn1:function(index,layero){
|
||
|
var uname=$('#regUname').val();
|
||
|
var pass=$('#regPass').val();
|
||
|
var repass=$('#repass').val();
|
||
|
var uuname=$('#uuname').val();
|
||
|
if(pass!=repass){
|
||
|
alert('两次密码不一致');
|
||
|
return;
|
||
|
}
|
||
|
$.post('/user/reg.do', {uname:uname,pass:pass,name:uuname}, function(data) {
|
||
|
alert(data);
|
||
|
});
|
||
|
}
|
||
|
,btn2:function(index){
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
function login() {
|
||
|
var name=$('#uname').val();
|
||
|
var pass=$('#pass').val();
|
||
|
console.log("name:"+name+" pass:"+pass);
|
||
|
$.post('/user/login.do',{uname:name,pass:pass},function(data){
|
||
|
console.log(data);
|
||
|
var json=JSON.parse(data);
|
||
|
if(json.code==102){
|
||
|
layer.open({
|
||
|
title: '还没注册?',
|
||
|
content:'似乎你还没注册呢,先注册吧',
|
||
|
btn:['现在注册','下次吧'],
|
||
|
btn1:function(index){
|
||
|
reg();
|
||
|
},
|
||
|
btn2: function(index){
|
||
|
|
||
|
}
|
||
|
})
|
||
|
}else if(json.code==100){
|
||
|
window.location.replace('home.jsp');
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
</script>
|
||
|
</html>
|