<?php include $this->admin_tpl('meta', 'admin');?>
<title>添加微信菜单 - YzmCMS内容管理系统</title>
</head>
<style>
.exp{margin:5px 0px 5px 120px;color:#888}
</style>
<body>
<article class="page-container">
<div class="formdoby_normal"> 
	<form method="post" onsubmit="return dosub(this)">
		<ul>
			<li><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><p class="exp">一级菜单最多3个，每个一级菜单最多包含5个二级菜单。</p></li>
			<li><label><span class="c-red">*</span>菜单名称：</label><input type="text" class="input" style="width:300px" name="name" value=""><p class="exp">一级菜单最多4个汉字，二级菜单最多7个汉字，多出来的部分将会以“...”代替。</p></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><label>Key/URL：</label><input type="text" class="input" style="width:300px" name="keyword" id="keyword" value="">
			<input type="url" class="input" style="width:450px;display:none" name="url" id="url" value=""><p class="exp"><span class="c-red">该菜单为一级菜单，且该菜单下有二级菜单时，此选项为空，否则不为空！</span></p></li>
			<li></li>
			<li><label>菜单排序：</label><input type="text" class="input" style="width:100px;" name="listorder" value="0"> <span style="color:#888">由小到大排列</span></li>
			<li><input type="hidden" name="dosubmit" value="1"><input class="dosubmit w_120 btn-primary radius" name="dosubmit" type="submit" value="提交"> <input class="btn w_120 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){
					parent.location.reload();       
			    }else{
					layer.msg(msg.message);
				}
            }
        })		 
		return false;			 
	}
</script> 

</body>
</html>