<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<title>SURVVPOS</title>
<script src="<?= base_url() ?>assets/front/js/jquery-1.8.3.min.js"></script>  
<link href="<?= base_url() ?>assets/front/css/style.css" rel="stylesheet" type="text/css" /> 
<script src="<?= base_url() ?>assets/front/js/common.js"></script>
<script src="<?= base_url() ?>assets/layer/layer.js"></script>
</head>

<body> 
<!---->
<div class="container"> 
   <div class="login register">
    	<form>
        	<dl class="login_list ">
            	<dt><img src="<?= base_url() ?>assets/front/images/logo.png" /></dt>
                <input type="hidden" id="hassendcode" value="0">
				<input type="hidden" id="access_token" value="<?= $access_token ?>">
				<input type="hidden" id="card_no" value="<?= $openid ?>">
            	<dd class="icon tel"><input type="text" id="phone" value=""  class="text" placeholder="请输入手机号码" /></dd>
            	<dd class="icon verify" style="position: relative;"><input type="text" id="code" value=""  class="text" placeholder="请输入验证码" />
                    <a id="send_bt1" href="javascript:sendCode('reg');" class="gain"  style="top: 0">获取验证码</a>
                    <a id="send_bt" href="javascript:;" class="gain" style="display: none;top: 0" >获取验证码</a>
                </dd>
            	<dd class="login_btn"><input type="button" value="注册登陆" class="btn_login"  onclick="checkfm()" /></dd> 
               <!-- <dd class="deal"><input type="checkbox" value="" />阅读并同意<a href="#">《用户协议》</a></dd>-->
            </dl>
        </form> 
    </div>
</div>
<!----> 
 
</body>
</html>
<script>
    var i = 59;
    var intervalid;
    function fun() {
        $("#send_bt1").hide();
        $("#send_bt").show();
        var Aid = document.getElementById("send_bt")
        Aid.innerHTML = i +'秒后重新获取';
        if (i <= 0) {
            $("#send_bt1").html('重新获取')
            $("#send_bt1").show();
            $("#send_bt").hide();
            clearInterval(intervalid);
            i = 59
            Aid.innerHTML = '59秒后重新'
        }
        i--;
    }

    function checkfm() {
        if ($("#hassendcode").val() == 0) {
			layer.msg("请先发送手机验证码短信!", {icon:2, anim:6});
            $("#code").focus();
            return false;
        }
        var data = {phone:$("#phone").val(),code:$("#code").val(),access_token:$("#access_token").val(),card_no:$("#card_no").val(),stamp:Date.parse(new Date())};
        $.post("<?= site_url('index.php/site/login') ?>",data, function (result) {
            if(result.code == 200)
            {
                window.location.href="<?= site_url('index.php/member') ?>";
            }
            else
            {
				layer.msg(result.msg, {icon:2, anim:6});
            }
        },"json");
    }


    function sendCode(obj) {
		// alert(123);
        if ($("#phone").val() != '' && (/^1[3|4|5|8|7][0-9]\d{8}$/.test($("#phone").val()))) {
			var data = { phone:$("#phone").val(),code_type:obj};
			// alert($("#phone").val());
			// alert(obj);
			$.post("<?= site_url('index.php/site/send_code') ?>",data, function (result) {
				// alert(data);
                layer.msg(result.msg);

                if (result.code == 200) {
                    $("#hassendcode").val(1);
                    $("#code").val(result.data);
                    intervalid = setInterval("fun()", 1000);
                }
            },"json");
        } else {
            layer.msg("手机号码格式不正确!", {icon:2, anim:6});
        }
    }
</script>