<!DOCTYPE html>
<html lang=zh-cn>
<head>
    <meta charset=utf-8>
    <title>注册纵横通行帐号</title>
    <meta name=description content=一个帐号通用纵横旗下所有网络产品。>
    <meta name=copyright content=smartcost.com.cn>
    <link rel=stylesheet href=<?php echo $data['rootUrl_CSS']; ?>global.css>
    <script src=<?php echo $data['rootUrl_JS']; ?>jquery-1.7.1.min.js></script>
    <script src=<?php echo $data['rootUrl_JS']; ?>global.js></script>
    <script src="<?php echo $data['rootUrl_JS']; ?>jquery.validate.min.js"></script>
    <script type="text/javascript">
        $(function(){
            jQuery.validator.addMethod("isMobile", function(value, element) {
                var length = value.length;
                var mobile = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1})|(14[0-9]{1}))+\d{8})$/;
                return this.optional(element) || (length == 11 && mobile.test(value));
            }, "请正确填写您的手机号码");
            jQuery.validator.addMethod("isCode", function(value, element) {
                var length = value.length;
                var mobile = /^(\d{6})$/;
                return this.optional(element) || (length == 6 && mobile.test(value));
            }, "请正确填写验证码");
            $("#mobileform").validate({
                rules: {
                    zhmobile:{
                        required: true,
                        isMobile: true,
                        remote: {
                            url: '<?php echo $data['rootUrl']; ?>check',
                            type: 'POST',
                            dateType: 'json',
                            data: {
                                zhmobile: function () {
                                    return $('#zhmobile').val();
                                }
                            }
                        }
                    },
                    zhsmscode: {
                        required: true,
                        isCode: true,
                        remote: {
                            url: '<?php echo $data['rootUrl']; ?>check',
                            type: 'POST',
                            dateType: 'json',
                            data: {
                                zhsmscode: function () {
                                    return $('#zhsmscode').val();
                                },
                                zhmobile: function () {
                                    return $('#zhmobile').val();
                                }
                            }
                        }
                    },
                    password: {
                        required: true,
                        minlength: 6,
                        maxlength: 16,
                        remote: {
                            url: '<?php echo $data['rootUrl']; ?>check',
                            type: 'POST',
                            dateType: 'json',
                            data: {
                                password: function () {
                                    return $('#password').val();
                                }
                            }
                        }
                    }
                },
                messages: {
                    zhmobile:{
                        required: "请输入手机号",
                        remote: "该手机号码已被注册！"
                    },
                    zhsmscode: {
                        required: "请输入验证码",
                        remote: "验证码过期或不一致，请重新获取"
                    },
                    password: {
                        required:"请输入密码",
                        minlength: "密码长度不能小于6",
                        maxlength: "密码长度不能大于16",
                        remote:"请确认密码是否正确"
                    }
                },
                errorElement: "span",// 错误信息容器标签
                errorClass: "erroT",
                validClass: "inputSus",
                onkeyup: false
            });
        });
    </script>
</head>
<body>
<?php include Doo::conf()->SITE_PATH .  Doo::conf()->PROTECTED_FOLDER . "viewc/v2/_header.php"; ?>
<?php include Doo::conf()->SITE_PATH .  Doo::conf()->PROTECTED_FOLDER . "viewc/v2/_body_top.php"; ?>
<div class="globalContent width950">
    <div class="formItem">

        <h2>修改手机号</h2>
        <div class="regInfo fR">
            <div class="regTips">
                为了确保您能正常收取验证信息，请：<br><br>
                1.确保您填写的手机号是规范的，可正常使用的手机号；<br><br>
                <!-- 2.把域名“smartcost.com.cn”添加至您的邮箱白名单中；<br><br>
                3.查看“垃圾箱”，看是否有我们发送给您的激活邮件；<br><br>
                查看帮助中心-《<a href="http://help.zhzdwd.com/index_article/6/74" target="_blank">收不到邮件怎么办？</a>》 -->
            </div>
        </div>
        <form method="post" name="mobileform" id="mobileform">
            <dl>
                <dt>当前手机号</dt>
                <dd><b><?php echo $data['mobile']; ?></b></dd>
                <dt>新手机号</dt>
                <dd><input type="text" name="zhmobile" id="zhmobile" class="inputText"></dd>
                <dt>验证码</dt>
                <dd><input type="text" class="inputText" name="zhsmscode" id="zhsmscode" style="width:177px;"><input type="button" class="btnTextOne" id="codebtn" name="codebtn" value="获取验证码" onclick="checkAndSend(this)" ></dd>
                <dt>输入密码确认</dt>
                <dd><input type="password" name="password" id="password" class="inputText"></dd>
                <dd class="clearfix"><br><br>
                    <input type="submit" name="mobilesubmit" id="timer" class="button btn-blue " value="确认修改">
                    <p class="submitSus"><?php echo $data['message']; ?></p></dd>

            </dl>
        </form>
    </div>
</div>
<?php include Doo::conf()->SITE_PATH .  Doo::conf()->PROTECTED_FOLDER . "viewc/v2/_footer.php"; ?>
<script type="text/javascript">
    var clock = '';
    var nums = 60;
    var btn;
    function checkAndSend(thisbtn){
        $('#zhmobile').removeClass('erroT');
        if($('#zhmobile').siblings().hasClass('erroT')){
            $('#zhmobile').siblings('.erroT').remove();
        }
        var mobile = $('#zhmobile').val();
        if(mobile == ''){
            $('#zhmobile').addClass('erroT');
            var span = '<span class="erroT">请输入手机号</span>';
            $('#zhmobile').parent().append(span);
            return false;
        }else if(!mobile.match(/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1})|(14[0-9]{1}))+\d{8})$/)){
            $('#zhmobile').addClass('erroT');
            var span = '<span class="erroT">请正确填写您的手机号码</span>';
            $('#zhmobile').parent().append(span);
            return false;
        }
        var flag = true;
        $.ajax({
            url: '<?php echo $data['rootUrl']; ?>checksms',
            type: 'POST',
            dateType: 'json',
            async: false,
            data: {zhmobile:mobile},
            success: function (result) {
                var data = eval('('+result+')');
                if(data.code == -1){
                    $('#zhmobile').addClass('erroT');
                    var span = '<span class="erroT">'+data.msg+'</span>';
                    $('#zhmobile').parent().append(span);
                    flag = false;
                }else if(data.code == 1){
                    flag = true;
                }
            }
        });
        if(!flag){
            return false;
        }
        $('#zhmobile').addClass('inputSus');
        sendCode(thisbtn);
    }

    function sendCode(thisBtn)
    {
        btn = thisBtn;
        btn.disabled = true; //将按钮置为不可点击
        btn.value = nums+'秒后可重新获取';
        $('#codebtn').removeClass('btnTextOne').addClass('btnText');
        btn.style.cursor = 'no-drop';
        clock = setInterval(doLoop, 1000); //一秒执行一次
    }
    function doLoop()
    {
        nums--;
        if(nums > 0){
            btn.value = nums+'秒后可重新获取';
        }else{
            clearInterval(clock); //清除js定时器
            btn.disabled = false;
            btn.value = '点击发送验证码';
            $('#codebtn').removeClass('btnText').addClass('btnTextOne');
            btn.style.cursor = 'pointer';
            nums = 60; //重置时间
        }
    }
</script>
</body>
</html>