<!--{include file="<!--{$mpath}-->block_header.tpl"}-->
<!--loading页开始-->
<div class="loading">
    <div class="loader">
        <div class="loader-inner pacman">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
</div>
<!--loading页结束-->
<body>
<header class="mui-bar mui-bar-nav report-header box-s" id="header">
    <a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl"></i></a>
    <p>注册</p>
</header>
<div id="main" class="mui-clearfix">
    <div class="sign clearfloat">
        <form id="companyinforeg">
            <input type="hidden" name="parent_id" id="parent_id" value="<!--{$id}-->">
        <div class="list clearfloat">
            <ul>
                <li>
                    <i class="iconfont icon-gerenzhongxin fl"></i>
                    <input type="text" name="username" id="username" value="" class="text fl" placeholder="请输入手机号码" />
                </li>
            <!--    <li>
                    <i class="iconfont icon-yanzhengma fl"></i>
                    <input type="text" name="" id="" value="" class="text yzma fl" placeholder="请输入验证码" />
                    <input type="button" name="" id="" value="获取验证码" class="btn fr" />
                </li>-->
                <li>
                    <i class="iconfont icon-mima fl"></i>
                    <input type="password" name="password" id="password" value="" class="text fl" placeholder="请输入6-16位密码" />
                </li>
                <li>
                    <i class="iconfont icon-mima fl"></i>
                    <input type="password" name="assertpassword" id="assertpassword" value="" class="text fl" placeholder="密码确认" />
                </li>
                <li>
                    <i class="iconfont icon-jian fl"></i>
                    <input type="text" name="email" id="email" value="" class="text fl" placeholder="会员邮箱" />
                </li>

                <li>
                    <i class="iconfont icon-yanzhengma fl"></i>
                    <input type="text" size="8"  class="form-control text fl" name="checkcode" id="checkcode" autocomplete="off" required  style="width:100px;" placeholder="验证码" />
                    <div style="float:right;margin-top:10px">
                        <img alt="图片验证码" title="看不清换一张" class="chkcode_img" src="<!--{$urlpath}-->source/include/imagecode.php?act=verifycode" style="height: 30px;" />
                    </div>
                </li>


            </ul>
            <a href="javascript:void(0);" class="tui-btn" id="submit">
                注册
            </a>
        </div>
        </form>
    </div>
</div>
</body>
<script type="text/javascript" src="<!--{$mpath}-->js/jquery-1.8.3.min.js" ></script>
<script src="<!--{$mpath}-->layer_mobile/layer.js"></script>
<script src="<!--{$mpath}-->js/fastclick.js"></script>
<script src="<!--{$mpath}-->js/mui.min.js"></script>
<script type="text/javascript" src="<!--{$mpath}-->js/hmt.js" ></script>
</html>

<script>

	$("#submit").click(function() {
	var username=document.getElementById("username").value;//获取form中的用户名
	var password=document.getElementById("password").value;
	var assertpassword=document.getElementById("assertpassword").value;
	var email=document.getElementById("email").value;
	var checkcode=document.getElementById("checkcode").value;
	var regex=/^[/s]+$/;//声明一个判断用户名前后是否有空格的正则表达式
	if(regex.test(username)||username.length==0)//判定用户名的是否前后有空格或者用户名是否为空
	{
        layer.open({
            content: '手机格式不对'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });
		return false;
	}
	if(regex.test(password)||password.length==0)//同上述内容
	{
        layer.open({
            content: '密码格式不对'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });
		return false;
	}
	if(regex.test(assertpassword)||assertpassword.length==0)//同上述内容
	{
        layer.open({
            content: '密码确认格式不对'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });

		return false;
	}

	if(regex.test(password)!=regex.test(assertpassword)){
        layer.open({
            content: '密码不一致'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });

    }
	if(regex.test(email)||email.length==0)//同上述内容
	{
        layer.open({
            content: '邮箱格式不对'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });
		return false;
	}
	if(regex.test(checkcode)||checkcode.length==0)//同上述内容
	{
        layer.open({
            content: '验证码不能为空'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });
		return false;
	}

	event.preventDefault();
        var form = new FormData(document.getElementById("companyinforeg"));
        $.ajax({
                url: "index.php?c=user&a=ajaxreg",
                type: "post",
                data: form,
                dataType: "json",
                processData: false,
                contentType: false,
                success: function(data) {
                        var json = eval(data);
                        var response = json.response;
                        var result = json.result;

                        if(response == "1") {
                            layer.open({
                                content: result
                                ,skin: 'msg'
                                ,time: 2 //2秒后自动关闭
                            });
                            setTimeout( function(){
                                window.location.href = '/index.php?c=user&a=login&res=1';
                            }, 2 * 1000 );//延迟5000毫米
                        } else {
                            layer.open({
                                content: result
                                ,skin: 'msg'
                                ,time: 2 //2秒后自动关闭
                            });
                        }
                },
                error: function(e) {
                        alert("错误！！");

                }
        });                        
	});
</script>