<!--{include file="<!--{$oetplpath}-->block_head.tpl"}-->
<!--{if $a == "run"}-->
<div class="oemarry_layout">
  <div class="oe_top_nav"><i></i>广告管理->广告图管理</div>
  <div class="oe_content">
	
	<form id="serform" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post">
	<div class="oe_txtwrap">
	  当前风格：<!--{$config.templet}-->&nbsp;&nbsp;
	  所属城市：<!--{hook mod='city' type='select' name='scityid' text='=请选择=' value=$scityid}-->&nbsp;
	  所属版位：<!--{hook mod='zone' type='select' name='szoneid' text='=请选择=' value=$szoneid}-->&nbsp;
	  广告标识：<input type="text" name="smark" id="smark" class="input-150" value="<!--{$smark}-->" />&nbsp;
	  广告图名：<input type="text" name="sname" id="sname" class="input-150" value="<!--{$sname}-->" />&nbsp;
	  &nbsp;&nbsp;&nbsp;<input type="submit" name="btn_search" id="btn_search" class="button_2" value="搜索" />
	</div>
	</form>

    <div class="oe_tools_bar clearfix">
      <a class="icon-checkbox-unchecked" href="javascript:;" id="selAll" onclick="oemarrySelectAll(this, 'selall');">选择</a>
      <a class="icon-remove-2" onclick="oemarryDialogFormDel('myform');">删除</a>
      <span class="fr"><a class="icon-plus" href="<!--{$oefile}-->&c=<!--{$c}-->&a=add">添加</a></span>
    </div>
    
	<form id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->&a=del" method="post">
    <table class="oe_table_list table_cs">
	  <tr>
	    <th width="8%">ID</th>
		<th width="13%">标识</th>
		<th width="13%">名称</th>
		<th width="8%">图片</th>
		<th width="8%">城市</th>
		<th width="8%">频道</th>
		<th width="13%">所属版位</th>
		<th width="13%">添加时间</th>
		<th width="6%">排序</th>
		<th>操作</th>
	  </tr>
	  <!--{if empty($myads)}-->
	  <tr>
	    <td class="text_center" colspan="10">没有符合条件的信息！</td>
	  </tr>
	  <!--{else}-->
	  <!--{foreach $myads as $volist}-->
	  <tr>
	    <td class="text_center"><input type="checkbox" name="id[]" id="id[]" class="selall" value="<!--{$volist.adid}-->" /><!--{$volist.adid}--></td>
		<td><!--{$volist.admark}--></td>
		<td><!--{$volist.adname}--></td>
		<td class="text_center">
		  <img src="<!--{$urlpath}--><!--{$volist.drawimg}-->" width="20px" height="20px" f="viewimg" />
		</td>
		<td class="text_center">
		<!--{if $volist.cityid == '0'}-->
		~~
		<!--{else}-->
		<!--{$volist.cityname}-->
		<!--{/if}-->
		</td>
		<td class="text_center"><!--{$volist.channel}--></td>
		<td class="text_center"><!--{$volist.zonename}--></td>
		<td><!--{$volist.addtime|date_format:"%Y-%m-%d %H:%M:%S"}--></td>
		<td class="text_center"><!--{$volist.orders}--></td>
		<td class="text_center">
		 <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$volist.adid}-->&<!--{$comeurl}-->" class="oe_ico_blue">编辑</a>
		 <a href="javascript:;" onclick="oemarryDialogUrlDel('<!--{$oefile}-->&c=<!--{$c}-->&a=del&id[]=<!--{$volist.adid}-->&<!--{$comeurl}-->');" class="oe_ico_red">删除</a>
		</td>
	  </tr>
	  <!--{/foreach}-->
	  <!--{/if}-->
	</table>
	</form>

	<div class="oe_page_box"><!--{$showpage}--></div>

  </div>
</div>
<!--{/if}-->

