<?php include $this->admin_tpl('meta', 'admin');?>
<title>添加微信菜单 - YzmCMS内容管理系统</title>
</head>
<body>
<article class="page-container">
<div class="formdoby_normal"> 
	<form method="post" onsubmit="return dosub(this)">
		<ul>
			<li class="yzm-explain-box">
			<label><span class="c-red">*</span>上级菜单：</label>
			<select  name="parentid" class="select" style="width:300px">
				<option value="0">一级菜单</option>
			   <?php 
				foreach($data as $val){
					$str = $id == $val['id'] ? 'selected' : '';
					echo '<option value="'.$val['id'].'" '.$str.'>'.$val['name'].'</option>';
				}
			   ?>			
			 </select>
			 <span class="yzm-explain">一级菜单最多3个，每个一级菜单最多包含5个二级菜单。</span>
			</li>
			<li class="yzm-explain-box">
			<label><span class="c-red">*</span>菜单名称：</label>
			<input type="text" class="input" style="width:286px" name="name" value="" placeholder="请输入菜单名称" >
				<span class="yzm-explain">一级菜单最多4个汉字，二级菜单最多7个汉字，多出来的部分将会以“...”代替。</span>
			</li>
			<li>
			<label>菜单类型：</label>
			<select  name="type" class="select" style="width:300px" onchange="javascript:setting(this.value);">
				<option value="1">关键字</option>	
				<option value="2">跳转链接</option>	
			</select>
			</li>
			<li class="yzm-explain-box">
			<label>Key/URL：</label>
				<input type="text" class="input" style="width:286px" name="keyword" id="keyword" value="">
				<input type="text" class="input" style="width:286px;display:none" name="url" id="url" value="">
				<span class="yzm-explain">该菜单为一级菜单，且该菜单下有二级菜单时，此选项为空，否则不为空！</span>
			</li>
			<li class="yzm-explain-box">
				<label>菜单排序：</label>
				<input type="text" class="input" style="width:100px;" name="listorder" value="0">
				<span class="yzm-explain">由小到大排列</span>
			</li>
			<li>
				<input type="hidden" name="dosubmit" value="1">
				<input class="dosubmit w_100 btn-primary radius" name="dosubmit" type="submit" value="提交"> 
				<input class="btn w_100 btn-default radius" type="button" value="取消" onclick="yzmcms_close()">
			</li>
		</ul>
	</form>
</div>
</article>
<?php include $this->admin_tpl('footer', 'admin');?>

<script type="text/javascript">
	function setting(val) {
	    if(val=='1') {
			$('#keyword').css('display','');
			$('#url').css('display','none');
		}else{
			$('#keyword').css('display','none');
			$('#url').css('display','');
		}  		
	}
	function dosub(obj){
		 if(obj.name.value==''){
			 layer.msg('菜单名称不能为空！');
			 return false;
		 }
        $.ajax({
            type: 'POST',
            url: '<?php echo U('add');?>', 
            data: $(obj).serialize(),
		    dataType: "json", 
            success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1,time:1500}, function(){
						parent.location.reload();     
					});
			    }else{
					layer.msg(msg.message, {icon:2});
				}
            }
        })		 
		return false;			 
	}
</script> 

</body>
</html>