<!--{include file="<!--{$oetplpath}-->block_head.tpl"}-->

<!--{if $a == "run"}-->
<div class="layui-fluid oe_fluid">
  <form class="layui-form" id="mysearch" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post">
  <div class="oe_breadcrumb_box clearfix">
    <div class="layui-breadcrumb fl" lay-filter="breadcrumb" style="visibility: visible;">
      <a href="javascript:;">站点管理</a><span lay-separator="">/</span>
      <a href="javascript:;">广告管理</a><span lay-separator="">/</span>
      <a><cite>广告图</cite></a>
    </div>
  </div>
  <!--//Top End -->
  
  <div class="oe_searchbar layui-form">
    <div class="more_search_open"></div>
    <div class="layui-form-item">
      当前风格：<!--{$config.templet}-->&nbsp;&nbsp;&nbsp;
      <div class="layui-inline">
        <div class="layui-form-label">所属版位：</div>
        <div class="layui-input-inline input-150">
          <!--{hook mod='zone' type='select' name='szoneid' text='=请选择=' value=$szoneid}-->
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">广告标识：</div>
        <div class="layui-input-inline input-150">
          <input type="text" name="smark" id="smark" value="<!--{$smark}-->" class="layui-input" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">广告图名：</div>
        <div class="layui-input-inline input-150">
          <input type="text" name="sname" id="sname" value="<!--{$sname}-->" class="layui-input" />
        </div>
      </div>
      
      <div class="layui-inline">
        <button class="layui-btn layui-btn-sm search" id="but_submit_search2" lay-submit lay-filter="searchform2">
          <i class="layui-icon layui-icon-search"></i>
          搜索
          <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
        </button>
      </div>
      
    </div>
  </div>
  <!--//search End -->
  </form>

  <div class="oe_table_wrap layui-form">
  
    <div class="oe_tbl_tool clearfix">
      <div class="oe_gnbar clearfix">
        <div class="select btn fl">
          <input type="checkbox" name="allid[]" lay-skin="primary" title="全选" lay-filter="selectAll">
        </div>
        <div class="btn del fl" f="handle-array" data-form="myform">
          <i class="layui-icon layui-icon-delete"></i>
          <span>删除</span>
        </div>
        <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=add" class="btn add fl">
          <i class="layui-icon layui-icon-add-1"></i>
          <span>添加</span>
        </a>
      </div>
      <div class="oe_tongji_bar clearfix current">
        <span><b><!--{$total}--></b> 条记录</span>
      </div>
    </div>
    
    <form class="layui-form" id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post">
    <input type="hidden" name="a" id="a" value="del" />
    <table class="layui-table">
      <thead>
        <tr>
          <th width="4%"></th>
          <th width="10%">ID</th>
          <th width="15%">标识</th>
          <th width="15%">名称</th>
          <th width="8%">图片</th>
          <th width="15%">所属版位</th>
          <th width="16%">添加时间</th>
          <th width="8%">排序</th>
          <th>操作</th>
        </tr> 
      </thead>
      
      <!--{if empty($myads)}-->
      <tr>
        <td colspan="9" class="text_center">没有符合条件的信息</td>
      </tr>
      <!--{else}-->
      <!--{foreach $myads as $volist}-->
      <tr>
        <td class="check text_center">
          <input type="checkbox" name="id[]" lay-skin="primary" value="<!--{$volist.adid}-->" />
        </td>
        <td class="text_center">
          <!--{$volist.adid}-->
        </td>
        <td class="text_center"><!--{$volist.admark}--></td>
        <td class="text_center"><!--{$volist.adname}--></td>
        <td class="text_center">
          <img src="<!--{$urlpath}--><!--{$volist.drawimg}-->" width="20px" height="20px" f="viewimg" />
        </td>
        <td class="text_center">
          <!--{if !empty($volist.zonename)}-->
          <!--{$volist.zonename}-->
          <!--{else}-->
          --
          <!--{/if}-->
        </td>
        <td class="text_center"><!--{$volist.addtime|date_format:"%Y-%m-%d %H:%M:%S"}--></td>
        <td class="text_center"><!--{$volist.orders}--></td>
        <td class="text_center">
          <div class="btn_box">
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$volist.adid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs layui-btn-normal">编辑</a>
            <a href="javascript:;" f="handle-one" data-url="<!--{$oefile}-->&c=<!--{$c}-->&a=del&id[]=<!--{$volist.adid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
          </div>
        </td>
      </tr>
      <!--{/foreach}-->
      <!--{/if}-->
    </table>
    </form>
    <div class="oe_page_box"><!--{$showpage}--></div>

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

