<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head lang="en">
    <meta name="decorator" content="base"/>
    <title></title>
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/h-ui/css/H-ui.css"/>
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" href="${ctxPlugin}/static/h-ui.admin/css/style.css"/>
</head>
<body>
<div class="bg2">
    <div>
        <%--<img src="${ctxPlugin}/img/logo3.png" alt=""/>--%>
    </div>
    <div class="step_">
        <!--<img src="img/step1.jpg" alt=""/>-->
    </div>
    <div class="step_ have_ f-14">返回，<a href="${ctx}/main/redirect/mainIndex">立即登录</a></div>
    <div class="step_ regis_"><span><i class="red">*&nbsp;</i>注册手机号：</span>
        <input type="text" class="input-text" name="mobile" id="mobile"/>
    </div>

    <div class="step_ duan">
        <span><i class="red">*</i> 短信验证码：</span>
        <div class="input-text pd-0">
            <input type="text" class="input-text" name="msgCheck" id="msgCheck" />
            <button type="button" class="btn" id="sendMsg">发送验证码</button>
        </div>
    </div>

   <%-- <div class="step_ regis_">
        <span><i class="red">*&nbsp;</i>短信验证码：</span>
        <input type="text" class="input-text" name="msgCheck" id="msgCheck" />
        <button type="button" class="btn" id="sendMsg">发送短信验证码</button>
    </div>--%>
    <div class="step_ regis_"><span><i class="red">*&nbsp;</i>新&emsp;密&emsp;码：</span>
        <input type="text" class="input-text" id="password" name="password"/>
    </div>
    <div class="step_ regis_"><span><i class="red">*&nbsp;</i>确&nbsp;认&nbsp;密&nbsp;码：</span>
        <input type="text" class="input-text" id="password1" name="password1"/>
    </div>
    <div class="text-c w80 red f-12  lh-20 pd-0 hide" id="checkMobile">
        <!-- <p class="c-fe0101 f-13 lh-20 "><i class="sficon sficon-errorwran2"></i>您输入的手机号错误，请重新输入！</p> -->
    </div>
    <div class="nextParent_">
        <button type="button" class="btn next1_" onclick="submitPwd()">确认重置</button>
    </div>
</div>
<div class="foot__">
    <p>为了您有更好的系统使用体验，我们建议您使用：
        <img src="${ctxPlugin}/img/fox.png" alt=""/>&emsp;<a class="btn_browserFf mr-10" href="http://www.firefox.com.cn/" target="_blank">火狐浏览器</a>&emsp;
        <img src="${ctxPlugin}/img/google.png" alt=""/>&emsp;<a class="btn_browserGg" href="https://www.google.cn/chrome/" target="_blank">谷歌浏览器</a></p>
    <p>Copyright ©2014-2018 安徽思方网络科技有限公司 皖ICP备17000071号</p>
</div>
<script type="text/javascript" src="${ctxPlugin}/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    var fsMsg="0";
    $(function(){

    })

    function isBlank(val) {
        if (val == null || $.trim(val) == '' || val == undefined) {
            return true;
        }
        return false;
    }

    function CheckPassWord(password) {

        var str = password;
        if ((str.length < 6) || (str.length > 16) ) {
            return false;
        }
        /*  var reg1 = new RegExp(/^[a-zA-Z0-9]{6,16}$/);
         if (!reg1.test(str)) {
             return false;
         } */
    }

    function submitPwd(){
        $("#checkMobile").empty();
        var mobile = $("#mobile").val();
        var password = $("#password").val();
        var password1 = $("#password1").val();
        var msgCheck = $("#msgCheck").val();//验证码
        if(fsMsg=="1"){
            if(isBlank(msgCheck)){
                layer.msg("请输入您获取的短信验证码");
                $("#msgCheck").focus();
                return;
            }
        }else{
            layer.msg("请先点击发送短信验证码");
            $("#confirmCode").focus();
            return;
        }
        if(isBlank(password)){
            $("#password").focus();
            $("#checkMobile").append('<p class="c-fe0101 f-13 lh-20 hide1" style="padding-left: 35px;">请输入6-16位字符的密码</p>');
            $("#checkMobile").removeClass("hide");
            return ;
        }
        if(CheckPassWord(password)==false){
            $("#password").focus();
            $("#checkMobile").append('<p class="c-fe0101 f-13 lh-20 hide1" style="padding-left: 35px;">请输入6-16位字符的密码</p>');
            $("#checkMobile").removeClass("hide");
            return ;
        }
        if(password != password1){
            $("#password1").focus();
            $("#checkMobile").append('<p class="c-fe0101 f-13 lh-20 hide1" style="padding-left: 115px;">您输入的的密码前后不一致，请重新输入</p>');
            $("#checkMobile").removeClass("hide");
            return ;
        }

        $.ajax({
            type:"post",
            url:"${ctx}/main/redirect/resertPwd",
            data:{mobile:mobile,password:password,msgCheck:msgCheck},
            datype:"text",
            success:function(result){
                if(result=="errorMsg"){
                    $("#msgCheck").focus();
                    $("#checkMobile").append('<p class="c-fe0101 f-13 lh-20 hide1" style="padding-left: 102px;">您的短信验证码输入错误，请重新输入</p>');
                    $("#checkMobile").removeClass("hide");
                    return ;
                }else if(result=="ok"){
                    layer.msg("密码编辑成功！");
                    setTimeout(function() {
                            window.parent.location.reload(true);
                            window.close();
                        },
                        500)
                }else{
                    $("#checkMobile").append('<p class="c-fe0101 f-13 lh-20 hide1">注册失败，请检查！</p>');
                    $("#checkMobile").removeClass("hide");
                }

            }
        })


    }

    var wait=60;
    function time(o) {
        if (wait == 0) {
            $(o).attr("disabled",false);
            $(o).text("发送短信验证码");
            wait = 60;
        } else {
            $(o).attr("disabled", true);
            $(o).text("重新发送(" + wait + ")");
            wait--;
            setTimeout(function() {time(o)}, 1000)
        }
    }
    document.getElementById("sendMsg").onclick=function(){
        var ff = this;
        $("#checkMobile").empty();
        var mobile = $("#mobile").val();
        if(mobile.length==11 && (/^1[3|4|5|7|8][0-9]\d{4,8}$/.test(mobile))){//点击发送短信验证码
            fsMsg="1";
            $.ajax({
                type:"post",
                url:"${ctx}/main/redirect/sendMsg1",
                data:{mobile:mobile},
                success:function(result){
                    if(result=="noExist"){
                        $("#mobile").focus();
                        $("#checkMobile").append('<p class="c-fe0101 f-13 lh-20 hide1"><i class="sficon sficon-errorwran2"></i>该手机号未注册</p>');
                        $("#checkMobile").removeClass("hide");
                    }else if(result=="ok"){
                        time(ff);
                    }else{
                        layer.msg("发送失败，请检查！");
                        return ;
                    }
                }
            })
        }else{
            $("#mobile").focus();
            $("#checkMobile").append('<p class="c-fe0101 f-13 lh-20 hide1"><i class="sficon sficon-errorwran2"></i>请输入正确的手机号</p>');
            $("#checkMobile").removeClass("hide");
        }
    }

    function retn(){
        window.parent.location.reload(true);
        window.close();
    }
</script>
</body>
</html>