<?php 
	$this->display(tpl('head',true));
	$is_w[$data['is_w']]='checked';
	$state[$data['state']]='checked';
?>
<style>
	.layui-input-block button{
		margin-top: 10px;
	}
</style>
	<form class="layui-form" method="post">
		<div class="w-100 left bcf ">
			<div class="layui-form-item mt10">
				<label class="layui-form-label">链接名称</label>
				<div class="layui-input-block">
					<input type="text" class="layui-input my-input" name="title" value="<?php echo $data['title']?>"  />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">链接</label>
				<div class="layui-input-block">
					<input type="text" class="layui-input my-input" name="link" value="<?php echo $data['link']?>"  />
				</div>
			</div>
			<?php if(C('FRIEND_LINK.is_w')==0){?>
			<div class="layui-form-item">
				<label class="layui-form-label">站标</label>
				<div class="layui-input-block">
					<input type="text" class="layui-input my-input" style="float: left;" id="thumb" name="thumb" value="<?php echo $data['thumb']?>"  />
					<button style="float: left;" type="button" class="layui-btn layui-btn-normal" id="select_pic">选择图片上传</button>
				</div>
			</div>
			<?php } ?>
			<div class="layui-form-item">
				<label class="layui-form-label">所属分类</label>
				<div class="layui-input-block">
					<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>
				</div>
			</div>
			<?php if(C('FRIEND_LINK.is_yzm')){?>
			<div class="layui-form-item">
				<label class="layui-form-label">验证码</label>
				<div class="layui-input-block">
					<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();"/>
				</div>
			</div>
			<?php } ?>
		</div>
		<div class="w-100 left bcf mt10">
			<div class="layui-form-item mt10 center">
				<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>
			</div>
		</div>
	</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));
?>