<!--{if $a == "add"}-->
<div class="layui-fluid oe_fluid">

  <div class="oe_breadcrumb_box clearfix">
    <div class="layui-breadcrumb fl" lay-filter="breadcrumb" style="visibility: visible;">
      <a href="javascript:;">站点管理</a><span lay-separator="">/</span>
      <a href="javascript:;">广告管理</a><span lay-separator="">/</span>
      <a><cite>广告图</cite></a>
    </div>
    <div class="oe_tool_bar ft">
      <button class="layui-btn layui-btn-sm layui-btn-radius" id="but_submit_post2" lay-submit lay-filter="addform">
        添加保存
        <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
      </button>
      <span class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius"><a href="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->">返回列表</a></span>
    </div> 
  </div>
  
  <form class="layui-form" id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->" method="post">
  <input type="hidden" name="a" id="a" value="saveadd" />
  <div class="layui-card">
    <div class="layui-card-header">添加广告图</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th><font color="red"></font>所属版位：</th>
          <td>
            <div class="input-300">
            <!--{hook mod='zone' type='select' name='zoneid' text='=请选择='}-->
            </div>
          </td>
        </tr>
        <tr>
          <th width="15%"><font color="red">*</font>广告标识：</th>
          <td width="85%">
            <input type="text" name="admark" id="admark" class="layui-input input-300" /> 
            <span id="tips_box"></span>
            <br >
            <span class="text_tip_inline">（由字母、数字、下横线组成）</span>
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>广告图名称：</th>
          <td>
            <input type="text" name="adname" id="adname" class="layui-input input-300" />
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>广告图片：</th>
          <td>
            <div class="layui-btn">
              <i class="layui-icon layui-icon-upload"></i>
              点击上传
              <input type="file" name="img" id="img" f="but_upload_image" data-forbidcom="1" data-forbidwater="1" />
            </div>
            <div class="upload_loading" id="img_loading" style="display:none;"></div>
            <input type="hidden" id="img_thumb" name="img_thumb" value="" />
            <input type="hidden" id="img_url" name="drawimg" value="" />
        
            <div class="tblform_tips normal">&nbsp;&nbsp;&nbsp;预览：</div>
            <div class="upload_pic upload_pic_md" style="width:30px;height:30px;">
              <img src="<!--{$urlpath}-->tpl/static/images/nopic.jpg" id="img_preview" f="viewimg" />
            </div>
            <a href="javascript:;" class="oe_deluploadimg" f="removeimg" data-preview="img" data-input="img">移除</a>
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>链接URL：</th>
          <td>
            <input type="text" name="url" id="url" class="layui-input input-300" /> 
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>排序：</th>
          <td>
            <input type="text" name="orders" id="orders" class="layui-input input-100" value="<!--{$orders}-->" /> 
          </td>
        </tr>
        <tr>
          <th>备注说明：</th>
          <td>
            <textarea name="remark" id="remark" class="layui-textarea" style="width:50%;height:60px;"></textarea>
          </td>
        </tr>
      </table>
    </div>
  </div>
  </form>
  
  <div class="oe_tbl_form_btn">
    <button class="layui-btn" id="but_submit_post" lay-submit lay-filter="addform">
      添加保存
      <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
    </button>
  </div>
  
</div>

<script type="text/javascript">
$(function(){
    
    //检测标识
    $(document).on("blur", "#admark", 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') {
                        $("#tips_box").html("<font color='green'>该标识可用</font>");
                    }
                    else {
                        if ($result.length == 0) {
                            $result = "该标识已存在";
                        }
                        $("#tips_box").html("<font color='red'>"+$result+"</font>");
                    }
                },
                error: function() {
                    layer.msg("系统繁忙，请稍后再试！");
                }
            });
        }
    });
  
  
    layui.use('form', function(){
        $form = layui.form;
        //保存...
        $form.on('submit(addform)', function(data){
            $obj_id = data.elem.getAttribute("id");
            if (!$("#"+$obj_id).hasClass("forbid_submit")) {
            
                if ($("#admark").val().length  == 0) {
                    layer.msg("请填写标识");
                    return false;
                }
                if ($("#adname").val().length  == 0) {
                    layer.msg("请填写图片名称");
                    return false;
                }
                if ($("#img_url").val().length  == 0) {
                    layer.msg("请上传广告图");
                    return false;
                }
                
                $("#"+$obj_id).addClass("forbid_submit");
                if ($("#"+$obj_id).find("span").length > 0) {
                    $("#"+$obj_id).find("span").show();
                }
                $("#myform").submit();
            }
        });   
    });
    
});
</script>
<!--{/if}-->

