<?php
if (!defined('ROOT'))
	exit ;
?>
<!DOCTYPE html>
<html>

	<head>
		<title>安全信息绑定-106云盘www.<?php echo C('BEN_BZUSR');?></title>
		<meta name="description" content="">
		<meta name="keywords" content="">
		<?php
		include 'Inc_files.php';
		?>
		<style type="text/css">
		.pt5{padding-top: 5px;}
		</style>
		<link rel="stylesheet" type="text/css" href="/static/member/css/wap.1.0.0.css">
	</head>

	<body data-type="index">
		<script src="<?php echo C('TMPL_PARSE_STRING.__TPL__'); ?>/assets/js/theme.js"></script>
		<div class="am-g tpl-g">
			<?php include 'Inc_head.php'?>
			<!-- 侧边导航栏 -->
			<?php
				include 'Inc_left.php';
			?>
			<!-- 内容区域 -->
			<div class="tpl-content-wrapper">
				<div class="row-content am-cf">
					<div class="row">
	                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
	                        <div class="widget am-cf">
	                            <div class="widget-head am-cf">
	                                <div class="widget-title am-fl">安全信息 </div>
	                            </div>
	                            <div class="widget-body am-fr">
	                                <form  class="am-form tpl-form-border-form tpl-form-border-br">
	                                	<input type="hidden" name="model_id" value="27" />
	                                	<input type="hidden" name="id" value="<?php echo session('user_auth.id');?>" />
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">真实姓名 </label>
	                                        <div class="am-u-sm-9 pt5">
	                                        	<?php
	                                        	if(empty($modval['truename'])){
	                                        	    echo '未设置，<a href="/member/alipay">点击设置</a>';
	                                        	}else{
	                                        		echo substr_cut($modval['truename']);
	                                        	}	
	                                        	?>
	                                        </div>
	                                    </div>
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">联系手机 </label>
	                                        <div class="am-u-sm-9 pt5">
	                                        	<?php
	                                        	echo substr_cut($modval['mobile'],3,4).'（<a href="/member/mobileold">更换手机</a>）';	
	                                        	?>
	                                        </div>
	                                    </div>
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">身份证 </label>
	                                        <div class="am-u-sm-9 pt5">
	                                        	<?php
	                                        	if(empty($modval['idcard'])){
	                                        	    echo '未设置，<a href="/member/alipay">点击设置</a>';
	                                        	}else{
	                                        		echo substr_cut($modval['idcard'],10,4);
	                                        	}	
	                                        	?>
	                                        </div>
	                                    </div>
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">联系邮箱 </label>
	                                        <div class="am-u-sm-9 pt5">
	                                        	<?php
	                                        	if(empty($modval['email'])){
	                                        	    echo '未设置，<a href="/member/email">点击设置</a>';
	                                        	}else{
	                                        		echo substr_cut($modval['email'],strlen($modval['email'])/2-2,strlen($modval['email'])/2-2).'（<a href="/member/emailold">更换邮箱</a>）';
	                                        	}	
	                                        	?>
	                                        </div>
	                                    </div>
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">绑定微信 </label>
	                                        <div class="am-u-sm-9 pt5 weixin_bind">
	                                        	<?php
	                                        	if(empty($modval['weixin'])){
	                                        	    echo '未绑定，<a href="#ewm" data-am-modal="{width:380}">点击绑定</a>';
	                                        	}else{
	                                        		echo '已绑定，<a href="#ewm" data-am-modal="{width:380}">点击重新绑定</a>';
	                                        	}	
	                                        	?>
	                                        </div>
	                                    </div>
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">二级密码 </label>
	                                        <div class="am-u-sm-9 pt5">
	                                        	<?php
	                                        	if(empty($modval['password2'])){
	                                        	    echo '未设置，<a href="/member/safe2">点击设置</a>';
	                                        	}else{
	                                        		echo '已设置，<a href="/member/safe2">点击修改</a>';
	                                        	}	
	                                        	?>
	                                        </div>
	                                    </div>
	                                </form>
	                            </div>
	                        </div>
	                    </div>
	                </div>
				</div>
			</div>
		</div>
		<?php
		include 'Inc_files_boot.php';
		?>
		<div class="am-modal am-modal-no-btn" tabindex="-1" id="ewm">
		  <div class="am-modal-dialog">
		    <div class="am-modal-hd">使用微信扫描二维码绑定
		      <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
		    </div>
		    <div class="am-modal-bd">
		      <img src="<?php echo $ewm;?>" width="300" />
		    </div>
		  </div>
		</div>
		<script src="/static/public/js/idard.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
		jQuery(document).ready(function($){ 
		    try{
		    	jQuery('#ewm').on('open.modal.amui', function(){
		    		var time=Math.floor(new Date().getTime()/1000);
		    		jQuery.ajax({
		    			url:"/member/weixin_bind_time_update",
		    		    data:{
		    		    	time:time
		    		    },
		    		    dataType: "json",
		    		    type: "post",
		    		    timeout: 10000,
		    		    success: function(data) {
		    		       console.log(data); 
		    		    },
		    		    error: function() {
		    		        mui.toast("网络连接超时");
		    		    }
		    		});
					cl=setInterval(function () {
			        	jQuery.ajax({
				        	url:"/member/is_weixin_bind",
				            data:{
				            	time:time
				            },
				            dataType: "json",
				            type: "post",
				            timeout: 10000,
				            success: function(data) {
				            	if (data.status==1) {
				            		clearInterval(cl);
				            		jQuery(".weixin_bind").html('已绑定，<a href="#ewm" data-am-modal="{width:380}">点击重新绑定</a>');
				            		jQuery("#ewm").modal('close');
				            	}
				            },
				            error: function() {
				                mui.toast("网络连接超时");
				            }
				        }); 
			        },3000);
				}).on('close.modal.amui',function () {
        			clearInterval(cl);
        		});
		    }catch(e){}
		});
		jQuery(document).on('click','.btn_submit',function () {
		    var the=jQuery(this);
		    if (jQuery('[name="truename"]').val()=='' || jQuery('[name="idcard"]').val()=='' || jQuery('[name="alipay"]').val()=='') {
		    	wd_alert({msg:'请完善相关信息',background:'#f00'});
		    	return false;
		    }
		    jQuery.ajax({
		    	url:"/v/mod",
		        data:the.closest('form').serializeArray(),
		        dataType: "json",
		        type: "post",
		        timeout: 10000,
		        success: function(data) {
		        	if (data.statua==1) {
		        		wd_alert({msg:data.info})
		        	}else{
		        		wd_alert({msg:data.info,background:'#f00'})
		        	}
		        },
		        error: function() {
		        }
		    });          
		});
		jQuery(document).on('blur','[name="idcard"]',function () {
		    var the=jQuery(this);
		    var checkFlag = new clsIDCard(the.val());
		    if (!checkFlag.IsValid() && the.val()!='') {
		    	wd_alert({msg:'身份证号码有误，请检查',background:'#f00'});
		    	jQuery('.btn_submit').prop('disabled',true);
		    }else{
		    	jQuery('.btn_submit').prop('disabled',false);
		    }         
		})
		</script>
	</body>

</html>