<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link rel="stylesheet" href="/static/weChat/css/public.css">
    <link rel="stylesheet" href="/static/weChat/css/bai_basic.css">
    <script src="/static/weChat/js/flexible.js"></script>
    <title>找回密码</title>
</head>
<body>
<%--过度动画--%>
<div id="mask">
    <div class="main">
        <div class="loading">
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
        </div>
    </div>
    <div class="black-mask-my"></div>
</div>
<div class="ert-head">
    <div class="ert-left">
        <a href="/weixin/login/resetOne">
            <img src="/static/weChat/images/head-left.png" />
        </a>
    </div>
    <p>找回密码</p>
</div>
<div class="search-pwd search-asd">
    <p><i>${email}</i></p>
    <input  type="hidden" value="${email}" id="a1">
    <input type="text" placeholder="请输入验证码" id="code">
    <p class="tyu"></p>
    <a href="javascript:;" id="next-step">下一步</a>
    <%--<div class="error"></div>--%>
    <span class="code-text" id="code-text">获取验证码</span>
</div>

</body>
<script src="/static/weChat/js/jquery-1.8.3.min.js"></script>

<script src="/static/weChat/js/basic.js"></script>
<script src="/static/weChat/common/layer_mobile/layer.js"></script>
<link rel="stylesheet" href="/static/weChat/common/layer_mobile/need/right.css">
<script>
    // 验证码倒计时
    var count=60;
    var e_tit = true;

    // 找回密码
    $('#code-text').click(function () {
        if(e_tit){
            sendTrueCode();
            sendphone(this);
        }
    });

    function sendphone(obj) {
        if (count == 0) {
            $(obj).text("获取验证码").css({"color":"#ff6600","pointer-events":"auto"});
            count = 60;
            e_tit = true;
            return;
        } else {
            $(obj).text("再次发送(" + count + ")").css({"color":"#c7c7c7","pointer-events":"none"});
            count--;
            e_tit = false;
        }
        setTimeout(function() { sendphone(obj)   } ,1000)
    };

    function sendTrueCode(){
        var email =$("#a1").val();
        console.log('email:'+email);
        $("#mask").show();
        $.ajax({
            type : 'POST',
            url : "/weixin/login/sendCode",
            async: true,
            data : { eOrT : email },
            dataType : "json",
            cache : false,
            success : function(json) {
//                alert(json);
                if (json.status == '200') {
                    layer.open({  content: '发送验证码成功' ,btn: '我知道了'   });
                }else{
                    layer.open({  content: '发送验证码错误' ,btn: '我知道了'   });
                }
                $("#mask").hide();
            },
        });
    }

    function checkPwed() {
        var  pwed_ok=false;
        if($('#code').val() == ''){
            $('#code').css({"border-bottom":"1px solid red"}).siblings('p.tyu').text('验证码不能为空').css({"display":"block"});
             pwed_ok = false;
        }else{
            $.ajax({
                type: 'POST',
                url: "/weixin/login/register/checkCodeExist",
                data:{'code': $('#code').val()},
                dataType:"json",
                async: false,
                success: function(json){
//                    alert(json);
                    console.log(json);
                    if(json.status == "200") {
                        $('#code').css({"border-bottom":"1px solid #e6e6e6"}).siblings('p.tyu').text('').css({"display":"none"});
                        pwed_ok = true;
                    }else{
                        $('#code').css({"border-bottom":"1px solid red"}).siblings('p.tyu').text('验证码错误').css({"display":"block"});
                        pwed_ok = false;
                    }
                }
            });

        }
        return  pwed_ok;
    }



    $("#mask").hide();
    $('#next-step').click(function () {
        var pwed_ok=checkPwed();
        //判断code是否正确
        if(pwed_ok){
            //检查验证码是否正确
            window.location = "/weixin/login/resetThree";
        }
    })
</script>
</html>