<?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>
				<?php if(C('FRIEND_LINK.is_w')==0){?>
				<tr>
					<td>站标</td>
					<td>
						<input type="text" class="layui-input my-input" style="float: left;" id="thumb" name="thumb" value="<?php echo $data['thumb']?>"  />
						<button style="float: left; margin-left: 10px;" type="button" class="layui-btn layui-btn-normal" id="select_pic">选择图片上传</button>
					</td>
				</tr>
				<?php } ?>
				<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>
				<?php if(C('FRIEND_LINK.is_yzm')){?>
				<tr>
					<td>验证码</td>
					<td>
						<input style="width: 100px; float: left;" type="text" class="layui-input my-input" name="yzm"/>
						<img style="float: left; margin-left: 10px;" src="/verification_code{{C('HTML')}}" alt="点击图片更换验证码" title="点击图片更换验证码" class="yzimg"  onclick="this.src='/verification_code{{c('html')}}?'+Math.random();"/>
					</td>
				</tr>
				<?php } ?>
				<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;
			upload.render({
			    elem: '#select_pic',
			    url: '/user/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));
?>
