<?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>场景ID：</label>
				<input type="text" class="input" style="width:300px" name="scan" value="<?php echo $data['scan']?>">
				<p class="exp">场景ID必须为英文、数字或下划线，且长度为1-30位。</p>
			</li>
			<li><label>场景分类：</label>
				<label><input class="radio" type="radio" name="type" value="1" <?php if($data['type']) echo 'checked="checked"';?>> 临时二维码</label>
	            <label><input class="radio" type="radio" name="type" value="0" <?php if(!$data['type']) echo 'checked="checked"';?>> 永久二维码</label>	
	        </li>
			<li id="expire_time" <?php if(!$data['type']) echo 'style="display:none"';?>><label>过期时间：</label>
				<select  name="expire_time" class="select" style="width:300px">
					<option value="180" <?php if($data['expire_time'] == 180) echo 'selected';?>>3分钟</option>
					<option value="1800" <?php if($data['expire_time'] == 1800) echo 'selected';?>>30分钟</option>
					<option value="3600" <?php if($data['expire_time'] == 3600) echo 'selected';?>>1小时</option>
					<option value="10800" <?php if($data['expire_time'] == 10800) echo 'selected';?>>3小时</option>
					<option value="21600" <?php if($data['expire_time'] == 21600) echo 'selected';?>>6小时</option>
					<option value="43200" <?php if($data['expire_time'] == 43200) echo 'selected';?>>12小时</option>
					<option value="86400" <?php if($data['expire_time'] == 86400) echo 'selected';?>>24小时</option>
				</select>
			</li>
			<li><label>备注：</label>
				<textarea class="textarea" name="remarks" style="width:450px"><?php echo $data['remarks']?></textarea>
			</li>
		</ul>
		<div class="footer_btn">
			<input type="hidden" name="dosubmit" value="1">
			<input type="hidden" name="id" value="<?php echo $data['id']?>">
			<input class="btn btn-primary radius" type="submit" value="提 交">
			<input class="btn btn-default radius" type="button" value="取 消" onclick="yzmcms_close()">	
		</div>
	</form>
</div>
</article>
<?php include $this->admin_tpl('footer', 'admin');?>

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

	function dosub(obj){
		 var reg = /^[a-zA-Z]{1}([a-zA-Z0-9]|[_]){0,29}$/;	
		 if(obj.scan.value.length<1 || obj.scan.value.length>30){
		 	layer.msg('场景ID长度必须为1-30位！', {icon:2});
		 	return false;
		 }
		 if(!reg.test(obj.scan.value)){
		 	layer.msg('场景ID必须为英文、数字或下划线！', {icon:2});
		 	return false;
		 }
        $.ajax({
            type: 'POST',
            url: '<?php echo U('edit');?>', 
            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>