<!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={{rootUrl_CSS}}global.css> 
	<script src={{rootUrl_JS}}jquery-1.7.2.min.js></script> 
	<script src={{rootUrl_JS}}global.js></script>
    <script src={{rootUrl_JS}}smartcost.js></script>
    <script src="{{rootUrl_JS}}jquery.validate.min.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#chpasswd").validate({
                rules: {
                    oldpwd: {
                        required: true,
                        minlength: 6,
                        maxlength: 16,
                        remote: {
                            url: '{{rootUrl}}check',
                            type: 'POST',
                            dateType: 'json',
                            data: {
                                password: function () {
                                    return $('#oldpwd').val();
                                }
                            }
                        }
                    },
                    newpwd: {
                        required: true,
                        minlength: 6,
                        maxlength: 16
                    },
                    newpwdrepeat: {
                        required: true,
                        equalTo: "#newpwd",
                        minlength: 6,
                        maxlength: 16
                    },
                    answer: {
//                        required: true
                    }
                },
                messages: {
                    oldpwd: {
                        required:"请输入旧密码",
                        minlength: "密码长度不能小于6",
                        maxlength: "密码长度不能大于16",
                        remote:"请确认旧密码是否正确"
                    },
                    newpwd: {
                        required:"请输入新密码",
                        minlength: "密码长度不能小于6",
                        maxlength: "密码长度不能大于16",
                    },
                    newpwdrepeat: {
                        required:"请重复输入新密码",
                        minlength: "密码长度不能小于6",
                        maxlength: "密码长度不能大于16",
                        equalTo: "请输入相同的新密码"
                    },
                    answer: {
                        required:"请输入您的答案"
                    }
                },
                errorElement: "span",// 错误信息容器标签
                errorClass: "erroT",
                validClass: "inputSus",
                onkeyup: false
            });
        });
    </script>
</head>
<body>
<!-- include '_header' -->
<!-- include '_body_top' -->
<div class="globalContent width950">
	<div class="formItem">
		<h2>修改密码</h2>
		<dl>
			<form method="post" name="chpasswd" id="chpasswd">
				<dt>旧密码</dt>
				<dd><input id="oldpwd" name="oldpwd" type="password" class="inputText {{erroT}}">{{erroTxt}}</dd>
				<dt>新密码</dt>
				<dd><input id="newpwd" name="newpwd" type="password" class="inputText"></dd>
				<dt>确认新密码</dt>
				<dd><input id="newpwdrepeat" name="newpwdrepeat" type="password" class="inputText"></dd>
                <dt><b>选择您的验证方式：</b></dt>
                <div class="trainForm">
                    <div class="trainFormTab trainFormTabs clearfix">
                        <!-- if !{{zh_empty(userquestion)}} --><a class="now">使用密保</a><!-- endif -->
                        <!-- if !{{zh_empty(userquestion)}} && !{{zh_empty(mobile)}} --><a>使用验证码</a><!-- elseif {{zh_empty(userquestion)}} && !{{zh_empty(mobile)}} --><a class="now">使用验证码</a><!-- endif -->
                    </div>
                </div>
                <div class="trainFormItem">
                    <!-- if !{{zh_empty(userquestion)}} -->
                    <div class="formEntry clearfix">
                        <dl class="regForm" style="width:100%;">
                            <dt>密码保护问题：<b>{{defquestion}}</b></dt>
                            <dd><input id="answer" name="answer" class="inputText {{aerroT}}">{{aerroTxt}}</dd>
                        </dl>
                    </div>
                    <!-- endif -->
                    <!-- if !{{zh_empty(userquestion)}} && !{{zh_empty(mobile)}} -->
                    <div class="formEntry reportContent" style="display:none">
                        <div class="formEntry clearfix">
                            <dl class="regForm" style="width:100%;">
                                <dt>短信校验码</dt>
                                <dd><input type="text" class="inputText {{aerroT}}" name="zhsmscode" id="zhsmscode" style="width:177px;"><p class="tips">验证码是6位数字</p><input type="button" class="btnTextOne" id="codebtn" name="codebtn" value="获取验证码" onclick="checkAndSend(this)" >{{aerroTxt}}</dd>
                            </dl>
                        </div>
                    </div>
                    <!-- elseif {{zh_empty(userquestion)}} && !{{zh_empty(mobile)}} -->
                    <div class="formEntry reportContent">
                        <div class="formEntry clearfix">
                            <dl class="regForm" style="width:100%;">
                                <dt>短信校验码</dt>
                                <dd><input type="text" class="inputText {{aerroT}}" name="zhsmscode" id="zhsmscode" style="width:177px;"><p class="tips">验证码是6位数字</p><input type="button" class="btnTextOne" id="codebtn" name="codebtn" value="获取验证码" onclick="checkAndSend(this)" >{{aerroTxt}}</dd>
                            </dl>
                        </div>
                    </div>
                    <!-- endif -->
                </div>
				<dd class="clearfix"><br>
				<input type="submit" name="subchpwd" value="确认修改"  class="button btn-blue " />
				<a class="button btn-dark " href="{{rootUrl}}profile">返回</a>
			</dd>
			</form>
		</dl>
	</div>
</div>
<!-- include '_footer' -->
<script type="text/javascript">
    var clock = '';
    var nums = 60;
    var btn;
    var mobile = '{{mobile}}';
    function checkAndSend(thisbtn){
        $('#zhsmscode').removeClass('erroT');
        if($('#zhsmscode').siblings().hasClass('erroT')){
            $('#zhsmscode').siblings('.erroT').remove();
        }
        var flag = true;
        if(mobile != ''){
            $.ajax({
                url: '{{rootUrl}}chpwdsms',
                type: 'POST',
                dateType: 'json',
                async: false,
                data: {zhmobile:mobile},
                success: function (result) {
                    var data = eval('('+result+')');
                    if(data.code == -1){
                        $('#zhsmscode').addClass('erroT');
                        var span = '<span class="erroT">'+data.msg+'</span>';
                        $('#zhsmscode').parent().append(span);
                        flag = false;
                    }else if(data.code == 1){
                        flag = true;
                    }
                }
            });
            if(!flag){
                return false;
            }
//        $('#zhsmscode').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>