<?php 
	$this->display(tpl('head',true));
?>
<style>
	.layui-table thead tr th{
		text-align: center;
	}
	.w-100{
		width: 100%;
	}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  	<legend>广告编辑</legend>
</fieldset>
<form class="layui-form" method="post">
	<table class="layui-table" cellspacing="0" cellpadding="0" border="0" >
		<tbody>
			<tr>
				<td align="center" width="100">广告名称</td>
				<td>{{$data['info']['name']}}</td>
			</tr>
			<tr>
				<td align="center" width="100">广告说明</td>
				<td>{{$data['info']['msg']}}</td>
			</tr>
			<tr>
				<td align="center" width="100">广告类型</td>
				<td><?php if($data['ad_type']=="images"){
			$ad_type="图片类型";
		}elseif($row['ad_type']=="text"){
			$ad_type="文字类型";
		}else{
			$ad_type="代码类型";
		}
		 echo $ad_type;
		?></td>
			</tr>
			<tr>
				<td align="center" width="100">广告设置</td>
				<td>
					<if condition="$data['ad_type']=='images'">
					<table class="layui-table" cellspacing="0" cellpadding="0" border="0" >
						<tbody>
							<tr>
								<td align="center" width="100">上传广告图片</td>
								<td>
									<div style="width: 30%;float: left;">
										<input class="layui-input" type="text" name="ad[imgurl]" id="imgurl" value="{{$data['content']['imgurl']}}" />
									</div>
									<div style="float: left; margin-left: 10px;">
										<button type="button" class="layui-btn" id="select_pic">上传</button>
									</div>
								</td>
							</tr>
							<tr>
								<td align="center" width="100">广告链接</td>
								<td>
									<div style="width: 30%;float: left;">
										<input class="layui-input" type="text" name="ad[weburl]" id="" value="{{$data['content']['weburl']}}" />
									</div>
								</td>
							</tr>
						</tbody>
					</table>
					<elseif condition="$data['ad_type']=='text'">
						<table class="layui-table" cellspacing="0" cellpadding="0" border="0" >
							<tbody>
								<tr>
									<td align="center" width="100">文字信息</td>
									<td>
										<div style="width: 30%;float: left;">
											<input name="ad[title]" type="text" class="layui-input" value="{{$data['content']['title']}}" />
										</div>
									</td>
								</tr>
								<tr>
									<td align="center" width="100">广告链接</td>
									<td>
										<div style="width: 30%;float: left;">
											<input class="layui-input" type="text" name="ad[weburl]" id="" value="{{$data['content']['weburl']}}" />
										</div>
									</td>
								</tr>
							</tbody>
						</table>
					
					</if>
				</td>
			</tr>
			
			<tr>
				<td colspan="2">
					<input type="hidden" name="step" id="" value="post" />
					<button type="submit" class="layui-btn" lay-submit lay-filter="post">确定</button>
				</td>
			</tr>
		</tbody>
	</table>
</form>

<script>
	
	layui.use(['table','upload','form'], function() {
		var form=layui.form;
		var upload = layui.upload;
		//选完文件后不自动上传
		upload.render({
			 elem: '#select_pic',
		    url: '{{WEBURL}}/user/upfile/up/json_true/',
		    auto: true,
		    before: function(obj){
		    	files = obj.pushFile(); //将每次选择的文件追加到文件队列
		    	loading = layer.load();
		    },
		    done: function(res, index, upload){
		    	layer.close(loading);
			    if(res.code !=0){
			    	layer.msg(res.text);
			    }else{
			      	$('#imgurl').val(res.url); 
			    }
			    delete files[index]; //删除对应的文件
		    },
		});
	});
</script>
<?php 
	$this->display(tpl('foot',true));
?>
