<?php 
	$this->display(tpl('head',true));
	$is_w[$data['is_w']]='checked';
	$state[$data['state']]='checked';
?>
<style>
	.layui-form-checkbox {
		   margin-top: 10px;
	}
	.layui-form-select{
		width: 30%;
	}	
</style>
	<script src="/public/global/js/colpick.js" type="text/javascript" charset="utf-8"></script>
	<fieldset class="layui-elem-field layui-field-title">
	  	<legend>添加&修改友情链接</legend>
	</fieldset>
	<form class="layui-form" method="post">
		<table class="layui-table  my-tabel">
			<tbody>
				<tr>
					<td>链接名称</td>
					<td>
						<input type="text" class="layui-input my-input" name="title" value="<?php echo $data['title']?>"  />
					</td>
				</tr>
				<tr>
					<td>链接</td>
					<td>
						<input type="text" class="layui-input my-input" name="link" value="<?php echo $data['link']?>"  />
					</td>
				</tr>
				<tr>
					<td>站标</td>
					<td>
						<input type="text" class="layui-input my-input" id="thumb" name="thumb" value="<?php echo $data['thumb']?>"  />
						<button type="button" class="layui-btn layui-btn-normal" id="select_pic">选择图片上传</button>
					</td>
				</tr>
				<tr>
					<td>所属分类</td>
					<td>
						<select name="cid">
							<option value="0">默认分类</option>
							<?php foreach($cdata as $row) {
								if($row['cid'] == $data[cid]){
									$check='selected';
								}
							?>
							<option value="<?php echo $row['cid']?>" <?php echo $check ?>><?php echo $row['name']?></option>
							<?php } ?>
						</select>
					</td>
				</tr>
				<tr>
					<td>排序值</td>
					<td>
						<input type="text" class="layui-input my-input" name="reorder" value="<?php echo $data['reorder']?>"  />
					</td>
				</tr>
				<tr>
					<td>有效期</td>
					<td>
						<input type="text" class="layui-input my-input" id="vld" name="vld" value="<?php echo $data['vld']?>"  />
						如果不填写则为长期有效
					</td>
				</tr>
				<tr>
					<td>是否为文字</td>
					<td>
						<input type="radio"  name="is_w" value="1" title="是" <?php echo $is_w['1']?>/>
						<input type="radio"  name="is_w" value="0" title="否" <?php echo $is_w['0']?>/>
						如果选择“是”不管是否上传站标，都直接以文字显示
					</td>
				</tr>
				<tr>
					<td>状态</td>
					<td>
						<input type="radio"  name="state" value="1" title="已审并显示" <?php echo $state['1']?>/>
						<input type="radio"  name="state" value="0" title="等待审核" <?php echo $state['0']?>/>
						<input type="radio"  name="state" value="-2" title="拒绝" <?php echo $state['-1']?>/>
						<input type="radio"  name="state" value="-1" title="加入黑名单" <?php echo $state['-1']?>/>
					</td>
				</tr>
				<tr>
					<td colspan="2" class="my_button">
						<input type="hidden" name="id" id="id" value="<?php echo $data['id']?>" />
						<input type="hidden" name="step" id="step" value="post" />
						<button class="layui-btn">立即设置</button>
					</td>
				</tr>
			</tbody>
		</table>
	</from>
	<script>
		
		layui.config({
			version: '<?php echo NOWTIME ?>'
		});
		layui.use(['form','upload','laydate'], function(){
		  	var $ = layui.jquery,form = layui.form,upload = layui.upload,laydate= layui.laydate;
		  	var laydate = layui.laydate;
			laydate.render({
				elem: '#vld',
				type: 'datetime'
			});
			upload.render({
			    elem: '#select_pic',
			    url: '/admin/upfile/up/thumb_1/json_true/',
			    auto: true,
			    bindAction: '#star_upload',
			    before: function(obj){
			    	files = obj.pushFile(); //将每次选择的文件追加到文件队列
			    	loading = layer.load();
			    },
			    done: function(res, index, upload){
			    	layer.close(loading);
				    if(res.Result==0){
				    	layer.msg(res.content);
				    }else{
				      	$('#thumb').val(res.url); 
				    }
				    delete files[index]; //删除对应的文件
			    }
			});
		});
	</script>
	
<?php 
	$this->display(tpl('foot',true));
?>