<!--{if $a == 'add'}-->
<div class="oemarry_layout">
  <div class="oe_top_nav">
	<i></i>广告管理->广告图管理->添加
	<span><a href="<!--{$oefile}-->&c=<!--{$c}-->">&lt;&lt;返回列表</a></span>
  </div>
  <div class="oe_content">
    <h6>添加广告图</h6>
	<form id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post" />
	<input type="hidden" name="a" id="a" value="saveadd" />
    <table class="oe_table_wrap">
      <tr>
	    <th>所属频道：<span class="f_red"></span></th>
		<td>
		  <select name="channel" id="channel">
			<option value="">=请选择=</option>
			<option value="index">首页(index)</option>
			<option value="shop">商家(shop)</option>
			<option value="goods">商城(goods)</option>
			<option value="activity">活动(activity)</option>
			<option value="coupon">优惠券(coupon)</option>
			<option value="gallery">图库(gallery)</option>
			<option value="article">文章(article)</option>
		  </select>
		</td>
	  </tr>

	  <tr>
	    <th>所属城市：<span class="f_red"></span></th>
		<td><!--{hook mod="city" type="select" name="cityid" text="=不限="}--></td>
	  </tr>
	  <tr>
	    <th width="15%">所属版位：<span class="f_red"></span></th>
		<td width="85%">
		  <!--{hook mod='zone' type='select' name='zoneid' text='=请选择='}-->
		  <span class="oe_trap"></span>
		</td>
	  </tr>
	  <tr>
	    <th>广告标识：<span class="f_red">*</span></th>
		<td>
		  <input type="text" name="admark" id="admark" class="input-b" />
		  <span class="oe_trap">（由字母、数字、下横线组成）</span>
		</td>
	  </tr>
	  <tr>
	    <th>广告图名称：<span class="f_red">*</span></th>
		<td><input type="text" name="adname" id="adname" class="input-b" /></td>
	  </tr>
	  <tr>
	    <th>广告图片：<span class="f_red">*</span></th>
		<td>
		  <table class="oe_table_wrap">
		    <tr>
			  <td width="150px">
				  <div class="oe_img_upload">
					<label class="_uploadbtn">点击上传<input type="file" name="img" id="img" value="" /></label>
					<label class="_uploading" id="img_loading">
					  <img src="<!--{$urlpath}-->tpl/admin/images/loading.gif" />上传中...
					</label>
					<input type="hidden" id="img_thumb" name="img_thumb" value="" />
					<input type="hidden" id="img_url" name="drawimg" value="" />
				  </div>
				  <script type="text/javascript">
				  $(function(){
					  $("#img").live("change", function(){
						oemarryUploadImg("img", "<!--{$oefile}-->&c=index&a=uploadimg&module=upload&forbidcom=1&forbidwater=1");
					  });
				  });
				  </script>
			  </td>
			  <td width="50px">预览：</td>
			  <td width="80px">
			    <img src="<!--{$urlpath}-->tpl/static/images/waitimg.jpg" width="30px" height="30px" id="img_preview" f="viewimg" />
				<a href="javascript:;" class="_removeimg" f="removeimg" data-preview="img_preview" data-draw="img_url">移除</a>
			  </td>
			  <td></td>
			</tr>
		  </table>
		</td>
	  </tr>
	  <tr>
	    <th>链接URL：<span class="f_red"></span></th>
		<td><input type="text" name="url" id="url" class="input-b" /></td>
	  </tr>
	  <tr>
	    <th>排序：<span class="f_red"></span></th>
		<td><input type="text" name="orders" id="orders" class="input-100" value="<!--{$orders}-->" /></td>
	  </tr>
	  <tr>
	    <th>备注说明：</th>
		<td colspan="3"><textarea name="remark" id="remark" style="width:50%;height:60px;"></textarea></td>
	  </tr>
	  <tr>
	    <td></td>
		<td><input type="button" id="btn_save" class="button_2" value="添加保存" /></td>
	  </tr>
	</table>
	</form>
  </div>
