<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>账号注册</title>
  <script src="__JS__/jquery-1.11.3.min.js"></script>
  <script type="text/javascript" src="__JS__/getRem.js"></script>
  <link rel="stylesheet" type="text/css" href="__CSS__/reset.css">
  <link rel="stylesheet" type="text/css" href="__CSS__/foot_tabbar.css">
  <link rel="stylesheet" type="text/css" href="__CSS__/step1.css">
  <link href="__CSS__/common-cz.css" rel="stylesheet" >
</head>
<body>
<div class="login">
  <!-- 子页公共头部 -->
  <div class="subpage-heard">账号注册
    <a href="javascript:window.history.go(-1);" class="arrows"></a>
  </div>

    <div class="login-box">
      <div class="login-input">
        <img src="__IMG__/new/people.png" alt="">
        <input type="text" placeholder="请输入账号" name="account" id="account" value="">
      </div>
      <div class="login-input">
        <img src="__IMG__/new/suo.png" alt="">
        <input type="password" placeholder="请输入密码" name="password" id="password" value="">
      </div>
      <!--<div class="login-input">
        <img src="__IMG__/new/nicheng.png" alt="">
        <input type="text" placeholder="请输入昵称" name="nickname" id="nickname" value="">
      </div>-->
      <!-- <div class="login-gender">
        <div class="title">
          <img src="__IMG__/new/xingbie.png" alt="">
          <span>性别</span>
        </div>
        <div class="radio">
          <span>男</span>
          <input id="radio-1" name="sex" type="radio" value="男" checked>
          <label for="radio-1" class="radio-label"></label>
        </div>
        <div class="radio">
          <span>女</span>
          <input id="radio-2" name="sex" type="radio" value="女">
          <label  for="radio-2" class="radio-label"></label>
        </div>
      </div> -->
      <button class="login-btn nextsubmit">注册</button>
      <div class="login-agreement">注册即表示同意<a href="{:U('News/protocol')}">《用户协议》</a></div>
    </div>
</div>
<div class="popmsg pop-dialog" style="font-size: .28rem"></div>

<script src="__JS__/pop.lwx.min.js"></script>
<script src="__JS__/common.js"></script>

<script>
    var pmsg = $('.popmsg').pop();
    $(function() {
        $('input[name=sex]').change(function() {
            var that = $(this);
            $('input[name=sex]').removeClass('on');
            if (that.prop('checked')) {
                that.addClass('on');
            }
        });


        $('.nextsubmit').click(function(event) {
            var account = $.trim($('#account').val());
            var nickname = $.trim($('#nickname').val())
            var password = $.trim($('#password').val());
            // var sex = $.trim($('input[name=sex]:checked').val());
            var promoteId = parseInt("{:I('get.pid')}") ? parseInt("{:I('get.pid')}") : 0;
            var gameId = parseInt("{:I('get.gid')}") ? parseInt("{:I('get.gid')}") : 0;

            if(account.length == 0 ){
                pmsg.msg('账号不能为空');event.preventDefault();
                return false;
            }
            /*if(nickname.length == 0 ){
                pmsg.msg('昵称不能为空');event.preventDefault();
                return false;
            }*/
            if(password.length == 0){
                pmsg.msg('密码不能为空');event.preventDefault();
                return false;
            }
            if(account.length > 15 || account.length < 6){
                pmsg.msg('账号在6-15个字符之间');event.preventDefault();
                return false;
            }
            if(nickname.length > 15 ){
                pmsg.msg('昵称在15个字符以内');event.preventDefault();
                return false;
            }
            if(password.length < 6 || password.length > 15){
                pmsg.msg('密码长度6-15个字符');event.preventDefault();
                return false;
            }
            if (account) {
                if (password) {
                    $.ajax({
                        type:'POST',
                        url:'{:U("User/step1")}',
                        data:{'account':account,'nickname':nickname,'password':password,'promote_id':promoteId,'game_id':gameId},
                        dataType:"Json",
                        success:function(data){
                            pmsg.msg(data.msg);
                            if(parseInt(data.status) == 1){
                                window.location.href = data.url;
                            }
                        },
                        error:function(data){
                            console.log(data);

                        }
                    });
                } else{
                    pmsg.msg('请输入密码');event.preventDefault();
                }
            } else {
                pmsg.msg('请输入账号');event.preventDefault();
            }
        });


    });

</script>
</body>
</html>