<?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" disabled="disabled" style="width:300px">
				<option value="0">一级菜单</option>
			   <?php 
				foreach($res as $val){
					$str = $data['parentid'] == $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:300px" name="name" value="<?php echo $data['name']?>" 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" <?php if($data['type'] == 2) echo 'selected';?>>跳转链接</option>	
				</select>
			</li>
			<li class="yzm-explain-box"><label>Key/URL：</label>
			<input type="text" class="input" style="width:300px;<?php if($data['type'] == 2) echo 'display:none';?>" name="keyword" id="keyword" value="<?php echo $data['keyword']?>">
			<input type="text" class="input" style="width:300px;<?php if($data['type'] == 1) echo 'display:none';?>" name="url" id="url" value="<?php echo $data['url']?>">
			<span class="yzm-explain">该菜单为一级菜单，且该菜单下有二级菜单时，此选项为空，否则不为空！</span>
			</li>
			<li></li>
			<li class="yzm-explain-box"><label>菜单排序：</label><input type="text" class="input" style="width:100px;" name="listorder" value="<?php echo $data['listorder']?>"> 
				<span class="yzm-explain">由小到大排列</span>
			</li>
			<li><input type="hidden" name="id" value="<?php echo $data['id']?>"><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('edit');?>', 
            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>