{% extends "base.html" %}
{% block title %}register{% end %}
{% block head %}
<script type="text/javascript" src="{{ static_url('js/jquery-1.12.4.min.js') }}"></script>
<script type="text/javascript">
function getSteamId(){
var c_name = 'steamname';
if(document.cookie.length>0){
c_start = document.cookie.indexOf(c_name + "=")
if(c_start!=-1){
c_start=c_start + c_name.length+1
c_end=document.cookie.indexOf(";",c_start)
if(c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end));
}
}
}
function register() {
var username = document.getElementById("user_name").value;
var password = document.getElementById("pass_word").value;
var c_password = document.getElementById("c_password").value;
var mobile = document.getElementById("mobile").value;
var steam_id = getSteamId()
$.ajax({
type: "POST",
dataType: "json",
url: '/user/register',
contentType: "application/json",
data:JSON.stringify({
"username": username,
"password": password,
"c_password": c_password,
"mobile": mobile,
"steam_id": steam_id,
}),
success: function (result) {
if (result.code == 200) {
window.location.href = "/";
}else {
alert(result.message)
}
}
});
}
</script>
{% end %}
{% block content %}
<h1 style="text-align: center">
{{ data }}
</h1>
<form>
<p>用户名:<input type="text" id="user_name" name="username" placeholder="用户名"></p>
<p>密码(*):<input type="password" id="pass_word" name="password" placeholder="密码"></p>
<p>确认密码(*):<input type="password" id="c_password" name="c_password" placeholder="确认密码"></p>
<p>手机号(*):<input type="text" id="mobile" name="mobile" placeholder="手机号"></p>
<input type="button" value="注 册" onclick="register()">
<a href="/user/login"><input type="button" value="登录"></a>
</form>
{% end %}