<?php 
	$this->display(tpl('head'));
	$state[$edit[state]]="checked";
	$is_login[$edit[is_login]]="checked";
?>

<style>
	p{
		margin-top: 10px;
		color: #aaa;
	}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  	<legend>修改用户信息</legend>
</fieldset>
<form class="layui-form" method="post" action="">
	<table class="layui-table">
		<tr>
			<td>所属用户组</td>
			<td>
				<?php
				foreach(C('USER_GROUP') AS $key=>$row){
					$checked="";
					if($key===$edit[groupid]){
						$checked="checked";
					}
				?>
				<input name="groupid" value="<?php echo $key ?>" title="<?php echo $row[name] ?>" type="radio" <?php echo $checked ?>>
				<?php } ?>
			</td>
		</tr>
		<tr>
			<td>用户名</td>
			<td>
				<input name="username" class="layui-input my-input" placeholder="用户名" type="text" value="<?php echo $edit[username] ?>">
			</td>
		</tr>
		<tr>
			<td>用户密码</td>
			<td>
				<input name="password" class="layui-input my-input" placeholder="密码" type="text" value="<?php echo $edit[password] ?>">
				<p>如果需要更改密码直接在上方输入明文密码即可</p>
			</td>
		</tr>
		<tr>
			<td>头像</td>
			<td>
				<input name="thumb" id="userthumb"  value="<?php echo $edit[thumb] ?>" style="width: 30%;float: left;"  class="layui-input my-input" type="text">
				<button type="button" class="layui-btn" id="uplogo" style="margin-left: 30px;">上传头像</button>
			</td>
		</tr>
		<tr>
			<td>审核状态</td>
			<td>
				<input name="state" lay-skin="primary" title="审核" value="1" type="radio" <?php echo $state[1] ?>>
				<input name="state" lay-skin="primary" title="未审核" value="0" type="radio" <?php echo $state[0] ?>>
			</td>
		</tr>
		<tr>
			<td>邮箱</td>
			<td>
				<input name="email" class="layui-input my-input"  placeholder="邮箱" type="email" value="<?php echo $edit[email] ?>">
			</td>
		</tr>
		<tr>
			<td>手机号码</td>
			<td>
				<input name="mobile" class="layui-input my-input" placeholder="手机号码" type="text" value="<?php echo $edit[mobile] ?>">
			</td>
		</tr>
		<tr>
			<td>积分</td>
			<td>
				<input name="integral" class="layui-input my-input" type="number" value="<?php echo $edit[integral] ?>">
			</td>
		</tr>
		<tr>
			<td>是否禁止登陆</td>
			<td>
				<input name="is_login" title="允许登陆" value="1" type="radio" <?php echo $is_login[1] ?>>
				<input name="is_login" title="禁止登陆" value="0" type="radio" <?php echo $is_login[0] ?>>
			</td>
		</tr>
		<tr>
			<td>限制登陆时间</td>
			<td>
				起始时间：<input id="not_login_star_time" value="<?php echo $edit[not_login_star_time] ? date('Y-m-d H:i:d',$edit[not_login_star_time]) :'' ?>" name="not_login_star_time" style="width: 155px !important;" class="layui-input my-input" type="text" >
				结束时间：<input id="not_login_end_time" value="<?php echo $edit[not_login_end_time] ? date('Y-m-d H:i:d',$edit[not_login_end_time]) :'' ?>" name="not_login_end_time" style="width: 155px !important;" class="layui-input my-input" type="text" >
				<p>如果限制了登陆，就不会判断限制登陆时间。</p>
				<p>如果只填写了起始时间没有填写结束时间，则无限期禁止登陆。</p>
				<p>如果只填写结束时间，没填写起始时间。则直到结束时间才可正常登陆</p>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="my_button">
				<input type="hidden" name="step" value="edit" />
				<input type="hidden" name="uid"	 value="<?php echo $edit[uid] ?>" />
				<button class="layui-btn" lay-submit="" lay-filter="post">立即提交</button>
			</td>
		</tr>
</table>
</form>
<script>
		layui.use(['form','upload','laydate'], function(){
				var form=layer.form,laydate=layui.laydate;
				var $ = layui.jquery,upload = layui.upload;
  				laydate.render({
					elem: '#not_login_star_time',
					type: 'datetime'
				});
				laydate.render({
					elem: '#not_login_end_time',
					type: 'datetime'
				});
				//普通图片上传
				upload.render({
				    elem: '#uplogo'
				    ,url: '/admin/upfile/up'
				    ,done: function(res){
				      //如果上传失败
				      	if(res.code > 0){
				        	return layer.msg('上传失败');
				    	}else{
				    		if(res.Result==='1'){
				    			$('#userthumb').val(res.url);
				    		}else{
				    			return layer.msg(res.content);
				    		}
				      		
				     	}
				      //上传成功
				    }
				    ,error: function(){
				      //演示失败状态，并实现重传
				      var demoText = $('#demoText');
				      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
				      demoText.find('.demo-reload').on('click', function(){
				        uploadInst.upload();
				      });
				    }
				});
		})
</script>

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