2022-01-26 21:10:09 +08:00
|
|
|
|
{% block body %}
|
|
|
|
|
{% if session['logged_in'] %}
|
2024-07-04 11:04:38 +08:00
|
|
|
|
You're logged in already! <a href="/logout">Logout</a>.
|
2022-01-26 21:10:09 +08:00
|
|
|
|
{% else %}
|
2024-07-04 11:04:38 +08:00
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes" />
|
|
|
|
|
<link rel="stylesheet" href="static/css/login_service.css">
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE-edge,chrome=1">
|
|
|
|
|
<link href="static/css/slide-unlock.css" rel="stylesheet">
|
2024-09-06 08:54:11 +08:00
|
|
|
|
<script src="static/js/password.js"></script>
|
2024-07-04 11:04:38 +08:00
|
|
|
|
<script src="static/js/jquery.js"></script>
|
|
|
|
|
<script src="static/js/jquery.slideunlock.js"></script>
|
2023-03-08 16:33:13 +08:00
|
|
|
|
<script>
|
2024-07-04 11:04:38 +08:00
|
|
|
|
var slider
|
|
|
|
|
let username,password,password2
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
slider = new SliderUnlock("#slider", {
|
|
|
|
|
successLabelTip: "验证成功"
|
|
|
|
|
}, function() {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
slider.init(); // 初始化滑块解锁功能
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function signup(){
|
|
|
|
|
// 发起 AJAX 请求来处理注册
|
|
|
|
|
username = $("#username").val().trim();
|
|
|
|
|
password = $("#password").val().trim();
|
|
|
|
|
password2 = $("#password2").val().trim();
|
|
|
|
|
|
|
|
|
|
// 基本表单验证
|
|
|
|
|
if (username === "" || password === "" || password2 === "") {
|
|
|
|
|
alert('输入不能为空!');
|
2023-03-08 16:33:13 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-07-04 11:04:38 +08:00
|
|
|
|
if (password.includes(' ') || password2.includes(' ')) {
|
|
|
|
|
alert('输入不能包含空格!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (password !== password2) {
|
|
|
|
|
alert('确认密码与输入密码不一致!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (password.length < 4) {
|
|
|
|
|
alert('密码过于简单。(密码长度至少4位)');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-09-05 10:11:20 +08:00
|
|
|
|
if (!containsDigitsLettersSpecialCharacters(password)) {
|
|
|
|
|
alert('密码过于简单。(密码要包括数字,字母,特殊符号)');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-07-04 11:04:38 +08:00
|
|
|
|
is_ok = slider.getIsOk();
|
|
|
|
|
if(!is_ok){
|
|
|
|
|
alert('没有滑动验证');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$.post("/signup", {
|
|
|
|
|
'username': username,
|
|
|
|
|
'password': password
|
|
|
|
|
}, function(response) {
|
|
|
|
|
if (response.status === '0') {
|
|
|
|
|
alert('用户名' + username + '已经被注册。');
|
|
|
|
|
window.location.href = "/signup";
|
|
|
|
|
} else if (response.status === '1') {
|
|
|
|
|
alert('用户名密码验证失败。');
|
|
|
|
|
window.location.href = "/signup";
|
|
|
|
|
} else if (response.status === '2') {
|
|
|
|
|
var f = confirm("恭喜,你已成功注册,你的用户名是" + username + '.\n点击“确认”开始使用,或点击“取消”返回首页');
|
|
|
|
|
if (f) {
|
|
|
|
|
window.location.href = '/' + username + '/userpage';
|
|
|
|
|
} else {
|
|
|
|
|
window.location.href = '/';
|
|
|
|
|
}
|
|
|
|
|
} else if (response.status === '3') {
|
|
|
|
|
alert(response.warn);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<p>{{ get_flashed_messages()[0] | safe }}</p>
|
|
|
|
|
|
|
|
|
|
<div class="container">
|
|
|
|
|
<section class="signin-heading">
|
|
|
|
|
<h1>Sign up</h1>
|
|
|
|
|
</section>
|
2022-01-26 21:10:09 +08:00
|
|
|
|
|
2024-07-04 11:04:38 +08:00
|
|
|
|
<form>
|
|
|
|
|
<p><input type="text" id="username" placeholder="输入用户名" class="username"></p>
|
|
|
|
|
<p><input type="password" id="password" placeholder="输入密码" class="password"></p>
|
|
|
|
|
<p><input type="password" id="password2" placeholder="确认密码" class="password"></p>
|
2022-06-14 12:37:28 +08:00
|
|
|
|
|
2024-07-04 11:04:38 +08:00
|
|
|
|
<div id="slider">
|
|
|
|
|
<div id="slider_bg"></div>
|
|
|
|
|
<span id="label">>></span> <span id="labelTip">-----滑动验证你是不是人类</span>
|
|
|
|
|
</div>
|
2022-07-20 17:10:03 +08:00
|
|
|
|
|
2024-07-04 11:04:38 +08:00
|
|
|
|
<button type="button" class="btn" onclick="signup()">注册</button>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
2022-01-26 21:10:09 +08:00
|
|
|
|
|
2024-07-04 11:04:38 +08:00
|
|
|
|
<script>
|
|
|
|
|
// Bind click event to the signup button
|
|
|
|
|
$(".btn").click(function() {
|
|
|
|
|
// Trigger slider unlock
|
|
|
|
|
var slider = new SliderUnlock("#slider");
|
|
|
|
|
slider.isOk();
|
|
|
|
|
});
|
|
|
|
|
</script>
|
2022-06-14 12:37:28 +08:00
|
|
|
|
|
2022-01-26 21:10:09 +08:00
|
|
|
|
{% endif %}
|
|
|
|
|
{% endblock %}
|