<!--{if $a == "edit"}-->
<div class="layui-fluid oe_fluid">

  <div class="oe_breadcrumb_box clearfix">
    <div class="layui-breadcrumb fl" lay-filter="breadcrumb" style="visibility: visible;">
      <a href="javascript:;">站点管理</a><span lay-separator="">/</span>
      <a href="javascript:;">广告管理</a><span lay-separator="">/</span>
      <a><cite>广告图</cite></a>
    </div>
    <div class="oe_tool_bar ft">
      <button class="layui-btn layui-btn-sm layui-btn-radius" id="but_submit_post2" lay-submit lay-filter="editform">
        编辑保存
        <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
      </button>
      <span class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius"><a href="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->">返回列表</a></span>
    </div> 
  </div>
  
  <form class="layui-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}-->" />
  <div class="layui-card">
    <div class="layui-card-header">编辑广告图</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th><font color="red"></font>所属版位：</th>
          <td>
            <div class="input-300">
            <!--{hook mod='zone' type='select' name='zoneid' text='=请选择=' value=$myads.zoneid}-->
            </div>
          </td>
        </tr>
        <tr>
          <th width="15%"><font color="red">*</font>广告标识：</th>
          <td width="85%">
            <input type="text" name="admark" id="admark" class="layui-input input-300" value="<!--{$myads.admark}-->" /> 
            <span id="tips_box"></span>
            <br >
            <span class="text_tip_inline">（由字母、数字、下横线组成）</span>
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>广告图名称：</th>
          <td>
            <input type="text" name="adname" id="adname" class="layui-input input-300" value="<!--{$myads.adname}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>广告图片：</th>
          <td>
            <div class="layui-btn">
              <i class="layui-icon layui-icon-upload"></i>
              点击上传
              <input type="file" name="img" id="img" f="but_upload_image" data-forbidcom="1" data-forbidwater="1" />
            </div>
            <div class="upload_loading" id="img_loading" style="display:none;"></div>
            <input type="hidden" id="img_thumb" name="img_thumb" value="" />
            <input type="hidden" id="img_url" name="drawimg" value="<!--{$myads.drawimg}-->" />
        
            <div class="tblform_tips normal">&nbsp;&nbsp;&nbsp;预览：</div>
            <div class="upload_pic upload_pic_md" style="width:30px;height:30px;">
              <img src="<!--{$urlpath}--><!--{if !empty($myads.drawimg)}--><!--{$myads.drawimg}--><!--{else}-->tpl/static/images/nopic.jpg<!--{/if}-->" id="img_preview" f="viewimg" />
            </div>
            <a href="javascript:;" class="oe_deluploadimg" f="removeimg" data-preview="img" data-input="img">移除</a>
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>链接URL：</th>
          <td>
            <input type="text" name="url" id="url" class="layui-input input-300" value="<!--{$myads.url}-->" /> 
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>排序：</th>
          <td>
            <input type="text" name="orders" id="orders" class="layui-input input-100" value="<!--{$myads.orders}-->" /> 
          </td>
        </tr>
        <tr>
          <th>备注说明：</th>
          <td>
            <textarea name="remark" id="remark" class="layui-textarea" style="width:50%;height:60px;"><!--{$myads.remark}--></textarea>
          </td>
        </tr>
      </table>
    </div>
  </div>
  </form>
  
  <div class="oe_tbl_form_btn">
    <button class="layui-btn" id="but_submit_post" lay-submit lay-filter="editform">
      编辑保存
      <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
    </button>
  </div>
  
</div>
<script type="text/javascript">
$(function(){

    //检测标识
    $(document).on("blur", "#admark", function(){
        if ($(this).val().length > 0) {
            $.ajax({
                type: "POST",
                url: "<!--{$oefile}-->&c=<!--{$c}-->",
                cache: false,
                data: {a:"check", adid:"<!--{$id}-->", name:$(this).val(), r:get_rndnum(8)},
                dataType: "json",
                success: function(data) {
                    $json = eval(data);
                    $response = $json.response;
                    $result = $json.result;
                    if ($response == '1') {
                        $("#tips_box").html("<font color='green'>该标识可用</font>");
                    }
                    else {
                        if ($result.length == 0) {
                            $result = "该标识已存在";
                        }
                        $("#tips_box").html("<font color='red'>"+$result+"</font>");
                    }
                },
                error: function() {
                    layer.msg("系统繁忙，请稍后再试！");
                }
            });
        }
    });

    layui.use('form', function(){
        $form = layui.form;
        //保存...
        $form.on('submit(editform)', function(data){
            $obj_id = data.elem.getAttribute("id");
            if (!$("#"+$obj_id).hasClass("forbid_submit")) {
            
                if ($("#admark").val().length  == 0) {
                    layer.msg("请填写标识");
                    return false;
                }
                if ($("#adname").val().length  == 0) {
                    layer.msg("请填写图片名称");
                    return false;
                }
                if ($("#img_url").val().length  == 0) {
                    layer.msg("请上传广告图");
                    return false;
                }
                
                $("#"+$obj_id).addClass("forbid_submit");
                if ($("#"+$obj_id).find("span").length > 0) {
                    $("#"+$obj_id).find("span").show();
                }
                //...
                $("#myform").submit();
            }
        });   
    });
    
});
</script>
<!--{/if}-->
</body>
</html>