</div>
<script type="text/javascript">
$(function(){

	$("#admark").bind("blur", function(){ //检测标识
		if ($(this).val().length > 0) {
			$.ajax({
				type: "POST",
				url: "<!--{$oefile}-->&c=<!--{$c}-->",
				cache: false,
				data: {a:"check", name:$(this).val(), r:get_rndnum(8)},
				dataType: "json",
				success: function(data) {
					$json = eval(data);
					$response = $json.response;
					$result = $json.result;
					if ($response == '1') {
						oemarryCheckOk("admark", "该标识可用");
					}
					else {
						if ($result.length == 0) {
							$result = "该标识已存在";
						}
						oemarryCheckError("admark", $result);
					}
				},
				error: function() {
					ToastShow("检测失败，请检查网络...");
				}
			});
		}
	});

	$("#btn_save").bind("click", function(){
		if ($("#admark").val().length == 0) {
			ToastShow("请填写标识", "admark");
			return false;
		}
		if ($("#adname").val().length == 0) {
			ToastShow("请填写图片名称", "adname");
			return false;
		}
		if ($("#img_url").val().length == 0) {
			ToastShow("请上传广告图");
			return false;
		}
		$("#myform").submit();
	});

});
</script>

<!--{/if}-->


<!--{if $a == 'edit'}-->
<div class="oemarry_layout">
  <div class="oe_top_nav">
	<i></i>广告管理->广告图管理->编辑
	<span><a href="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->">&lt;&lt;返回列表</a></span>
  </div>
  <div class="oe_content">
    <h6>编辑广告图</h6>
	<form id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->" method="post" />
	<input type="hidden" name="a" id="a" value="saveedit" />
	<input type="hidden" name="id" id="id" value="<!--{$id}-->" />
    <table class="oe_table_wrap">
	  <tr>
	    <th>所属频道：<span class="f_red"></span></th>
		<td>
		  <select name="channel" id="channel">
			<option value="">=请选择=</option>
			<option value="index"<!--{if $myads.channel == "index"}--> selected<!--{/if}-->>首页(index)</option>
			<option value="shop"<!--{if $myads.channel == "shop"}--> selected<!--{/if}-->>商家(shop)</option>
			<option value="goods"<!--{if $myads.channel == "goods"}--> selected<!--{/if}-->>商城(goods)</option>
			<option value="activity"<!--{if $myads.channel == "activity"}--> selected<!--{/if}-->>活动(activity)</option>
			<option value="coupon"<!--{if $myads.channel == "coupon"}--> selected<!--{/if}-->>优惠券(coupon)</option>
			<option value="gallery"<!--{if $myads.channel == "gallery"}--> selected<!--{/if}-->>图库(gallery)</option>
			<option value="article"<!--{if $myads.channel == "article"}--> selected<!--{/if}-->>文章(article)</option>
		  </select>
		</td>
	  </tr>
	  <tr>
	    <th>所属城市：<span class="f_red"></span></th>
		<td><!--{hook mod="city" type="select" name="cityid" text="=不限=" value=$myads.cityid}--></td>
	  </tr>
	  <tr>
	    <th width="15%">所属版位：<span class="f_red"></span></th>
		<td width="85%">
		  <!--{hook mod='zone' type='select' name='zoneid' text='=请选择=' value=$myads.zoneid}-->
		  <span class="oe_trap"></span>
		</td>
	  </tr>
	  <tr>
	    <th>广告标识：<span class="f_red">*</span></th>
		<td>
		  <input type="text" name="admark" id="admark" class="input-b" value="<!--{$myads.admark}-->" />
		  <span class="oe_trap">（由字母、数字、下横线组成）</span>
		</td>
	  </tr>
	  <tr>
	    <th>广告图名称：<span class="f_red">*</span></th>
		<td><input type="text" name="adname" id="adname" class="input-b" value="<!--{$myads.adname}-->" /></td>
	  </tr>
	  <tr>
	    <th>广告图片：<span class="f_red">*</span></th>
		<td>
		  <table class="oe_table_wrap">
		    <tr>
			  <td width="150px">
				  <div class="oe_img_upload">
					<label class="_uploadbtn">点击上传<input type="file" name="img" id="img" value="" /></label>
					<label class="_uploading" id="img_loading">
					  <img src="<!--{$urlpath}-->tpl/admin/images/loading.gif" />上传中...
					</label>
					<input type="hidden" id="img_thumb" name="img_thumb" value="" />
					<input type="hidden" id="img_url" name="drawimg" value="<!--{$myads.drawimg}-->" />
				  </div>
				  <script type="text/javascript">
				  $(function(){
					  $("#img").live("change", function(){
						oemarryUploadImg("img", "<!--{$oefile}-->&c=index&a=uploadimg&module=upload&forbidcom=1&forbidwater=1");
					  });
				  });
				  </script>
			  </td>
			  <td width="50px">预览：</td>
			  <td width="80px">
				<!--{if !empty($myads.drawimg)}-->
				<img src="<!--{$urlpath}--><!--{$myads.drawimg}-->" width="30px" height="30px" id="img_preview" f="viewimg" />
				<!--{else}-->
			    <img src="<!--{$urlpath}-->tpl/static/images/waitimg.jpg" width="30px" height="30px" id="img_preview" f="viewimg" />
				<!--{/if}-->
				<a href="javascript:;" class="_removeimg" f="removeimg" data-preview="img_preview" data-draw="img_url">移除</a>
			  </td>
			  <td></td>
			</tr>
		  </table>
		</td>
	  </tr>
	  <tr>
	    <th>链接URL：<span class="f_red"></span></th>
		<td><input type="text" name="url" id="url" class="input-b" value="<!--{$myads.url}-->" /></td>
	  </tr>
	  <tr>
	    <th>排序：<span class="f_red"></span></th>
		<td><input type="text" name="orders" id="orders" class="input-100" value="<!--{$myads.orders}-->" /></td>
	  </tr>
	  <tr>
	    <th>备注说明：</th>
		<td colspan="3"><textarea name="remark" id="remark" style="width:50%;height:60px;"><!--{$myads.remark}--></textarea></td>
	  </tr>
	  <tr>
	    <td></td>
		<td><input type="button" id="btn_save" class="button_2" value="编辑保存" /></td>
	  </tr>
	</table>
	</form>
  </div>
