<?php 
	$this->display(tpl('head')); 
	if( (C('MYDB.id_type') && C('MYDB.id_type')==1) ||  !C('MYDB.id_type') ) {
		$hide2 ="none";
		$click1="checked" ;
	 } else { 
		$hide1 ="none" ;
		$click2="checked";
	}
	$renzheng=unserialize(C('renzheng'));
?>
<style>
	body{
		background-color: #ddd;
	}
	.list,.yz_content{
		float: left;
		width: 98%;
		background: #fff;
		margin: 1%;
	}
	.list ul{
		float: left;
		padding: 10px;
	}
	.list ul a{
		float: left;
		border:1px solid #009688;
		color: #009688;
		padding: 5px 10px;
		margin: 10px 10px 10px 0;
	}
	.list ul a:hover,.list ul a.hover{
		background: #009688;
		color: #fff;
	}
	.yz_content .sort{
		float: left;
		padding: 1%;
		width: 98%;
		border-bottom: 1px solid #ddd;
		font-weight: bolder;
	}
	.yz{
		float: left;
		width: 100%;
		margin-top: 10px;
	}
	.yz .layui-form-label{
		width: 120px;
	}
	.yz .layui-input{
		width: 200px;
	}
	.yz .yzm .layui-input{
		width: 60px;
	}
	.layui-input-block span{
		float: left;
	}
	.layui-input-block span:last-child{
		margin-left: 10px;
	}
	.photo{
		position: absolute;
		top: 200px;
		left: 500px;
		display: none;
	}
	.photo img{
		width: 400px;
		height: 200px;
	}
	.msg{
		font-weight: bolder;
		color: red;
	}
	.upimg img{
		width: 200px;
		height: 150px;
	}
	.layui-input-block dd{
		padding: 10px 0;
	}
	.green{
		color: green;
	}
	.up_state_img{
		float: left;
		width: 100%;
		margin-top: 10px;
	}
	.up_state_img img{
		width: 90%;
		
	}
</style>

<div class="list">
	<ul>
		<foreach array="list">
			<php> $hover=$_GET['type'] && $_GET['type']==$row['dir'] ? 'hover' : $key=='0' && !$_GET['type'] ? 'hover' : ''</php>
			<a class="{{$hover}}" href="/user/renzheng/index/type/{{$row['dir']}}">{{$row['name']}}</a>
		</foreach>
	</ul>
