注册功能完成

This commit is contained in:
Yang Zhao 2016-12-28 15:21:43 +00:00
parent 694e9f2c97
commit 4fbac0332c
3 changed files with 119 additions and 30 deletions

View File

@ -57,7 +57,7 @@
<nav class="navbar navbar-static-top">
<div class="container">
<div class="navbar-header">
<a href="../../index2.html" class="navbar-brand"><b>Ambition</a>
<a href="index.html" class="navbar-brand"><b>Ambition</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
<i class="fa fa-bars"></i>
</button>

View File

@ -43,42 +43,15 @@
</div>
<div class="row">
<!-- /.col -->
<div class="col-md-2 col-md-offset-9">
<div class="col-md-3 col-md-offset-9">
<button id="login" class="btn btn-success">登录</button>
</div>
<!-- /.col -->
</div>
<!--</form>-->
<!-- 忘记密码 -->
<a href="#" data-toggle="modal" data-target="#myModal">忘记密码</a>
<a href="register.html">注册</a>
<br/>
<!-- 模态框Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
&times;
</button>
<h4 class="modal-title" id="myModalLabel">
忘记密码
</h4>
</div>
<div class="modal-body">
Please send a mail to lucio.yang@qq.com
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" data-dismiss="modal">
关闭
</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<!-- /.modal fade -->
</div>
<!-- /.login-box-body -->

116
public/pages/register.html Normal file
View File

@ -0,0 +1,116 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Ambition-敏捷开发项目管理工具</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="../dist/css/AdminLTE.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body class="hold-transition login-page">
<div class="login-box">
<div class="row"> </div>
<div class="login-logo">
<span class="logo-lg"><b>Ambition</b></span>
</div>
<!-- /.logo -->
<div class="register-box-body">
<p class="login-box-msg">请注册</p>
<!--<form action="../../index.html" method="post">-->
<div class="form-group has-feedback">
<input id="name" type="text" class="form-control" placeholder="昵称">
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input id="email" type="email" class="form-control" placeholder="邮箱">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input id="phone" type="phone" class="form-control" placeholder="手机">
<span class="glyphicon glyphicon glyphicon-phone form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input id="pwd1" type="password" class="form-control" placeholder="密码">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input id="pwd2" type="password" class="form-control" placeholder="重复密码">
<span class="glyphicon glyphicon-log-in form-control-feedback"></span>
</div>
<div class="row">
<div class="col-md-3 col-md-offset-9">
<button id="register" class="btn btn-info">注册</button>
</div>
</div>
<!--</form>-->
</div><!-- /.form-box -->
</div><!-- /.register-box -->
</div>
<!-- /.register-box -->
<!-- jQuery 2.1.4 -->
<script src="../plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="../bootstrap/js/bootstrap.min.js"></script>
<script>
$(document).ready(function(){
$("#register").click(function(){
var name=$("#name").val();
var email=$("#email").val();
var phone=$("#phone").val();
var pwd1=$("#pwd1").val();
var pwd2=$("#pwd2").val();
if( name.length>0 && email.length>0 && phone.length>0 && pwd1.length>0 && pwd2.length>0 ){
if( pwd1!=pwd2 ){
alert("两次密码输入不相同!");
}else{
$.ajax({
type: "post",
dataType: "json",
url:"/users.json",
data: {
"user[name]":name,
"user[email]":email,
"user[phone]":phone,
"user[password]":pwd1
},
statusCode: {
201: function() {// 请求成功
alert("注册成功!");
window.location.href="login.html";
},
422:function(){
alert("输入不符合要求,请重新输入!");
},
401:function(){// 未授权
alert("用户名或密码错误!");
}
}
});
}
}
else{
alert("请输入完整!");
}
});
});
</script>
</body>
</html>