<!--{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">
    
      <div class="layui-inline">
        <div class="layui-form-label">分类：</div>
        <div class="layui-input-inline input-150">
          <!--{hook mod='var' item='giftcat' type='select' name='scatid' text='=请选择=' value=$scatid}-->
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">礼物名称：</div>
        <div class="layui-input-inline input-150">
          <input type="text" name="sgiftname" id="sgiftname" class="layui-input" value="<!--{$sgiftname}-->" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">状态：</div>
        <div class="layui-input-inline input-100">
          <select name="sflag" id="sflag">
            <option value="">=不限=</option>
          <option value="1"<!--{if $sflag == '1'}--> selected<!--{/if}-->>通过</option>
          <option value="2"<!--{if $sflag == '2'}--> selected<!--{/if}-->>锁定</option>
          </select>
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">推荐：</div>
        <div class="layui-input-inline input-100">
          <select name="selite" id="selite">
            <option value="">=不限=</option>
          <option value="1"<!--{if $selite == '1'}--> selected<!--{/if}-->>是</option>
          <option value="2"<!--{if $selite == '2'}--> selected<!--{/if}-->>否</option>
          </select>
        </div>
      </div>
      
      <div class="layui-inline">
        <div class="layui-form-label">费用：</div>
        <div class="layui-input-inline input-120">
          <select name="sfee" id="sfee">
            <option value="">不限</option>
            <option value="1"<!--{if $sfee == '1'}--> selected<!--{/if}-->>有</option>
            <option value="2"<!--{if $sfee == '2'}--> selected<!--{/if}-->>免费</option>
          </select>
        </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" data-text="确定要删除吗？">
          <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}-->&a=del" method="post">
    <input type="hidden" name="a" id="a" value="del" />
    <table class="layui-table">
      <thead>
        <tr>
          <th width="8%">ID</th>
          <th width="8%">礼物</th>
          <th width="12%">名称</th>
          <th width="8%">分类</th>
          <th width="7%">状态</th>
          <th width="7%">推荐</th>
          <th width="9%">费用(<!--{$config.moneyname}-->)</th>
          <th width="9%">添加时间</th>
          <th>描述</th>
          <th width="10%">操作</th>
        </tr>
      </thead>
      <!--{if empty($gift)}-->
      <tr>
        <td class="text_center" colspan="9">没有符合条件的信息</td>
      </tr>
      <!--{else}-->
      <!--{foreach $gift as $volist}-->
      <tr>
        <td class="text_center check">
          <input type="checkbox" lay-skin="primary" name="id[]" class="selall" value="<!--{$volist.giftid}-->" />
          <!--{$volist.giftid}-->
         </td>
        <td class="text_center">
          <img src="<!--{$volist.imgurl}-->" width="40px" height="40px" f="viewimg" />
        </td>
        <td class="text_center">
          <!--{$volist.giftname}-->
        </td>
        <td class="text_center">
          <!--{if $volist.catid > 0}-->
          <!--{hook mod='var' item='giftcat' type='text' value=$volist.catid}-->
          <!--{else}-->
          --
          <!--{/if}-->
        </td>
        <td class="text_center">
          <input type="checkbox" name="flag" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$volist.giftid}-->" data-type="flag"<!--{if $volist.flag == '1'}--> checked<!--{/if}--> />
        </td>
        <td class="text_center">
          <input type="checkbox" name="elite" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$volist.giftid}-->" data-type="elite"<!--{if $volist.elite == '1'}--> checked<!--{/if}--> />
        </td>
        <td class="text_center"><!--{doubleval($volist.fee)}--></td>
        <td class="text_center">
        <!--{$volist.addtime|date_format:"%Y-%m-%d"}-->
        <br />
        <!--{$volist.addtime|date_format:"%H:%M:%S"}-->
        </td>
        <td><!--{$volist.intro}--></td>
        <td class="text_center">
          <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$volist.giftid}-->&<!--{$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.giftid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs layui-btn-danger" data-text="确定要删除吗？">删除</a>
        </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>
  
  <div class="layui-card oe_table_edit">
    <form id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post" />
    <input type="hidden" name="a" id="a" value="saveadd" />
    <div class="layui-card-header">添加礼物</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th width="15%">分类：<span class="f_red"></span></th>
          <td width="85%">
            <div class="input-150">
            <!--{hook mod='var' item='giftcat' type='select' name='catid' text='=请选择='}-->
            </div>
          </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-mod="gift" data-thumb="0" 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="thumbimg" value="" />
            <input type="hidden" id="img_url" name="imgurl" 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> 名称：</th>
          <td>
            <input type="text" name="giftname" id="giftname" class="layui-input input-300" />
          </td>
        </tr>
        <tr>
          <th><font color="red"></font> 费用：</th>
          <td>
            <input type="text" name="fee" id="fee" class="layui-input input-150" /> <!--{$config.moneyname}-->
          </td>
        </tr>
        <tr>
          <th>状态：</th>
          <td>
            <div class="input-150">
              <select name="flag" id="flag">
                <option value="">=请选择=</option>
                <option value="1" selected>正常</option>
                <option value="0">锁定</option>
              </select>
            </div>
          </td>
        </tr>
        <tr>
          <th>推荐：</th>
          <td>
            <div class="input-150">
              <select name="elite" id="elite">
                <option value="">=请选择=</option>
                <option value="1">是</option>
                <option value="0" selected>否</option>
              </select>
            </div>
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>礼物描述：</th>
          <td>
            <textarea class="layui-textarea" name="intro" id="intro" style="width:50%;height:80px;"></textarea>
          </td>
        </tr>
      </table>
    </div>
    </form>
  </div>
  
  <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(){
    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 ($("#img_url").val().length  == 0) {
                    layer.msg("请上传礼物图片");
                    return false;
                }
                
                if ($("#giftname").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>
  
  <div class="layui-card oe_table_edit">
  
    <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-header">编辑礼物</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th width="15%">分类：<span class="f_red"></span></th>
          <td width="85%">
            <div class="input-150">
            <!--{hook mod='var' item='giftcat' type='select' name='catid' text='=请选择=' value=$gift.catid}-->
            </div>
          </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-mod="gift" data-thumb="0" 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="thumbimg" value="" />
            <input type="hidden" id="img_url" name="imgurl" value="<!--{$gift.imgurl}-->" />
            <div class="tblform_tips normal">&nbsp;&nbsp;&nbsp;预览：</div>
            <div class="upload_pic upload_pic_md" style="width:30px;height:30px;">
              <img src="<!--{if !empty($gift.imgurl)}--><!--{$gift.imgurl}--><!--{else}--><!--{$urlpath}-->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> 名称：</th>
          <td>
            <input type="text" name="giftname" id="giftname" class="layui-input input-300" value="<!--{$gift.giftname}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red"></font> 费用：</th>
          <td>
            <input type="text" name="fee" id="fee" class="layui-input input-150" value="<!--{doubleval($gift.fee)}-->" /> <!--{$config.moneyname}-->
          </td>
        </tr>
        <tr>
          <th>状态：</th>
          <td>
            <div class="input-150">
              <select name="flag" id="flag">
                <option value="">=请选择=</option>
                <option value="1"<!--{if $gift.flag == '1'}--> selected<!--{/if}-->>正常</option>
                <option value="0"<!--{if $gift.flag == '0'}--> selected<!--{/if}-->>锁定</option>
              </select>
            </div>
          </td>
        </tr>
        <tr>
          <th>推荐：</th>
          <td>
            <div class="input-150">
              <select name="elite" id="elite">
                <option value="">=请选择=</option>
                <option value="1"<!--{if $gift.elite == '1'}--> selected<!--{/if}-->>是</option>
                <option value="0"<!--{if $gift.elite == '0'}--> selected<!--{/if}-->>否</option>
              </select>
            </div>
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>礼物描述：</th>
          <td>
            <textarea class="layui-textarea" name="intro" id="intro" style="width:50%;height:80px;"><!--{$gift.intro}--></textarea>
          </td>
        </tr>
      </table>
    </div>
	</form>
  
  
  </div>
  
  <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(){
    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 ($("#img_url").val().length  == 0) {
                    layer.msg("请上传礼物图片");
                    return false;
                }
                
                if ($("#giftname").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>