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.
120 lines
4.1 KiB
120 lines
4.1 KiB
8 years ago
|
<% this.title = 'Sign up' %>
|
||
|
<% include header %>
|
||
|
<div class="am-container am-g">
|
||
|
<div class="am-u-sm-8 am-u-sm-centered">
|
||
|
<h1>注册</h1>
|
||
|
|
||
|
<div class="am-alert am-alert-danger am-u-sm-12 center" id="error" data-am-alert hidden>
|
||
|
<p id="error_info">没什么可给你,但求凭这阙歌。谢谢你风雨里,都不退愿陪着我。</p>
|
||
|
</div>
|
||
|
<div class="am-u-sm-12">
|
||
|
<form class="am-form am-form-horizontal">
|
||
|
<div class="am-form-group">
|
||
|
<label class="am-u-sm-2 am-form-label">用户名</label>
|
||
|
|
||
|
<div class="am-u-sm-10">
|
||
|
<input type="text" placeholder="用户名将用于登陆" id="username" onkeydown="key_login()">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="am-form-group">
|
||
|
<label class="am-u-sm-2 am-form-label">邮箱</label>
|
||
|
|
||
|
<div class="am-u-sm-10">
|
||
|
<input type="email" placeholder="电子邮箱" id="email" onkeydown="key_login()">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="am-form-group">
|
||
|
<label class="am-u-sm-2 am-form-label">密码</label>
|
||
|
|
||
|
<div class="am-u-sm-10">
|
||
|
<fieldset class="am-form-set">
|
||
|
<input type="password" placeholder="设置一个密码吧" id="password1" onkeydown="key_login()">
|
||
|
<input type="password" placeholder="再输入一遍" id="password2" onkeydown="key_login()">
|
||
|
</fieldset>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="am-form-group">
|
||
|
<div class="am-u-sm-10 am-u-sm-offset-2">
|
||
|
<p id="sign_up" class="am-btn am-btn-default">注册</p>
|
||
|
</div>
|
||
|
</div>
|
||
|
</form>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<script type="text/javascript">
|
||
|
function key_login() {
|
||
|
if (event.keyCode == 13) {
|
||
|
submit();
|
||
|
}
|
||
|
}
|
||
|
function show_error(error){
|
||
|
$("#error_info").text(error);
|
||
|
$("#error").show();
|
||
|
}
|
||
|
function success(){
|
||
|
alert("注册成功了!\n没什么可给你,但求凭这阙歌。谢谢你风雨里,都不退愿陪着我。");
|
||
|
window.location.href="/";
|
||
|
}
|
||
|
function submit(){
|
||
|
if($("#password1").val()!=$("#password2").val()){
|
||
|
show_error("两次密码不同");
|
||
|
return;
|
||
|
}
|
||
|
password=$.md5($("#password1").val()+"syzoj2_xxx")
|
||
|
$("#sign_up").text("请稍等 ......");
|
||
|
$.ajax({
|
||
|
url : '/api/sign_up',
|
||
|
type : 'POST',
|
||
|
data: {
|
||
|
username: $("#username").val(),
|
||
|
password: password,
|
||
|
email: $("#email").val()
|
||
|
},
|
||
|
success : function(data) {
|
||
|
error_code=data.error_code;
|
||
|
switch(error_code){
|
||
|
case 2001:
|
||
|
show_error("服务器未收到数据");
|
||
|
break;
|
||
|
case 2005:
|
||
|
case 2002:
|
||
|
show_error("用户名需要大于 3 个字符小于 16 个字符,仅允许字母数字和下划线");
|
||
|
break;
|
||
|
case 2007:
|
||
|
case 2003:
|
||
|
show_error("密码不得为空");
|
||
|
break;
|
||
|
case 2004:
|
||
|
case 2006:
|
||
|
show_error("请输入正确的邮箱");
|
||
|
break;
|
||
|
case 2008:
|
||
|
show_error("已经有人用过这个用户名了");
|
||
|
break;
|
||
|
case 1:
|
||
|
success();
|
||
|
break;
|
||
|
default:
|
||
|
show_error("未知错误");
|
||
|
break;
|
||
|
}
|
||
|
$("#sign_up").text("注册");
|
||
|
},
|
||
|
error : function(XMLHttpRequest, textStatus, errorThrown) {
|
||
|
alert(XMLHttpRequest.responseText);
|
||
|
show_error("未知错误");
|
||
|
$("#sign_up").text("注册");
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
$(document).ready(function(){
|
||
|
$("#sign_up").click(function(){
|
||
|
submit();
|
||
|
});
|
||
|
});
|
||
|
</script>
|
||
|
|
||
|
<% include footer %>
|