<?php include $this->admin_tpl('meta', 'admin');?>
<title>新建群发 - YzmCMS内容管理系统</title>
</head>
<body>
<nav class="breadcrumb"><i class="yzm-iconfont yzm-iconai-home"></i> 首页 <span class="c-gray en">&gt;</span> 微信管理 <span class="c-gray en">&gt;</span> 高级群发 <span class="c-gray en">&gt;</span> 新建群发 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="yzm-iconfont yzm-iconshuaxin"></i></a></nav>
<article class="page-container">
  <div class="explain explain-error light"> 
       <p><span class="yzm-iconfont yzm-iconshuoming"></span>订阅号：提供了每天一条的群发权限，服务号：每月（自然月）4条的群发权限，请谨慎操作！</p>
  </div>
<div class="formdoby_normal mt-10"> 
	<form method="post" action="<?php echo U('add');?>" onsubmit="return dosub(this)">
		<ul>
			<li><label>群发模式：</label>
				<label><input class="radio" type="radio" name="type" value="2" checked="checked"> 全部用户 </label>
	            <label><input class="radio" type="radio" name="type" value="1"> 按分组群发 </label>
	            <label><input class="radio" type="radio" name="type" value="0"> 按openid群发 </label>
			</li>
			<li id="groupid"  style="display:none"><label>微信分组：</label>
			<select  name="groupid" style="width:200px">
				<?php 
				foreach($data as $val){
					echo '<option value="'.$val['id'].'">'.$val['name'].'</option>';
				}
				?>
			 </select>
			</li>
			<li id="openid_li" style="display:none"><label>openid：</label>
			<textarea class="textarea" name="openid" id="openid" placeholder="多个openid之间用“,”分隔" style="width:450px"></textarea>&nbsp;&nbsp;<a href="javascript:;" class="btn btn-primary radius" onclick="yzm_open('选择用户','<?php echo U('select_user');?>',900,550)">选择用户</a>
			</li>
			<li><label>消息类型：</label>
			 <select  name="message_type" style="width:200px" onchange="javascript:change_type(this.value);">
			    <option <?php if($message_type == 'news') echo 'selected';?> value="news">图文</option>
				<option <?php if($message_type == 'text') echo 'selected';?> value="text">文本</option>	
				<option <?php if($message_type == 'image') echo 'selected';?> value="image">图片</option>
				<option <?php if($message_type == 'voice') echo 'selected';?> value="voice">语音</option>						
			 </select>
			</li>
			<li id="media_li"><label>media_id：</label>
			<input type="text" class="input" style="width:300px" name="media_id" id="media_id" value="<?php echo $media_id;?>">&nbsp;&nbsp;
			<a href="javascript:;" class="btn btn-primary radius" onclick="yzm_open('选择素材','<?php echo U('select_material');?>',900,550)">选择素材</a>
			</li>
			<li id="text_li" style="display:none"><label>内容：</label>
			<textarea class="textarea" name="content" id="content_text" style="width:450px"></textarea>
			</li>
			<li>
			<input type="hidden" name="dosubmit" value="1"><input class="dosubmit w_100 btn-primary radius" name="dosubmit" type="submit" value="提交">
			</li>
		</ul>
	</form>
</div>
</article>
<?php include $this->admin_tpl('footer', 'admin');?>

<script type="text/javascript">
	$(function(){
		$('input:radio[name="type"]').change(function(){  
			if($(this).val()=='2') {
				$('#groupid').css('display','none');
				$('#openid_li').css('display','none');
			}else if($(this).val()=='1'){
				$('#groupid').css('display','');
				$('#openid_li').css('display','none');
			}else{
				$('#groupid').css('display','none');
				$('#openid_li').css('display','');
			}
		}); 
	});

	
	function change_type(type) {
		if(type != 'text'){
			$('#media_li').css('display','');
			$('#text_li').css('display','none');
		}else{
			$('#text_li').css('display','');
			$('#media_li').css('display','none');
		}
	}
	
	
	function dosub(obj){
	
		 if($("input[name='type']:checked").val()=='0'){
			 if($("textarea[name='openid']").val()==''){
				 layer.msg('openid不能为空！');
				 return false;
			 }
		 }

		 if($("select[name='message_type']").val()!='text'){
			 if($("input[name='media_id']").val()==''){
				 layer.msg('media_id不能为空！');
				 return false;
			 }
		 }else{
			 if($("textarea[name='content']").val()==''){
				 layer.msg('消息内容不能为空！');
				 return false;
			 }		 
		 }
	 
		return true;			 
	}
</script> 

</body>
</html>