</div>
<div class="yz_content">
	<div class="sort">身份主体验证</div>
	<div class="yz">
		<form class="layui-form" method="post">
			
			<div class="layui-form-item">
			    <label class="layui-form-label">验证主体</label>
			    <div class="layui-input-block">
					<if condition="C('MYDB.id_rz_state') =='1'">
						<if condition="C('MYDB.id_type') =='1'">
							<dd>个人认证</dd>
						<else>
							<dd>企业认证</dd>
						</if>
					<else>
					<input type="radio" lay-filter="main_input" name="_type" {{$click1}} value="1" class="layui-input" title="个人"/>
					<input type="radio" lay-filter="main_input" name="_type" {{$click2}} value="2" class="layui-input" title="企业"/>
					</if>
				</div>
			</div>
			<div class="_type1" style="display:{{$hide1}}">
				<div class="layui-form-item">
				    <label class="layui-form-label">姓名</label>
				    <div class="layui-input-block">
						<if condition="C('MYDB.id_rz_state') =='1'">
							<dd>{{C('MYDB.real_name')}}</dd>
						<else>
						<input type="text" name="truename" value="{{C('MYDB.real_name')}}" class="layui-input"/>
						</if>
					</div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">身份证号码</label>
				    <div class="layui-input-block">
						<if condition="C('MYDB.id_rz_state') =='1'">
							<dd>{{C('MYDB.id_number')}}</dd>
						<else>
						<input type="text" name="id_number" value="{{C('MYDB.id_number')}}" class="layui-input"/>
						</if>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">身份证正面照片</label>
				    <div class="layui-input-block upimg">
						<if condition="C('MYDB.id_rz_state') =='1'">
							<img src="{{get_img_url($img['idcard_zheng'])}}" >
						<else>
						<span style="display: none;"><input type="text" readonly name="idcard_zheng" id="idcard_zheng"  value="{{$img['idcard_zheng']}}" class="layui-input"/></span>
						<span><a href="javascript:" class="layui-btn" onclick="upload_img('idcard_zheng')">上传</a></span>
						<div class="up_state_img" id="up_idcard_zheng">
							<img src="{{get_img_url($img['idcard_zheng'])}}" >
						</div>
						</if>
					</div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">身份证反面照片</label>
				    <div class="layui-input-block upimg">
						<if condition="C('MYDB.id_rz_state') =='1'">
							<img src="{{get_img_url($img['idcard_fan'])}}" >
						<else>
						<span style="display: none;"><input type="text" readonly name="idcard_fan" id="idcard_fan"  value="{{$img['idcard_fan']}}" class="layui-input"/></span>
						<span><a href="javascript:" class="layui-btn" onclick="upload_img('idcard_fan')">上传</a></span>
						<div class="up_state_img" id="up_idcard_fan">
							<img src="{{get_img_url($img['idcard_fan'])}}" >
						</div>
						</if>
					</div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">手持身份证照片</label>
				    <div class="layui-input-block upimg">
						<if condition="C('MYDB.id_rz_state') =='1'">
							<img src="{{get_img_url($img['idcard_shouchi'])}}" >
						<else>
						<span style="display: none;"><input type="text"  name="idcard_shouchi" id="idcard_shouchi"  value="{{$img['idcard_shouchi']}}" class="layui-input"/></span>
						<span><a href="javascript:" class="layui-btn" onclick="upload_img('idcard_shouchi')">上传</a></span>
						<div class="up_state_img" id="up_idcard_shouchi">
							<img src="{{get_img_url($img['idcard_shouchi'])}}" >
						</div>
						</if>
					</div>
				</div>
			</div>
			<div class="_type2" style="display:{{$hide2}}">
				<div class="layui-form-item">
				    <label class="layui-form-label">企业名称</label>
				    <div class="layui-input-block">
						<if condition="C('MYDB.id_rz_state') =='1'">
							<dd>{{C('MYDB.real_name')}}</dd>
						<else>
						<input type="text" name="company_truename" value="{{C('MYDB.real_name')}}" class="layui-input"/>
						</if>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">统一社会信用代码</label>
				    <div class="layui-input-block">
						<if condition="C('MYDB.id_rz_state') =='1'">
							<dd>{{C('MYDB.id_number')}}</dd>
						<else>
						<input type="text" name="company_code" value="{{C('MYDB.id_number')}}" class="layui-input"/>
						</if>
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">营业执照扫描件</label>
				    <div class="layui-input-block upimg">
						<if condition="C('MYDB.id_rz_state') =='1'">
							<img src="{{get_img_url($img['company_business'])}}" >
						<else>
						<span style="display: none;"><input type="text" readonly name="company_business" id="company_business"  value="{{$img['company_business']}}" class="layui-input"/></span>
						<span><a href="javascript:" class="layui-btn" onclick="upload_img('company_business')">上传</a></span>
						<div class="up_state_img" id="up_company_business">
							<img src="{{get_img_url($img['company_business'])}}" >
						</div>
						</if>
					</div>
				</div>
			</div>
			<if condition="C('MYDB.id_rz_state') =='1'">
			<div class="layui-form-item">
				<div class="layui-input-block msg green">
					您的资料已审核通过。
				</div>
			</div>
			</if>
			<if condition="C('MYDB.id_rz_state') !='1'">
				<if condition="$renzheng['main']['is_yzm']">
			<div class="layui-form-item">
			    <label class="layui-form-label">验证码</label>
			    <div class="layui-input-block yzm">
					<span><input type="text" name="yzm" placeholder="验证码" value="" class="layui-input"/></span>
					<span class="yzmcode">
						<img src="{{WEBURL}}/verification_code{{c('html')}}"   onclick="this.src='{{WEBURL}}/verification_code{{c('html')}}?'+Math.random();">
					</span>
			    </div>
			</div>
				</if>
			<if condition="C('MYDB.id_rz_state') =='-1'">
			<div class="layui-form-item">
				<div class="layui-input-block msg">
					您的资料已提交，等待审核。
				</div>
			</div>
			</if>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="hidden" name="step" value="post" />
					<button class="layui-btn" lay-submit>确定</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
			</if>
		</form>
	</div>
</div>
<div id="upload_button" style="display: none;">
	<button type="button" id="upload_button_click"></button>
</div>
<script>
	var data={},upload,_type=null;
	var weburl_attachment='{{WEBURL}}/{{C('upfiles_catalog')}}/';
	
	layui.use(['form','upload'], function(){
		var form = layui.form,upload=layui.upload;
		form.on('radio(main_input)', function(data){
			if(data.value==1){
				$('._type1').show();
				$('._type2').hide();
			}else{
				$('._type1').hide();
				$('._type2').show();
			}
		});
		upload.render({
			elem: '#upload_button_click' //绑定元素
			,url: '/user/upfile/up' //上传接口
			,size:'200'
			,done: function(res){
				console.log(_type)
				if(res.code==0){
					$('#'+_type).val(res.url);
					console.log('#'+_type);
					$('#up_'+_type).html("<img src='"+weburl_attachment+res.url+"'>");
				}else{
					layer.msg(res.text);
				}
				return false;
			}
		});
	});
	function upload_img(type){
		_type=type;
		$('#upload_button_click').click();
		return false;
	}
</script>
<?php $this->display(tpl('foot')); ?>