<?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为数字或英文字母，建议不要太长。</p></li>
			<li><label>场景分类：</label><label><input class="radio" type="radio" name="type" value="1" <?php if($data['type']) echo 'checked="checked"';?>>临时二维码</label>&nbsp;&nbsp;
	                <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>
			<li></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(){
		$('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-z0-9]+$/;
		 if($("input[name='scan']").val()=='' || !reg.test($("input[name='scan']").val())){
			 layer.msg('场景ID必须为英文拼音或数字！');
			 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>