<?php require APPPATH_MVC.'views/header.php'; ?>
<style>
    .zm-rz2{display: none;}
</style>
<?php if(isset($_GET['retry']) && intval($_GET['retry']) == 1): ?>
    <style>
        .zm-rz{display: none;}
        .zm-rz2{display: block;}
    </style>
<?php endif; ?>
<style>
    .Validform_right{ display:none;}
    .cover {
        position: fixed;
        left: 0;
        top: 0;
        background: rgba(0, 0, 0, 0.6);
        filter: progid:DXImageTransform.Microsoft.gradient( GradientType=0, startColorstr="#60000000", endColorstr="#60000000");
        z-index: 19;
    }

    .sucewml_new{float: left;width: 168px;}
    .sucewml_new_pic{ border:1px solid #f0f0f0; width: 146px; height: 146px; padding: 10px; text-align: center;}
    .sucewml_new_pic img{ width: 146px; height: 146px;}
    .col_333333{color: #333333;}
    .col_ec6c00{color: #ec6c00;}
    .col_2760c7{color: #2760c7;}
    .mt20{margin-top: 20px;}
    .f14{font-size: 14px;}
    .h16{height: 16px;}
    .lh16{line-height: 16px;}
    .fl{float: left;}
    .fr{float: right;}
    .sucewmr_new{ float:right;width: 310px;height: 250px;}
    .font_bold{font-weight: bold;}
    .sucewmr_new_pic{width: 140px;height: 250px;}
    .f14{
        font-size: 14px;
    }

    .col_111111{
        color: #111111;
    }

    .pop {
        font-size: 12px;
        width: 665px;
        padding-bottom: 60px;
        position: fixed;
        background: #fff;
        z-index: 1001;
        font-family: Microsoft yahei;
        border-radius: 4px;
    }

    .pop button {
        border-radius: 4px;
        background: #ec6c00;
        color: #fff;
        font-size: 16px;
        padding: 14px 116px;
        margin-top: 25px;
        cursor: pointer;
    }

    .popwap {
        width: 506px;
        font-size: 14px;
        margin: 0 auto;
        color: #666;
    }

    .tit {
        width: 100%;
        height: 32px;
    }

    .tit span {
        background: url(../images/popclose.png) no-repeat;
        width: 28px;
        height: 28px;
        float: right;
        margin: 10px;
        cursor: pointer;
    }

    .popwap .sucewmr {
        width: 289px;
        margin-left: 20px;
    }

    .popwap .sucewmr p:first-child {
        font-size: 16px;
    }
    .sucewml{ float: left; border:1px solid #f0f0f0; width: 146px; height: 146px; padding: 10px; text-align: center;}
    .sucewml img{ width: 144px; height: 144px;}
    .sucewmr{ float: left; margin: 16px 0 0 24px; width: 322px;}
    .sucewmr p{ font-size: 14px;}
    .sucewmr p:first-child{ font-size: 18px; color: #333; margin-bottom: 20px;}
    .sucewm{ margin-top: 18px;}
    .word-orange{ color: #ec6c00;}

    /*银行卡实名认证*/
    /*字体模板*/
    /*边框模板*/
    input::-webkit-input-placeholder {
        /* WebKit browsers */
        color: #cccccc;
    }
    input:-moz-placeholder {
        /* Mozilla Firefox 4 to 18 */
        color: #cccccc;
    }
    input::-moz-placeholder {
        /* Mozilla Firefox 19+ */
        color: #cccccc;
    }
    input:-ms-input-placeholder {
        /* Internet Explorer 10+ */
        color: #cccccc;
    }
    .dn {
        display: none;
    }
    .imp {
        color: #ff0000;
    }
    .fl {
        float: left;
    }
    .fr {
        float: right;
    }
    .pb8 {
        padding-bottom: 8px;
    }
    .pt40 {
        padding-top: 40px;
    }
    .ylbox {
        width: 223px;
        height: 232px;
        border: 1px solid #d9d9d9;
        border-radius: 8px;
        margin-top: -234px;
        margin-left: 247px;
    }
    .ylbox .ylbox-1 {
        margin-top: 20px;
        text-align: center;
    }
    .ylbox .ylbox-2 {
        font-size: 16px;
        text-align: center;
        color: #4d4d4d;
        line-height: 1;
        margin: 13px 0;
    }
    .ylbox .ylbox-3,
    .ylbox .ylbox-4 {
        line-height: 1;
        font-size: 14px;
        color: #999;
        padding-left: 56px;
    }
    .ylbox .ylbox-5 {
        margin: 15px auto 0;
        width: 105px;
        height: 30px;
        background: #ff8400;
        text-align: center;
        line-height: 30px;
        font-size: 16px;
        color: #fff;
        border-radius: 2px;
        cursor: pointer;
    }

    .winmask {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
    }
    .winmask .winmask-pop {
        position: absolute;
        width: 652px;
        top: 154px;
        left: 50%;
        margin-left: -327px;
        border: 1px solid #fff;
        border-radius: 2px;
    }
    .winmask .winmask-pop .winmask-pop-hd {
        height: 32px;
        line-height: 32px;
        background: #f5f5f5;
    }
    .winmask .winmask-pop .winmask-pop-hd .title {
        font-size: 14px;
        color: #666666;
        padding-left: 15px;
        font-weight: bold;
    }
    .winmask .winmask-pop .winmask-pop-hd .close {
        margin-right: 10px;
        cursor: pointer;
        width: 20px;
        height: 32px;
        background: url(http://user.house365.com/images/bank/close-icon.png) right center no-repeat;
    }
    .winmask .winmask-pop .winmask-pop-bd {
        width: 100%;
        height: 100%;
        background: #fff;
        font-size: 14px;
        height: 543px;
    }
    .winmask .winmask-pop .winmask-pop-bd .form-item {
        position: relative;
        margin-bottom: 28px;
    }
    .winmask .winmask-pop .winmask-pop-bd .form-item .cd1 {
        width: 184px;
        height: 40px;
        margin-right: 7px;
        line-height: 40px;
        text-align: right;
        color: #999;
    }
    .winmask .winmask-pop .winmask-pop-bd .form-item .cd2 .inp {
        width: 288px;
        height: 38px;
        line-height: 38px;
        padding-left: 10px;
        color: #666;
        border: 1px solid #d9d9d9;
        border-radius: 2px;
    }
    .winmask .winmask-pop .winmask-pop-bd .form-item .cd2 .inp-sm {
        width: 178px;
        height: 38px;
        line-height: 38px;
        padding-left: 10px;
        color: #666;
        border: 1px solid #d9d9d9;
        border-radius: 2px;
    }
    .winmask .winmask-pop .winmask-pop-bd .form-item .codebtn {
        margin-left: 20px;
        width: 88px;
        height: 38px;
        text-align: center;
        line-height: 38px;
        border: 1px solid #ec6c00;
        border-radius: 2px;
        font-size: 14px;
        color: #ec6c00;
        cursor: pointer;
    }
    .winmask .winmask-pop .winmask-pop-bd .form-item .tips {
        color: #999;
        line-height: 1;
        margin-left: 191px;
        margin-top: 54px;
    }
    .winmask .winmask-pop .winmask-pop-bd .form-item .bank {
        margin-left: 10px;
        width: 88px;
        height: 40px;
        color: #333;
        padding-left: 10px;
        border: 1px solid #d9d9d9;
        border-radius: 2px;
        outline: none;
    }
    .winmask .winmask-pop .winmask-pop-bd .form-item .bankSelect {
        margin-left: 10px;
        width: 88px;
        height: 38px;
        line-height: 38px;
        color: #333;
        padding-left: 10px;
        border: 1px solid #d9d9d9;
        border-radius: 2px;
        /*background: url(http://user.house365.com/images/bank/s1.png) center right 10px no-repeat;*/
        cursor: pointer;
    }
    .winmask .winmask-pop .winmask-pop-bd .protocol {
        margin: 0 0 14px 191px;
    }
    .winmask .winmask-pop .winmask-pop-bd .protocol .checkboxC a {
        font-size: 12px;
        color: #666;
    }
    .winmask .winmask-pop .winmask-pop-bd .protocol .checkboxC label {
        font-size: 12px;
        color: #666;
        height: 14px;
        line-height: 14px;
        background: url(http://user.house365.com/images/bank/icon_choose.png) no-repeat;
        padding-left: 22px;
        cursor: pointer;
    }
    .winmask .winmask-pop .winmask-pop-bd .protocol .checkboxC label.on {
        background: url(http://user.house365.com/images/bank/ckon.png) no-repeat;
    }
    .winmask .winmask-pop .winmask-pop-bd .submitbtn {
        margin-left: 191px;
        width: 298px;
        height: 40px;
        font-weight: bold;
        line-height: 40px;
        text-align: center;
        background: #ec6c00;
        font-size: 16px;
        color: #fff;
        cursor: pointer;
        border: 1px solid #ec6c00;
        border-radius: 2px;
        margin-bottom: 60px;
    }
    .cardname_disabled{
        background-color: rgb(235, 235, 228);
    }
    .cardno_disabled{
        background-color: rgb(235, 235, 228);
    }
    .tpopcode{
        float: left;
        margin-left: 0px;
        width: 652px;
        display: block;
    }
    .bgrey{
        background-color: #ccc;
        color: #fff;
        border: 0px;
    }
    .bank-cloth {
        position: absolute;
        top: 112px;
        right: 50px;
        overflow-y: auto;
        z-index: 8;
        height: 287px;
        width: 394px;
        padding: 15px 0 0 15px;
        -webkit-box-shadow: 0 2px 6px #e9e9e9;
        box-shadow: 0 2px 6px #e9e9e9;
        border: 1px solid #e9e9e9;
        background: #fff;
        display: none;
    }
    .bank-cloth .list > span {
        display: inline-block;
        zoom: 1;
        text-align: center;
        padding: 5px 8px;
    }
    .bankSelect > i{

        display: inline-block;
        zoom: 1;
        width: 0;
        height: 0;
        margin-left: 2px;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 6px solid #dddddd;
    }

    .bankSelect.show > i{
        border-top: none;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-bottom: 6px solid #ff552e;
    }

</style>
<link rel="stylesheet" type="text/css" href="../css/identify.css"/>

<!--弹窗-->
<div class="cover"></div>
<div class="pop sucpop" style="display: none;">
    <div class="tit"><span onclick="HidePop('pop')"></span></div>
    <div class="popwap cf">
        <!--<p>只有实名认证用户可发布多条房源</p>-->
<!--        <p class="f14 col_111111 font_bold">只有实名认证用户可使用一键再发布，您也可以<a class="word-orange" target="_blank" href="#">重新发布房源>></a></p>-->

        <div class="cf sucewm clearfix">
            <div class="sucewml_new">
                <div class="sucewml_new_pic">
                    <img src="<?php echo $imgUrl;?>" />
                </div>
                <div class="mt20">
                    <div class="f14 col_333333 h16 lh16">扫码 <span class="col_ec6c00">下载淘房APP</span></div>
                    <div class="f14 col_333333 h16 lh16 mt10">后完成<span class="col_ec6c00">实名认证</span></div>
<!--                    <div class="h16 lh16 mt15">-->
<!--                        <a style="color: #2760c7;" target="_blank" href="http://app.house365.com">下载淘房APP>></a>-->
<!--                    </div>-->
                </div>
            </div>

            <div class="sucewmr_new">
                <div class="sucewmr_new_pic fl">
                    <img src="<?php echo $imgUrlbg1;?>" />
                </div>
                <div class="sucewmr_new_pic fr">
                    <img src="<?php echo $imgUrlbg2;?>" />
                </div>
            </div>
        </div>
    </div>
</div>

<!--2018 10 17 芝麻认证 end-->


<!--会员中心主体 Start--> 
<div class="w960 clearfix mt10 pepcenterBox">
 <?php require APPPATH_MVC.'views/left.php'; ?>
    <!--会员左侧 End-->
     <div class="user-main user-main02">
			<div class="hd-bar pos-r">
        	 <h2><?php echo $title;?></h2>
        </div>
  	  <div class="user-main">
            <div class="user-main">
                <form action="<?php echo USER_CENTER;?>user/bind_zmxy" method="post" id="zmxy_form" name="edit_password" class="form">
                <div class="zm-wap">
                    <?php if (empty($zhima)) {?>
                    <!--芝麻实名认证1-->
                    <div class="zm-rz" align="center">
                        <p class="mt20"><img src="<?php echo USER_CENTER;?>css/images/zm-icon.png"></p>
                        <p class="mt6 f16 c4d">芝麻实名认证</p>
                        <p class="mt5 f14 c9">· 适合有支付宝的用户</p>
                        <p class="f14 c9">· 无需拍照、实时通过</p>
<!-- onclick="ident()"-->
                        <p class="mt15"><button type="button" onclick="ShowPop('sucpop')" >立即认证</button></p>
                    </div>
                    <!--芝麻实名认证2-->
                    <div class="zm-rz2 cf">
                        <div align="center" class="fl">
                            <p class="mt38"><img src="<?php echo USER_CENTER;?>css/images/zm-icon.png"></p>
                            <p class="mt6 f16 c4d">芝麻实名认证</p>
                            <p class="mt5 f14 c9">· 适合有支付宝的用户</p>
                            <p class="f14 c9">· 无需拍照、实时通过</p>
                        </div>
                        <div class="fr">
                            <p align="center"><img src="<?php echo USER_CENTER;?>css/images/zm-step.png"></p>
                            <table>
                                <tr>
                                    <td>
                                        姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：
                                    </td>
                                    <td>
                                        <input type="text" value="" name="truename"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        身份证号：
                                    </td>
                                    <td>
                                        <input type="text" value="" name="idno"/>
                                        <input type="hidden" value="<?php echo $time;?>" name="time"/>
                                        <input type="hidden" value="<?php echo $token;?>" name="token"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2"><p align="center" class="mt5"><button id="submit" type="button" onclick="grant()">立即授权</button></p></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <?php } ?>
                    <!--芝麻实名认证3-->
                    <?php
                        if (!empty($zhima)) {
                            $display = '';
                            //获取隐藏的姓名与身份证
                            $truename = $userInfo[0]['truename'];
                            $strlen = mb_strlen($truename,'gbk');
                            $xing = str_repeat('*',$strlen-1);
                            $trueName = $xing.mb_substr($userInfo[0]['truename'],-1,1,'gbk');
                            $idNo = substr($userInfo[0]['idno'],0,6). '******' . substr($userInfo[0]['idno'],-4);
                        } else {
                            $display = 'display: none;';
                        }
                    ?>
                    <div class="zm-rz3" align="center"style="<?php echo $display;?>">
                        <p class="mt20"><img src="<?php echo USER_CENTER;?>css/images/zm-icon.png"></p>
                        <p class="mt6 f16 c4d">芝麻实名认证</p>
                        <p class="mt5 f14 c9" align="left">姓名：<?php echo $trueName;?></p>
                        <p class="f14 c9" align="left">身份证号：<?php echo $idNo;?></p>
                        <p class="mt15"><button type="button">已认证</button></p>
                    </div>


                    <!-- 银行卡实名认证 -->
                    <div class="ylbox zm-rz3" style="">
                        <div class="ylbox-1"><img src="<?php echo USER_CENTER;?>/images/bank/zm2-icon.png" alt="" /></div>
                        <div class="ylbox-2">银行卡实名认证</div>
                        <?php if(empty($bank_cert)): ?>
                            <div class="bank_cert">
                                <div class="ylbox-3 pb8">· 填写银行卡信息</div>
                                <div class="ylbox-4">· 安全可靠，实时通过</div>
                                <div class="ylbox-5">立即认证</div>
                            </div>

                        <?php else: ?>
                            <p class="mt5 f14 c9" align="left">姓名：<?php echo $user_card_info['truename']; ?></p>
                            <p class="f14 c9" align="left">身份证号：<?php echo $user_card_info['idno']; ?></p>
                            <p class="mt15" style="text-align: center;"><button type="button">已认证</button></p>
                        <?php endif;?>
                    </div>
                    <br>
                    <p>&nbsp;&nbsp;身份信息<span style="color: red">只限审核使用，不对外公布</span>，请放心填写！</p>

                </div>

                    <div class="rztab " style="margin-left: 30px;">
                        <div class="rztab-hd">认证优势</div>
                        <ul>
                            <li>
                                <div class="icon icon1"></div>
                                <p class="txt1">专属身份标识</p>
                                <p class="txt2">提高房源可信度</p>
                            </li>
<!--                            <li>-->
<!--                                <div class="icon icon2"></div>-->
<!--                                <p class="txt1">隐私保护服务</p>-->
<!--                                <p class="txt2">避免交易完仍有电话骚扰</p>-->
<!--                            </li>-->
                            <li>
                                <div class="icon icon3"></div>
                                <p class="txt1">优先展示</p>
                                <p class="txt2">房源排名靠前提高曝光度</p>
                            </li>
                            <li>
                                <div class="icon icon4"></div>
                                <p class="txt1">高级服务</p>
                                <p class="txt2">享有免费刷新，再发布功能</p>
                            </li>
                        </ul>
                    </div>


                </form>
            </div>
    </div>
	</div>
    <!--会员右侧 End-->
</div>

<div id="warning" class="pop" style=" display:none;z-index:100">
    <div class="hd">
    	<h2>提示</h2>
    	<a href="javascript:void(0)" class="close-win">关闭</a>
    </div>
    <div class="bd">
    	<div class="warning-inner">
        	<div class="war-bg" style="background:url(<?php echo USER_CENTER;?>/images/pop-ico.gif) 0 no-repeat;margin-left: 20px;"></div>
        	<p class="war-text" id="msg" style="line-height: normal;width: 250px;"></p>
        </div>
    	<div class="pop-btn-area"><a href="javascript:void(0);" class="close-win" style="background:#29B966;color:#fff;padding:7px 15px;margin:0 5px;border:1px solid #26AB5E">确定</a></div>
    </div>
</div>


<div class="winmask" style="display: none;">
    <div class="winmask-pop">
        <div class="winmask-pop-hd">
            <div class="fl title">银行卡实名认证</div>
            <div class="fr close"></div>
        </div>
        <div class="winmask-pop-bd clearfix">
            <form class="formalert" action="">
                <div class="form-item clearfix pt40">
                    <div class="cd1 fl"><span class="imp">*</span>银行卡号：</div>
                    <div class="cd2 fl"><input class="inp card_no" onkeyup="card_no(this)" maxlength="23" data="" type="text" placeholder="请输入您的银行卡号"/></div>
                    <div class="fl">
                        <!--<select class="bank" name="">
                            <option value="">支持银行</option>
                        </select>-->
                        <div class="bankSelect">
                            支持银行
                           <i></i>
                        </div>
                    </div>
                </div>
                <div class="bank-cloth">
                    <div class="list">
                        <?php foreach ($bank as $k=>$v): ?>
                            <span><?php echo $v; ?></span>
                        <?php endforeach; ?>
                    </div>

                </div>
                <?php  if(trim($user_card_info['truename'])):  ?>
                <div class="form-item clearfix">
                    <div class="cd1 fl"><span class="imp">*</span>持卡人姓名：</div>
                    <div class="cd2 fl cardname cardname_disabled"><input class="inp card_name" disabled value="<?php echo $user_card_info['truename']; ?>"/></div>
                </div>
                <?php else: ?>
                <div class="form-item clearfix">
                    <div class="cd1 fl"><span class="imp">*</span>持卡人姓名：</div>
                    <div class="cd2 fl "><input class="inp card_name"  value=""/></div>
                </div>
                <?php endif; ?>

                <?php  if(trim($user_card_info['idno'])):  ?>
                <div class="form-item clearfix">
                    <div class="cd1 fl"><span class="imp">*</span>持卡人身份证号：</div>
                    <div class="cd2 fl cardno cardno_disabled"><input class="inp card_id" disabled type="text" value="<?php echo $user_card_info['idno']; ?>"/></div>
                </div>
                <?php else: ?>
                <div class="form-item clearfix">
                    <div class="cd1 fl"><span class="imp">*</span>持卡人身份证号：</div>
                    <div class="cd2 fl"><input class="inp card_id" maxlength="20" type="text" value=""/></div>
                </div>
                <?php endif; ?>
                <div class="form-item clearfix">
                    <div class="cd1 fl"><span class="imp">*</span>银行预留手机号：</div>
                    <div class="cd2 fl"><input class="inp card_phone" type="text" placeholder="请输入银行预留手机号码"/></div>
                </div>
                <div class="form-item clearfix" style="overflow: hidden">
                    <div class="yanzheng" style="width: 1304px;float: left;">
                        <div class="tpopcode">
                            <div class="cd1 fl"><span class="imp">*</span>手机验证码：</div>
                            <div class="cd2 fl">
                                <input class="inp-sm phone-code" type="text" placeholder=""/>
                            </div>
                            <div class="codebtn fl bsend">立即获取</div>
                        </div>
                        <div class="tpopcode">
                            <div class="cd1 fl"></div>
                            <div class="cd2 fl">
                                <input class="inp-sm image-code imgcode" type="text" placeholder="请输入图形验证码"/>
                            </div>
                            <div class="fl " style="margin-left: 19px"><img class="showimgscode" onclick="reloadimgcode();" src="http://user.house365.com/user/imageCode"></div>
                        </div>
                    </div>
                    <p class="tips">验证码为365发送，与银行无关，请放心使用~</p>
                </div>
                <p class="errorinfo" style="color: red;text-align: center"></p>

                <div class="protocol"><span class="checkboxC on "><label class="checkboxC__label checkboxread on">我已阅读并接受</label><a target="_blank" href="http://user.house365.com/images/static/365_xieyi.pdf">《三六五认证服务协议》</a></span></div>
                <div class="submitbtn">确定</div>
            </form>
        </div>
    </div>
</div>

<script src="http://user.house365.com/js/layer-v3.1.1/layer/layer.js"></script>
<script>

    //银行卡实名认证
    $(function() {
        
        $('.checkboxread').on('click',function () {
            if($(this).hasClass('on')){
                $(this).removeClass('on')
            }else{
                $(this).addClass('on')
            }
        })
        
        $(".winmask .close").on("click", function () {
            $(".winmask").fadeOut();
        });

        $('.ylbox-5').on('click', function () {
            $(".winmask").fadeIn();
        })

        //点击整个弹出框，只要银行列表展开，都隐藏
        $('.bank-cloth').mouseleave(function () {
            if($('.bankSelect').hasClass('show')){
                $('.bank-cloth').css('display','none');
                $('.bankSelect').removeClass('show')
            }
        })
        
        $('.codebtn').on('click', function () {
            var phone_code = $.trim($('.card_phone').val());
            if($('.bsend').hasClass('bgrey')){
                return false;
            }
            if(!telnoValid(phone_code)){
                errorInfo('填写正确的预留手机号');
                return false;
            }
            reloadimgcode();
            $(".yanzheng").animate({marginLeft:"-654px"});
            return false;
        })

        $('.bankSelect').on('click', function () {
            if($(this).hasClass('show')){
                $('.bank-cloth').css('display','none');
                $(this).removeClass('show')
            }else{
                $('.bank-cloth').css('display','block');
                $(this).addClass('show')
            }
        })

        $("input.imgcode").on('keyup',function(){
            var telno = $.trim($('.card_phone').val());
            //验证手机号是否
            if(!telnoValid(telno)){
                //errorAlert('手机号不正确')
                return false;
            }
            if($.trim($(this).val()).length == 4){
                var code = $.trim($(this).val());
                var loginurl = '/user/imageCodeVerify';
                $.ajax({
                    url: loginurl,
                    type: 'get',
                    dataType: 'json',
                    data:{telno:telno,imageCode:code},
                    xhrFields: {
                        withCredentials: true
                    },
                    success: function(ret){
                        if(ret.code){
                            $('.bsend').addClass('bgrey');
                            errorInfo('');
                            $(".yanzheng").animate({marginLeft:"0px"});
                            settime($(".bsend"),60);

                        }else{
                            errorInfo(ret.msg);
                            return false;
                        }
                    }
                });
            }
        });

        //实名认证提交
        $('.submitbtn').on('click',function(){

            var card_no = $.trim($('.card_no').attr('data'));
            var card_name = $.trim($('.card_name').val());
            var card_id = $.trim($('.card_id').val());
            var card_phone = $.trim($('.card_phone').val());
            var code = $.trim($('.phone-code').val());
            var imgcode = $.trim($('.imgcode').val());

            if(!$('.checkboxread').hasClass('on')){
                errorInfo('请同意并接受365认证服务协议!');return false;
            }

            if(!card_no){
                errorInfo('填写银行卡号');return false;
            }
            if(!cardcert(card_no)){
                errorInfo('填写正确的银行卡号');return false;
            }
            if(!card_name){
                errorInfo('填写持卡人姓名');return false;
            }
            if(!card_id){
                errorInfo('填写持卡人身份证号');return false;
            }
            if(card_id && !$('.card_id').attr('disabled')) {
                var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
                if (reg.test(card_id) === false) {
                    errorInfo('请输入正确的身份证号');
                    return false;
                }
            }

            if(!card_phone || !telnoValid(card_phone)){
                errorInfo('填写正确预留手机号');return false;
            }
            if(!imgcode){
                reloadimgcode();
                $(".yanzheng").animate({marginLeft:"-654px"});
                errorInfo('填写图形验证码');return false;
            }
            if(!code){
                errorInfo('填写手机验证码');return false;
            }
            if(!code){
                errorInfo('填写手机验证码');return false;
            }
            errorInfo('');
            $('.submitbtn').html('认证中...');
            layer.load(0, {shade: false});
            $.ajax({
                url: '/user/bankCertify',
                type: 'post',
                dataType: 'json',
                data:{cardNo:card_no,certNo:card_id,name:card_name,phoneNo:card_phone,code:code},
                success: function(ret){
                    console.log(ret);
                    $('.submitbtn').html('确定');
                    if(ret.code){
                        $(".winmask").fadeOut();
                        var html = '<p class="mt5 f14 c9" align="left">姓名:'+ret.data.truename+'</p><p class="f14 c9" align="left">身份证号：'+ret.data.idno+'</p><p class="mt15" style="text-align: center;"><button type="button">已认证</button></p>';
                        $('.bank_cert').html(html);
                        layer.closeAll();
                    }else{
                        errorInfo(ret.msg);
                        layer.closeAll();
                        return false;
                    }
                }
            });
        })

    })

    function card_no(obj){
        var cardno = $(obj).val();
        var val = cardno.replace(/\s+/g,"");
        $(obj).attr('data',val);
        var showstr = strfuns(val)
        $(obj).val(showstr);
    }

    //银行卡号验证
    function cardcert(va){
        if(/^[0-9]+$/.test(va) && va.length<=19){
            return true
        }
        return false;
    }

    function strfuns(str) {

        var restr = '';
        function refunction(str)
        {
            var len = str.length;
            if (len > 4) {
                restr += str.substr(0, 4)+' ';
            } else {
                restr += str.substr(0, 4);
            }
            var res = str.substr(4)
            if (res.length > 0) {
                refunction(res);
            }
        }
        refunction(str);
        return restr;
    }

    //$(".yanzheng").animate({marginLeft:"-463px"});

    function reloadimgcode() {
        var codeurl = 'http://user.house365.com/user/imageCode?';
        var urlc = codeurl+'t='+Math.random();
        $('.imgcode').val('');
        $('.showimgscode').attr('src',urlc)
    }
    //手机号验证
    function telnoValid(value){
        partten = /^1[0-9]{10}$/;
        if(value && partten.test(value)){
            return true
        }
        return false;
    }




    function errorInfo(msg){
        $('.errorinfo').html(msg);
    }

    function settime(obj,countDown) { //发送验证码倒计时
        if (countDown == 0) {
            $(obj).attr('disabled', false);
            $(obj).removeClass("bgrey");
            $(obj).text("重新发送");
            countDown = 60;
            return;
        } else {
            $(obj).attr('disabled', true);
            $(obj).text("已发送(" + countDown + ")秒");
            countDown--;
        }
        setTimeout(function () {
            settime(obj,countDown);
        }, 1000)
    }

    //弹出提示
    function ShowPop(show, content) {
        var bh = $(window).height();
        var bw = $(window).width();
        $(".cover").css({
            height: 2 * bh,
            width: bw,
            display: "block"
        });
        var name = show;
        var t = $("." + show).height();
        var l = $("." + show).width();
        $("." + show).css({
            "top": (bh - t) / 2,
            "left": (bw - l) / 2
        });
        $("." + show + ' .normalh').html(content);
        $("." + show).fadeIn(500);
    }

    //关闭提示
    function HidePop(show) {
        $(".cover").fadeOut(100);
        $("." + show).fadeOut(500);
        window.location.reload();
    }

    var openWin = function(obj, type){
        var winHeght = $(document).height() ;
        var winElemt = $('#'+ obj);

        var win = {

            height : function(){
                return winElemt.outerHeight();
            },

            width : function(){
                return winElemt.outerWidth();
            },

            show : function(){
                winElemt.css({
                    'position':'absolute',
                    'z-index':'9999902',
                    'left':'50%',
                    'margin-left':'-' + win.width() / 2 + 'px',
                    'top':$(window).height()/2 - (win.height()/2) + $(window).scrollTop() + 'px'
                }).show();
            },

            hide : function(){
                winElemt.hide();
            }

        };
        win.show();
        $('.close-win').click(function(){
            win.hide();
            if(type == 2){
                window.location = "<?php echo USER_CENTER;?>user/bind_zmxy";
            }
        });
    };
    function ex_alert(msg, type){
        $("#msg").html(msg);
        openWin('warning', type);
        if(type == 2){
            setTimeout("window.location = '<?php echo USER_CENTER;?>user/bind_zmxy'",3000);
        }
    }
    function ident(){
        return false; //以前的逻辑
        $(".zm-rz").hide();
        $(".zm-rz2").fadeIn();
    }
    function identityCodeValid(code) {
        var city={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外 "};
        //var tip = "";
        var pass= true;

        if(!code || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code)){
            //tip = "身份证号格式错误";
            pass = false;
        }

        else if(!city[code.substr(0,2)]){
            //tip = "地址编码错误";
            pass = false;
        }
        else{
            //18位身份证需要验证最后一位校验位
            if(code.length == 18){
                code = code.split('');
                //∑(ai×Wi)(mod 11)
                //加权因子
                var factor = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ];
                //校验位
                var parity = [ 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 ];
                var sum = 0;
                var ai = 0;
                var wi = 0;
                for (var i = 0; i < 17; i++)
                {
                    ai = code[i];
                    wi = factor[i];
                    sum += ai * wi;
                }
                var last = parity[sum % 11];
                if(last != code[17]){
                    //tip = "校验位错误";
                    pass =false;
                }
            }
        }
        //if(!pass) alert(tip);
        return pass;
    }
    function grant(){
        var truename = $("input[name=truename]").val();
        var idno = $("input[name=idno]").val();
        if (truename == '' || idno == '') {
            ex_alert("姓名和身份证不能为空！", 1);
            return false;
        }
        var reg = /^[\u4e00-\u9fa5]+$/;
        if (!reg.test(truename) || truename.length > 4 || truename.length < 1) {
            ex_alert( "姓名格式错误！", 1);
            return false ;
        }
        if (!identityCodeValid(idno)) {
            ex_alert("身份证格式错误！", 1);
            return false;
        }
        $("#submit").attr('disabled',true);
        /*
        $.ajax({
            url: "/user/bind_zmxy/",
            type: "POST",
            dataType: "json",
            data :$("#zmxy_form").serialize(),
            success: function (data) {
                if (data.status == 1) {
                    window.location = data.url;
                } else {
                    ex_alert(data.msg, 2);
                }
            },
            error: function () {
                ex_alert("网络异常，请稍后再试", 2);
            }
        });*/
        $.ajax({
            url: '/alipay/saveInforamtion',
            type: 'POST',
            dataType: 'json',
            data: $("#zmxy_form").serialize(),
            success: function (data) {
                if (data.status === 1) {
                    window.location.href = '/alipay/authorization';
                } else {
                    ex_alert(data.message);
                }
            },
            error: function () {
                ex_alert("网络异常，请稍后再试", 2);
            }
        });
        
        $("#submit").attr('disabled',false);
    }

</script>
<?php require APPPATH_MVC.'views/footer.php'; ?>
