<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE HTML>
<html>
<head>
    <title></title>
    <meta name="decorator" content="base" />
    <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>
<span class="hint explorerSupportTip" style="display: none;">建议您切换成谷歌、火狐或IE9及以上版本的浏览器!!!</span>
<form action="" class="bg2" id="formAll" method="post">

<div class="tabCon1">
    <div>
        <%--<img src="${ctxPlugin}/img/logo3.png" alt=""/>--%>
    </div>
    <div class="step_">
        <img src="${ctxPlugin}/img/step1.jpg" alt=""/>
    </div>
    <div class="have_  f-14 loginlink">已有账号 <a onclick="retn()" href="${ctx}/main/redirect/mainIndex">直接登录</a></div>
    <div class="step_ regis_"><span><i class="red">*</i>注册手机号：</span>
        <input type="text" class="input-text" placeholder="输入的手机号将作为登录的账户名" name="mobile" id="mobile"/>
        <input type="text" class="f-l w-300 input-text hide"  name="msgMark" id="msgMark" value="0"/>
    </div>
    <div class="step_ regis_">
    	<span>&emsp;<i class="red">*</i> 登录密码：</span>
        <input type="text" class="input-text" placeholder="6-16位的数字、字母或组合" name="password" id="password"/>
    </div>
    <div class="step_ duan">
    	<span><i class="red">*</i> 短信验证码：</span>
        <div class="input-text pd-0">
            <input type="text" class="input-text" placeholder="请输入短信验证码" name="confirmCode" id="confirmCode" />
            <button class="btn" type="button" id="btn">发送验证码</button>
        </div>
    </div>
    <div class="step_ regis_">
        <span>优惠码：</span>
        <input type="text" class="input-text" name="shareCode" id="shareCode" />

    </div>
    <div class="tipT">
	    <p class="red text-c" id="errorTip1"></p >
	</div>
    <div class="nextParent_">
    	<span><i class="red"></i> &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</span>
        <button type="button" class="btn next1_" id="btnNext">下一步</button>
    </div>
    
    <div class="foot__ footReg">
	    <p>为了您更好的系统使用体验，我们建议您使用：<img src="${ctxPlugin}/img/fox.png" alt=""/>&emsp;火狐浏览器&emsp;<img src="${ctxPlugin}/img/google.png" alt=""/>&emsp;谷歌浏览器</p>
	    <p>Copyright ©2014-2018 安徽思方网络科技有限公司 皖ICP备17000071号</p>
	</div>
</div>

<div class="tabCon2 hide">
    <div class="step_">
        <img src="${ctxPlugin}/img/step2.jpg" alt=""/>
    </div>
    <div class="have_ f-14 loginlink">已有账号 <a onclick="retn()" href="${ctx}/main/redirect/mainIndex">直接登录</a></div>
    <div class="step_ regis_ step3">
    	<span><i class="red">*</i> 公司名称：</span>
        <input type="text" class="input-text" placeholder="请输入3-40字以内的企业名称" name="name" id="name" datatype="*" errormsg="格式错误" nullmsg="请输入企业名称"/>
    </div>
    <div class="step_ regis_ step3">
    	<span><i class="c-white">*</i>公司地址：</span>
    	<div>
	        <select id="province" name="province">
	            <c:forEach items="${provincelist }" var="pro">
	                <option value="${pro.columns.ProvinceName }" >${pro.columns.ProvinceName }</option>
	            </c:forEach>
	            <input hidden="hidden" id="province1" name="province1" />
	        </select>
	        <select id="city" name="city">
	            <c:forEach items="${cities }" var="cs">
	                <option value="${cs.columns.CityName }" >${cs.columns.CityName }</option>
	            </c:forEach>
	            <input hidden="hidden" id="city1" name="city1" />
	        </select>
	        <select id="area" name="area">
	            <c:forEach items="${districts }" var="ds">
	                <option value="${ds.columns.DistrictName }" >${ds.columns.DistrictName }</option>
	            </c:forEach>
	            <input hidden="hidden" id="area1" name="area1" />
	        </select>
        </div>
    </div>
    <div class="step_ regis_ introAdd">
        <span><i class="red"></i> &nbsp;&emsp;&emsp;&emsp;&emsp;&emsp;</span>
        <input type="text" class="input-text" id="address" name="address" placeholder="请输入企业详细地址"  errormsg="格式错误" nullmsg="请输入详细地址"/>
    </div>
     <div class="tipT">
	    <p class="red text-c" id="errorTip"></p >
	</div>
    
    <div class="nextParent_">
    	 <span><i class="red"></i> &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</span>
        <button type="button" class="btn next1_ re_" id="btnNext2">注册</button>
    </div>
   
	<div class="foot__ footReg">
        <p>为了您更好的系统使用体验，我们建议您使用：<img src="${ctxPlugin}/img/fox.png" alt=""/>&emsp;火狐浏览器&emsp;<img src="${ctxPlugin}/img/google.png" alt=""/>&emsp;谷歌浏览器</p>
        <p>Copyright ©2014-2018 安徽思方网络科技有限公司 皖ICP备17000071号</p>
    </div>
