<?php 
	$this->display(tpl('head'));
	$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: 100px;
	}
	.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;
	}
	.ok{
		text-align: center;
		padding: 20px;
		font-size: 16px;
	}
	.ok span{
		padding:0 5px;
		color: red;
		font-weight: bolder;
	}
</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">
		<if condition="C('mydb.mobile_rz_state') =='1'">
			<div class="ok">您的手机“<span>{{C('MYDB.mobile')}}</span>”已通过验证</div>
		<else>
		<form class="layui-form">
			<div class="layui-form-item">
			    <label class="layui-form-label">请输入手机号</label>
			    <div class="layui-input-block">
					<input type="number" id="mobile" name="mobile"  value="{{C('MYDB.mobile')}}" class="layui-input" placeholder="请输入你的手机号码进行验证"/>
			    </div>
			</div>
			<if condition="$renzheng['mob']['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"  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>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit lay-filter="*">确定</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
		</if>
	</div>
</div>
<script>
	var data={};
	layui.use('form', function(){
		var form = layui.form;
		form.on('submit(*)', function(res){
			if(!res.field.mob){
				layer.tips('手机号码不可为空或者号码错误', '#mob');
				$('#mob').focus();
			}
			data=res.field;
			data.type='mob';
			data.json=true;
			$.ajax({
				url:"/user/renzheng/send/",
				type: 'POST',
				data:data,
				dataType: 'json',
				success: function(res){
					if(res.code==0){
						layer.prompt({
							value: '',
							title: '手机认证码',
						}, function(value, index, elem){
							data.code=value;
							$.ajax({
								url:"/user/renzheng/approve/",
								type: 'POST',
								data:data,
								dataType: 'json',
								success: function(res){
									layer.msg(res.text);
									if(res.code==0){
										location.reload() ;
									}
								}
							})
						});
						layer.msg('手机验证码已发送，请注意查收');
					}else{
						layer.msg(res.text);
					}
				}
			})
			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		});

	});
</script>
<?php $this->display(tpl('foot')); ?>