<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../static/css/home.css">
    <title>注册</title>
    <script src="../static/js/jquery-3.5.1.min.js"></script>
    <script src="http://api.html5media.info/1.1.8/html5media.min.js"></script>
    <script src="../static/js/ip.js"></script>
</head>
<body>
    <div class="background">
        <video autoplay loop muted>
            <source src="../static/video/video.mp4" type="video/mp4"  />
            Your Browser is no longer supported.
        </video>
    </div>

    <div class="login">
        <div class="logo_1"></div>
        <div class="form-item">
            <p style="padding-bottom:15px"><input id="phonenum" oninput="value=value.replace(/[^\d]/g,'')" autocomplete="off" placeholder="电话号码" name="phonenum"></p>
            <p style="padding-bottom:15px"><input id="username" type="text" autocomplete="off" placeholder="用户名" name="username"></p>
            <p style="padding-bottom:15px"><input id="password" type="password" autocomplete="off" placeholder="登录密码" name="password"></p>
            <p style="padding-bottom:15px"><input id="password1" type="password" autocomplete="off" placeholder="确认登录密码" name="password1"></p>
            <p><input type="submit" id="register" value="注册" onclick="register(this)" style="padding-left:0;margin-left:0;width:350px;background-color:white;color:#1f6f4a;cursor:pointer"></p>
        </div>
    </div>
    <script type="text/javascript">
        function register(obj){
            var phonenum = $(obj).parent().prev().prev().prev().prev().children("#phonenum").val();
            var username = $(obj).parent().prev().prev().prev().children("#username").val();
            var password = $(obj).parent().prev().prev().children("#password").val();
            var password1 = $(obj).parent().prev().children("#password1").val();
            var suf_url = ":5000/bp_auth/register";
            var pre_url = "http://";
	    //alert(pre_url+url+suf_url);
            $.ajax({
                type: "POST",
                url: pre_url+url+suf_url,
                data: {
                    phonenum: phonenum,
                    username: username,
                    password: password,
                    password1: password1
                },
                success: function(data){
                    
                    if(data.code == 1){
                        window.location = "/login";
                    }
                    else{
                        window.location = "/register";
                    }
    
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    
                    alert(textStatus);
                    window.location = "/register";
                }
            });
        }    
        </script>

</body>
</html>
