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

<!--{if $a == "run"}-->
<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>
  <!--//top end -->
  <blockquote class="layui-elem-quote">
    <strong>温馨提示：</strong>
    根据微信菜单规则，一级菜单最多可以添加三个，每个一级菜单最多可以添加5个子菜单。
    
    <a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-normal" f="but_post_wxmenu">&nbsp;&nbsp;更新微信菜单&nbsp;&nbsp;</a>
    <img src="<!--{$urlpath}-->tpl/admin/images/loading.gif" id="tips_image" style="display:none;" />
    <span id="menu_msg"></span>
      
  </blockquote>
  
  <!--//search End -->
  
  <script type="text/javascript">
	$(function(){
      //更新微信菜单
      $(document).on("click", "[f='but_post_wxmenu']", function(){
          $("#menu_msg").html("");
          $("#tips_image").show();
          $.ajax({
              type: "POST",
              url: "<!--{$urlpath}-->weixin.php?c=post&a=menu",
              cache: false,
              data: {r:get_rndnum(8)},
              dataType: "json",
              success: function($data) {
                  $json = eval($data);
                  $response = $json.response;
                  $result = $json.result;
                  if ($response == 1){
                      $("#menu_msg").html("<font color='green'>菜单提交成功</font>");
                  }
                  else {
                      if ($result.length > 0) {
                          $("#menu_msg").html("<font color='red'>"+$result+"</font>");
                      }
                      else {
                          $("#menu_msg").html("<font color='red'>提交失败，请检查公众号设置是否正确</font>");
                      }
                  }
                  $("#tips_image").hide();
              },
              error: function() {
                  $("#menu_msg").html("<font color='red'>系统繁忙，请稍后再试</font>");
              }
          });
      });
	});
	</script>


  <div class="oe_table_wrap layui-form">
    <div class="oe_tbl_tool clearfix">
      <div class="oe_gnbar clearfix">
        <div class="add btn fl" style="border-right:none;">
          <i class="layui-icon layui-icon-add-1"></i>
          <span><a href="<!--{$oefile}-->&c=<!--{$c}-->&a=add">添加一级菜单</a></span>
        </div>
      </div>
    </div>
    
    <table class="layui-table">
      <thead>
        <tr>
          <th width="8%">ID</th>
          <th width="14%">菜单名称</th>
          <th width="9%">菜单类型</th>
          <th>菜单内容</th>
          <th width="7%">排序</th>
          <th width="7%">状态</th>
          <th width="15%">添加时间</th>
          <th width="18%">操作</th>
        </tr> 
      </thead>
      
      <!--{assign var="parent_menu" value=vo_list("mod={weixinmenu} where={v.parentid='0'} orderby={v.orders ASC}")}-->
      <!--{if empty($parent_menu)}-->
      <tr>
        <td colspan="8" class="text_center">没有符合条件的信息</td>
      </tr>
      <!--{else}-->
      <!--{foreach $parent_menu as $volist}-->
      <tr>
        <td class="text_center"><!--{$volist.menuid}--></td>
        <td><b><!--{$volist.name}--></b></td>
        <td class="text_center"><!--{$volist.type}--></td>
        <td><!--{$volist.menuval}--></td>
        <td class="text_center"><!--{$volist.orders}--></td>
        <td class="text_center">
          <input type="checkbox" name="flag" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$volist.menuid}-->" data-type="flag"<!--{if $volist.flag == '1'}--> checked<!--{/if}--> />
        </td>
        <td class="text_center"><!--{$volist.addtime|date_format:"%Y-%m-%d %H:%M"}--></td>
        <td align="right">
          <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=add&parentid=<!--{$volist.menuid}-->" class="layui-btn layui-btn-xs">添加二级菜单</a>
          <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$volist.menuid}-->&<!--{$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.menuid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
        </td>
      </tr>
      
      <!--{assign var="child_menu" value=vo_list("mod={weixinmenu} where={v.parentid='<!--{$volist.menuid}-->'} orderby={v.orders ASC}")}-->
      <!--{if !empty($child_menu)}-->
      <!--{foreach $child_menu as $val}-->
      <tr>
        <td class="text_center"><!--{$val.menuid}--></td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;-- <!--{$val.name}--></td>
        <td class="text_center"><!--{$val.type}--></td>
        <td><!--{$val.menuval}--></td>
        <td class="text_center"><!--{$val.orders}--></td>
        <td class="text_center">
          <input type="checkbox" name="flag" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$val.menuid}-->" data-type="flag"<!--{if $val.flag == '1'}--> checked<!--{/if}--> />
        </td>
        <td class="text_center"><!--{$val.addtime|date_format:"%Y-%m-%d %H:%M"}--></td>
        <td align="right">
          <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$val.menuid}-->&<!--{$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=<!--{$val.menuid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
        </td>
      </tr>
      <!--{/foreach}-->
      <!--{/if}-->
    
    
      <!--{/foreach}-->
      <!--{/if}-->
    </table>
    
  </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" />
	<input type="hidden" name="parentid" id="parentid" value="<!--{$parentid}-->" />
  <div class="layui-card">
    <div class="layui-card-header">添加菜单</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th width="15%"><font color="red">*</font>菜单类型：</th>
          <td width="85%">
            <div class="input-200">
            <select name="type" id="type">
              <option value="">请选择</option>
              <option value="menu">菜单(menu)</option>
              <option value="click">点击事件(click)</option>
              <option value="view">链接内容(view)</option>
              <!--//0.07.10 -->
            </select>
            </div>
            <span class="text_tip_inline">
              （提示：二级菜单，不能选择menu类型，否则无效）
            </span>
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>菜单名称：</th>
          <td>
            <input type="text" name="name" id="name" class="layui-input input-200" value="" />
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>菜单内容：</th>
          <td>
            <textarea name="menuval" id="menuval" class="layui-textarea" style="width:50%;height:60px;"></textarea>
            <br />
            <span class="text_tip_inline">
            （温馨提示：菜单类型为click的，可用事件：<br />
            MENU_ELITELADY(推荐女会员) / MENU_ELITEMAN(推荐男会员) / MENU_MARRY(征婚信息) / <br />MENU_PARTY(活动) / MENU_SERVICE(在线客服)）
            <br />
            URL标签可用：{siteurl}
            </span>
          </td>
        </tr>
        
        <!--//0.07.10 -->
        <tr>
          <th><font color="red"></font>状态：</th>
          <td>
            <input type="radio" name="flag" value="1" title="开启" checked />
            <input type="radio" name="flag" value="0" title="关闭" />
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>排序：</th>
          <td>
            <input type="text" name="orders" id="orders" class="layui-input input-120" value="<!--{$orders}-->" />
          </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(){

    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 ($("#type").val().length == 0) {
                    layer.msg("请选择菜单类型");
                    return false;
                }
                if ($("#name").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 width="15%"><font color="red">*</font>菜单类型：</th>
          <td width="85%">
            <div class="input-200">
              <select name="type" id="type">
                <option value="">请选择</option>
                <option value="menu"<!--{if $weixinmenu.type == 'menu'}--> selected<!--{/if}-->>菜单(menu)</option>
                <option value="click"<!--{if $weixinmenu.type == 'click'}--> selected<!--{/if}-->>点击事件(click)</option>
                <option value="view"<!--{if $weixinmenu.type == 'view'}--> selected<!--{/if}-->>链接内容(view)</option>
              </select>
            </div>
            <span class="text_tip_inline">（提示：二级菜单，不能选择menu类型，否则无效）</span>
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>菜单名称：</th>
          <td>
            <input type="text" name="name" id="name" class="layui-input input-200" value="<!--{$weixinmenu.name}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>菜单内容：</th>
          <td>
            <textarea name="menuval" id="menuval" class="layui-textarea" style="width:50%;height:60px;"><!--{$weixinmenu.menuval}--></textarea>
            <br />
            <span class="text_tip_inline">
            （温馨提示：菜单类型为click的，可用事件：<br />
            MENU_ELITELADY(推荐女会员) / MENU_ELITEMAN(推荐男会员) / MENU_MARRY(征婚信息) / <br />MENU_PARTY(活动) / MENU_SERVICE(在线客服)）
            <br />
            URL标签可用：{siteurl}
            </span>
          </td>
        </tr>

        <tr>
          <th><font color="red"></font>状态：</th>
          <td>
            <input type="radio" name="flag" value="1" title="开启"<!--{if $weixinmenu.flag == '1'}--> checked<!--{/if}--> />
            <input type="radio" name="flag" value="0" title="关闭"<!--{if $weixinmenu.flag == '0'}--> checked<!--{/if}--> />
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>排序：</th>
          <td>
            <input type="text" name="orders" id="orders" class="layui-input input-120" value="<!--{$weixinmenu.orders}-->" />
          </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(){

    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 ($("#type").val().length == 0) {
                    layer.msg("请选择菜单类型");
                    return false;
                }
                if ($("#name").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>