</div>
<script type="text/javascript">
$(function(){

	$("#admark").bind("blur", function(){ //检测标识
		if ($(this).val().length > 0) {
			$.ajax({
				type: "POST",
				url: "<!--{$oefile}-->&c=<!--{$c}-->",
				cache: false,
				data: {a:"check", name:$(this).val(), adid:"<!--{$id}-->", r:get_rndnum(8)},
				dataType: "json",
				success: function(data) {
					$json = eval(data);
					$response = $json.response;
					$result = $json.result;
					if ($response == '1') {
						oemarryCheckOk("admark", "该标识可用");
					}
					else {
						if ($result.length == 0) {
							$result = "该标识已存在";
						}
						oemarryCheckError("admark", $result);
					}
				},
				error: function() {
					ToastShow("检测失败，请检查网络...");
				}
			});
		}
	});

	$("#btn_save").bind("click", function(){
		if ($("#admark").val().length == 0) {
			ToastShow("请填写标识", "admark");
			return false;
		}
		if ($("#adname").val().length == 0) {
			ToastShow("请填写图片名称", "adname");
			return false;
		}
		if ($("#img_url").val().length == 0) {
			ToastShow("请上传广告图");
			return false;
		}
		$("#myform").submit();
	});

});
</script>
<!--{/if}-->
</body>
</html>