<%@ 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 class="ert-head">
    <div class="ert-left">
        <a href="/weixin/login/init">
            <img src="/static/weChat/images/head-left.png" />
        </a>
    </div>
    <p>找回密码</p>
</div>
<div class="search-pwd">
    <input type="text" placeholder="请输入手机号/邮箱号" name="email" id="phone_email">
    <p class="tyu"></p>
    <a href="javascript:;" id="next-step">下一步</a>
    <div class="error"></div>
</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>
    phone_reg = /^1[2|3|4|5|6|7|8|9]\d{9}$/;
//    email_reg = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
    email_reg =/^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/;

    function checkPwed() {
        console.log(!$('#phone_email').val().match(phone_reg))
        console.log(!$('#phone_email').val().match(email_reg))
        if($('#phone_email').val() == ''){
            $('#phone_email').css({"border-bottom":"1px solid red"}).siblings('p').text('手机号或邮箱不能为空').css({"display":"block"});
            return pwed_ok = false;
        }else if( !$('#phone_email').val().match(phone_reg) && !$('#phone_email').val().match(email_reg) ){
            $('#phone_email').css({"border-bottom":"1px solid red"}).siblings('p').text('手机号或邮箱格式错误').css({"display":"block"});
            return pwed_ok = false;
        }else{
            $('#phone_email').css({"border-bottom":"1px solid #e6e6e6"}).siblings('p').text('').css({"display":"none"});
            return pwed_ok = true;
        }
    }
    function checkUserExist(){
        var  al=$("#phone_email").val();
        var  user_ok= false;
        $.ajax({
            type: 'POST',
            url: "/weixin/login/register/checkUserExist",
            data: {email:al},
            dataType:"json",
            async: false,
            success: function(data){
                if(data.status =="200"){
                    user_ok=true;
                }else{
                    layer.open({  content: "该帐号不存在" ,btn: '我知道了'   });
                }
            }
        });
        return user_ok;
    }
    $('#next-step').click(function () {
        checkPwed();
        var  user_ok=checkUserExist();
        if(pwed_ok){
            if(user_ok){
                window.location.href="/weixin/login/resetTwo";
            }
        }
    })
</script>
</html>