</div>

<div class="tabCon3 hide">
    <div class="step_">
        <img src="${ctxPlugin}/img/step3.jpg" alt=""/>
    </div>
    <div class="step_ have_ f-14 loginlink">已有账号 <a onclick="retn()" href="${ctx}/main/redirect/mainIndex">直接登录</a></div>
    <div class="step_ regis_ yesRe">
        <img src="${ctxPlugin}/img/yes.png" alt=""/>
        <p>恭喜您，注册成功</p>
    </div>
    <div class="nextParent_" id="dlOrGm">
        <button type="button" class="btn next1_ login_a">立即登录</button>
    </div>
    <div class="foot__ footReg">
        <p>为了您更好的系统使用体验，我们建议您使用：<img src="${ctxPlugin}/img/fox.png" alt=""/>&emsp;火狐浏览器&emsp;<img src="${ctxPlugin}/img/google.png" alt=""/>&emsp;谷歌浏览器</p>
        <p>Copyright ©2014-2018 安徽思方网络科技有限公司 皖ICP备17000071号</p>
    </div>
</div>

</form>
<script type="text/javascript" src="${ctxPlugin}/lib/jqGrid_5.2/plugins/jquery.contextmenu.js"></script>
<script type="text/javascript" src="${ctxPlugin}/lib/socket.io.js"></script>
<script type="text/javascript" src="${ctxPlugin}/lib/jquery.qrcode.min.js"></script>
<script type="text/javascript" src="${ctxPlugin}/static/unipay/unipay.js"></script>
<script type="text/javascript" src="${ctxPlugin}/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="${ctxPlugin}/static/h-ui.admin/js/util.js"></script>
<script type="text/javascript">

    var exp = myexplorer();
    var explorerSupport = isExplorerSupport(exp);
    if(!explorerSupport){
        $(".explorerSupportTip").show();
    }

    var dueTime="";
    var monitor;
    var fsMsg="";
    var marks="";
    $("#province").change(function() {
        var province = $("#province").val();
        $.ajax({
            type : "post",
            url : "${ctx}/main/redirect/getCity1",
            async : false,
            data : {
                province : province
            },
            dataType : "json",
            success : function(data) {
                var obj = eval(data);
                var length = obj.length;
                if (length < 1) {
                    layer.msg("无数据");
                } else {
                    $("#city").empty();
                    $("#area").empty();
                    var HTML = " ";
                    for (var i = 0; i < length; i++) {
                        if (i == 0) {
                            HTML += '<option value="'+obj[i].columns.CityName+'" selected="selected">' + obj[i].columns.CityName + '</option>';
                        } else {
                            HTML += '<option value="'+obj[i].columns.CityName+'">' + obj[i].columns.CityName + '</option>';
                        }
                    }
                    $("#city").append(HTML);
                }

            },
            error : function() {
                return;
            },
            complete : function() {
                var cls = $("#city").find("option:selected").prop("value");
                $.ajax({
                    type : "post",
                    url : "${ctx}/main/redirect/getArea1",
                    async : true,
                    data : {
                        city : cls
                    },
                    dataType : "json",
                    success : function(data) {
                        var obj = eval(data);
                        var length = obj.length;
                        if (length < 1) {
                            layer.msg("无数据");
                        } else {
                            $("#area").empty();
                            var HTML = " ";
                            for (var i = 0; i < length; i++) {
                                if (i == 0) {
                                    HTML += '<option value="'+obj[i].columns.DistrictName+'" selected="selected">' + obj[i].columns.DistrictName + '</option>';
                                } else {
                                    HTML += '<option value="'+obj[i].columns.DistrictName+'" >' + obj[i].columns.DistrictName + '</option>';
                                }
                            }
                            $("#area").append(HTML);
                        }
                    }
                });

                return;
            }
        });
    });

    //选择市获取区县
    $("#city").change(function() {
        var city = $("#city").val();
        $.ajax({
            type : "post",
            url : "${ctx}/main/redirect/getArea1",
            async : false,
            data : {
                city : city
            },
            dataType : "json",
            success : function(data) {
                var obj = eval(data);
                var length = obj.length;
                if (length < 1) {
                    layer.msg("无数据");
                } else {
                    $("#area").empty();
                    var HTML = " ";
                    for (var i = 0; i < length; i++) {
                        if (i == 0) {
                            HTML += '<option value="'+obj[i].columns.DistrictName+'" selected="selected">' + obj[i].columns.DistrictName + '</option>';
                        } else {
                            HTML += '<option value="'+obj[i].columns.DistrictName+'" >' + obj[i].columns.DistrictName + '</option>';
                        }
                    }
                    $("#area").append(HTML);
                }
            }
        });
    });


    $('#btnNext').on('click', function(){
        $("#dlOrGm").empty();
        var mobile = $("#mobile").val();
        var password = $("#password").val();
        var confirmCode = $("#confirmCode").val();
        var shareCode = $("#shareCode").val();
        $("#errorTip1").empty();
        isBlank(password);
        if(isBlank(mobile)){
            $("#mobile").focus();
            $("#errorTip1").append('<p style="padding-right: 27px;" class="c-fe0101 f-13 lh-20 hide1"></i>请输入手机号</p>');
            $("#errorTip1").removeClass("hide");
            return ;
        }
        if(isBlank(password)){
            $("#password").focus();
            $("#errorTip1").append('<p style="padding-left: 35px;" class="c-fe0101 f-13 lh-20 hide1"></i>请输入6-16位字符的密码</p>');
            $("#errorTip1").removeClass("hide");
            return ;
        }
        if(CheckPassWord(password)==false){
            $("#password").focus();
            $("#errorTip1").append('<p style="padding-left: 35px;" class="c-fe0101 f-13 lh-20 hide1">请输入6-16位字符的密码</p>');
            $("#errorTip1").removeClass("hide");
            return ;
        }
        if(fsMsg=="1"){
            if(isBlank(confirmCode)){
                layer.msg("请输入您获取的短信验证码");
                $("#confirmCode").focus();
                return;
            }
        }else{
            layer.msg("请先点击发送短信验证码");
            $("#confirmCode").focus();
            return;
        }
        $.ajax({
            type:"post",
            url:"${ctx}/main/redirect/registerCheck",
            data:$("#formAll").serialize(),
            dataType:"text",
            success:function(result){
                if(result=="existName"){
                    $("#mobile").focus();
                    $("#errorTip1").append('<p class="c-fe0101 f-13 lh-20 hide1">该号码已注册，请勿重复注册</p>');
                    $("#errorTip1").removeClass("hide");
                }else if(result=="wrongMsg"){
                    $("#confirmCode").focus();
                    $("#errorTip1").append('<p class="c-fe0101 f-13 lh-20 hide1">您的短信验证码输入错误，请重新输入</p>');
                    $("#errorTip1").removeClass("hide");
                }else if(result=="wrongCode"){
                    $("#shareCode").focus();
                    $("#errorTip1").append('<p class="c-fe0101 f-13 lh-20 hide1">您输入的激活码不存在，请联系思方客服0551-66556995</p>');
                    $("#errorTip1").removeClass("hide");
                }else if(result=="qgOk" || result=="shOk"){
                    $(".tabCon1").addClass("hide");
                    $(".tabCon2").removeClass("hide");
                }else if(result=="nothing"){
                    $("#confirmCode").focus();
                    $("#errorTip1").append('<p class="c-fe0101 f-13 lh-20 hide1">您的短信验证码已失效，请重新获取</p>');
                    $("#errorTip1").removeClass("hide");
                }else if(result=="wrongShareCode"){
                    $("#shareCode").focus();
                    $("#errorTip1").append('<p class="c-fe0101 f-13 lh-20 hide1">您输入的优惠码不存在，请重新输入</p>');
                    $("#errorTip1").removeClass("hide");
                }
            }
        });
    });

    var registering = false;
    $('#btnNext2').on('click', function(){
        if(registering) {
            return;
        }

        $("#area1").val($('#area option:selected') .val());
        $("#province1").val($('#province option:selected') .val());
        $("#city1").val($('#city option:selected') .val());

        $("#errorTip").empty();
        var name = $("#name").val();
        var address = $("#address").val();
        if(isBlank(name)){
            $("#name").focus();
            $("#errorTip").append('<p class="c-fe0101 f-13 lh-20 hide1" style="padding-right: 38px;">输入企业名称！</p>');
            $("#errorTip").removeClass("hide");
            return ;
        }
        if(name.length < 4  ){
            $("#name").focus();
            $("#errorTip").append('<p class="c-fe0101 f-13 lh-20 hide1" style="padding-left: 82px;">您输入的企业名称错误，请重新输入！</p>');
            $("#errorTip").removeClass("hide");
            return ;
        }
        if(name.length > 20  ){
            $("#name").focus();
            $("#errorTip").append('<p class="c-fe0101 f-13 lh-20 hide1" style="padding-left: 82px;">您输入的企业名称错误，请重新输入！</p>');
            $("#errorTip").removeClass("hide");
            return ;
        }
        $.ajax({
            type:"post",
            url:"${ctx}/main/redirect/checkSiteName",
            data:{name:name},
            dataType: "text",
            success:function(result){
                if(result=="no"){
                    $("#name").focus();
                    $("#errorTip").append('<p class="c-fe0101 f-13 lh-20 hide1" style="padding-left: 82px;">您输入的企业名称已存在，请重新输入！</p>');
                    $("#errorTip").removeClass("hide");
                    return ;
                }else{
                    if(isBlank(address)){
                        $("#address").focus();
                        $("#errorTip").append('<p class="c-fe0101 f-13 lh-20 hide1"style="padding-right: 28px;">请输入详细地址！</p>');
                        $("#errorTip").removeClass("hide");
                        return ;
                    }
                    registering = true;
                    $.ajax({
                        type:"post",
                        url:"${ctx}/main/redirect/registerSign",
                        data:$("#formAll").serialize(),
                        dataType: "text",
                        success:function(result){
                            if(result=="existName"){
                                $("#mobile").focus();
                                $("#errorTip").append('<p class="c-fe0101 f-13 lh-20 hide1">该号码已注册，请勿重复注册</p>');
                                $("#errorTip").removeClass("hide");
                            }else if(result=="wrongMsg"){
                                $("#confirmCode").focus();
                                $("#errorTip").append('<p class="c-fe0101 f-13 lh-20 hide1" style="padding-left: 81px;">您的短信验证码输入错误，请重新输入</p>');
                                $("#errorTip").removeClass("hide");
                            }else if(result=="wrongCode"){
                                $("#shareCode").focus();
                                $("#errorTip").append('<p class="c-fe0101 f-13 lh-20 hide1">您输入的激活码不存在，请联系思方客服0551-66556995</p>');
                                $("#errorTip").removeClass("hide");
                            }else if(result=="qgOk" || result=="shOk"){
                                $("#dlOrGm").append('<button type="button" class="btn next1_ login_a" onclick="retn()">立即登录</button>');
                                $(".tabCon2").addClass("hide");
                                $(".tabCon3").removeClass("hide");
                                $('.loginlink').hide();
                            }else if(result=="nothing"){
                                $("#confirmCode").focus();
                                $("#errorTip").append('<p class="c-fe0101 f-13 lh-20 hide1"><i class="sficon sficon-errorwran2"></i>您的短信验证码已失效，请重新获取</p>');
                                $("#errorTip").removeClass("hide");
                            }
                        },
                        complete: function() {
                            registering =  false;
                        }
                    });
                }
            }
        })

    });

    $('#btnPrev').on('click', function(){
        $('#regSeqWrap').find('.currentSeq').last().prev().removeClass('registerFinish');
        $('#regSeqWrap').find('.currentSeq').last().removeClass('currentSeq');
        $(this).closest('.tabCon').hide().prev().show();
    });

    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 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("btn").onclick=function(){
        var ff = this;
        $("#errorTip1").empty();
        var mobile = $("#mobile").val();
        if(mobile.length==11 && (/^1[3|4|5|7|8|9][0-9]\d{4,8}$/.test(mobile))){//点击发送短信验证码
            fsMsg="1";
            $.ajax({
                type:"post",
                url:"${ctx}/main/redirect/sendMsg",
                data:{mobile:mobile},
                success:function(result){
                    if(result=="ok"){
                        time(ff);
                        $("#msgMark").val("0") ;
                    }else if(result=="existName"){
                        $("#mobile").focus();
                        $("#errorTip1").append('<p class="c-fe0101 f-13 lh-20 hide1">该号码已注册，请勿重复注册</p>');
                        $("#errorTip1").removeClass("hide");
                    }else{
                        layer.msg("发送失败，请检查！");
                        return ;
                    }
                }
            })
        }else{
            $("#mobile").focus();
            $("#errorTip1").append('<p class="c-fe0101 f-13 lh-20 hide1">请输入正确的手机号</p>');
            $("#errorTip1").removeClass("hide");
        }
    }

    function retn(){
        /* layer.open({
            type : 2,
            content:'${ctx}/main/redirect/mainIndex',
			title:false,
			area: ['100%','100%'],
			closeBtn:0,
			shade:0,
			anim:-1
		}); */
        window.parent.location.reload(true);
        window.close();
    }

    function bugSystem(){
        var mobile = $("#mobile").val();
        layer.open({
            type: 2,
            content: '${ctx}/main/redirect/openVIPSign?mobile='+mobile,
            //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://baidu.com', 'no']
            title:false,
            area: ['100%','100%'],
            closeBtn:0,
            shade:0
        });
    }

    $('#btnPrev1').on('click', function(){
        $('#regSeqWrap').find('.currentSeq').last().prev().removeClass('registerFinish');
        $('#regSeqWrap').find('.currentSeq').last().removeClass('currentSeq');
        $('.loginWrapBg').find('.tabCon2').hide();
        $('.loginWrapBg').find('.tabCon1').show();
    });

    $('#btnNext3').on('click', function(){
        $('#regSeqWrap2').find('.resStep').eq(1).addClass('resStep_cur');
        $('.loginWrapBg2').find('.tabCon1').hide();
        $('.loginWrapBg2').find('.tabCon2').show();
    });

    var formPosted = false;
    function zfPage(){
        if(formPosted) {
            return false;
        }
        marks="";
        formPosted = true;
        var index = layer.load(0, {shade: false});
        $(".payCode").empty();
        var countMoney = $(".vipCur input[name='countMoneyAll']").val();
        var gmMonth = $(".vipCur input[name='gmMonth']").val();
        var zfType = $(".vipCur input[name='zfbWx']").val();//支付宝：zfb；微信：wx;
        $("#countMoneyCopy").val(countMoney);
        $("#zfTypeCopy").val(zfType);
        $("#gmMonthCopy").val(gmMonth);
        $.ajax({
            type:"POST",
            url:"${ctx}/main/redirect/scPlatOrderSign",
            data:$("#formAll").serialize(),
            success:function(data){
                if (data.result.code == "200") {
                    var qrCodeUrl = data.result.data[0];
                    $('.payCode').qrcode({width: 150, height: 150, text: qrCodeUrl});
                    if(zfType=="zfb"){
                        $(".ljzf").removeClass("wxPay").addClass("zfbPay");
                    }else if(zfType=="wx"){
                        $(".lizf").removeClass("zfbPay").addClass("wxPay");
                    }
                    //$("#yfMoney").text(countMoney);
                    $("#zfbWxMoney").text(countMoney);
                    //$("#orderNo").text(data.result.data[2]);
                    /* var startTime;
                    var endTime;
                    var date =  new Date();
                    if(dueTime==null || dueTime==""){
                        startTime="";
                        endTime = "";
                    }else{
                        startTime="";
                        endTime="";
                    }
                    $("#dateRange").text("("+data.timeList[0].start +"-"+data.timeList[0].end+")");
                    var sbJect = "";
                    if(gmMonth=="1"){//
                        sbJect="一个月";
                    }else if(gmMonth=="6"){
                        sbJect="半年";
                    }else if(gmMonth=="12"){
                        sbJect="一年";
                    }else if(gmMonth=="24"){
                        sbJect="两年";
                    }else if(gmMonth=="36"){
                        sbJect="三年";
                    }
                    $("#limitDate").text(sbJect); */
                    $(".zfbCheck").addClass("vipCur");
                    $(".wxCheck").removeClass("vipCur");
                    //$.setPos($('.spPayWrap'));
                    //$('.payshadeBg').show();
                    //	$('.spPayWrap').show();

                    unipay.config({
                        cancelPath: "${ctx}/main/redirect/cancel",
                        queryOrderStatusPath: "${ctx}/main/redirect/status"
                    });
                    var payType="";
                    if(zfType=="zfb"){
                        payType="alipay";
                    }else{
                        payType="wx";
                    }
                    monitor = new unipay.Monitor(payType, data.result.data[1], {
                        onPaySuccess: function() {
                            $("#currentSeq1").addClass("currentSeq");
                            $(".payResultS").show();
                            $("#paymentPart").hide();
                            marks="ok";
                        },
                        onPayTimeout: function () {
                            layer.msg("支付超时");
                            //qquxiaozhifu();
                        }
                    });
                    monitor.start();
                }else{
                    $(".payResultF").show();
                }
            },
            error: function(a, b, c) {
            },
            complete: function () {
                formPosted = false;
                layer.close(index);
            }
        })
    }

    $('#btnNext4').on('click', function(){//点击完成
        if(marks=="ok"){
            $('#regSeqWrap2').find('.registerSeq').eq(1).addClass('registerFinish');
            $('#regSeqWrap2').find('.registerSeq').eq(2).addClass('currentSeq');
            $('.loginWrapBg2').find('.tabCon2').hide();
            $('.loginWrapBg2').find('.tabCon3').show();
        }else{
            layer.msg("请先完成支付！");
            return ;
        }

    });

    $('.vipPrice').on('click', function(){
        $(this).closest('.vipPriceW').find('.vipPrice').removeClass('vipCur');
        $(this).addClass('vipCur');
    });

    $('#btnPrev2').on('click', function(){
        $("#rgzc").hide();
        $('.loginWrapBg2').find('.tabCon2').hide();
        $('.loginWrapBg').show();
    });

</script>

</body>
</html>