{include file='public/meta'}
<link rel="stylesheet" href="__LIB__/layui/css/layui.css" media="all">
<body>
<article class="page-container">
	<form class="form form-horizontal" id="frm1">

	<?php if(1==$mullevels){?>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">父类别</label>
		<div class="formControls col-xs-8 col-sm-9">
			<span class="select-box" style='width:200px'>
			<?php if($row){?>
				<select name="pid" class='select'>
		            <option value="0">--作为顶级--</option>
		            {volist name="$categorys" id="vo"}
		            <option value="{$vo.id}" <?php if($row['pid']==$vo['id']) echo 'selected';?> ><?php echo $vo['new_title'];?></option>
		            {/volist}
	          	</select>
		    <?php }else{?>
			    <select name="pid" class='select'>
		            <option value="0">--作为顶级--</option>
		            {volist name="$categorys" id="vo"}
		            <option value="{$vo.id}" <?php if($pid==$vo['id']) echo 'selected';?> ><?php echo $vo['new_title'];?></option>
		            {/volist}
	          	</select>
		    <?php }?>
		    </span>
		</div>
	</div>
	<?php }?>

	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>名称</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text"  placeholder="" id="title" name="title" value="<?php echo $row['title'];?>" >
		</div>
	</div>

	<?php if('index'==$type || 'goods'==$type){?>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>图标(100x100)</label>
		<div class="formControls col-xs-8 col-sm-9">
			<button type="button" class="btn btn-primary size-S" id="btn_icon">上传</button>
			<div>
				<img class="layui-upload-img" id="demo_icon" width="100"  {notempty name="$row.icon"}src="{$row.icon|get_url}"{/notempty} >
			</div>
			<input type="hidden" name="icon" id='icon' value="<?php echo intval($row['icon']);?>"  />
		</div>
	</div>
	<?php }?>

	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">顺序</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" onkeyup="checkInputInt(this)" placeholder="" id="sort" name="sort" value="<?php echo intval($row['sort']);?>"  >
			
		</div>
	</div>

	<?php if('index'==$type && $row['pid']==0){?>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-2">移动端显示</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div class="radio-box">
					<input name="mobile_display" type="radio" id="mobile_display-1"  value="0" <?php if($row['mobile_display']==0) echo 'checked' ;?>>
					<label for="mobile_display-1">不显示</label>
				</div>
				<div class="radio-box">
					<input name="mobile_display" type="radio" id="mobile_display-2"  value="1" <?php if($row['mobile_display']==1) echo 'checked' ;?>  >
					<label for="mobile_display-2">显示</label>
				</div>
			</div>
	</div>
	<?php }?>


	<input type="hidden" name="id" value="<?php echo intval($row['id']);?>">
	<input type="hidden" name="type" value="<?php echo $type;?>" >

	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		</div>
	</div>



	</form>
</article>

{include file='public/pfooter'}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__LIB__/layui/layui.js"></script> 
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#frm1").validate({
		rules:{
			title:{
				required:true,
			},
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
				type: 'post',
				url: "<?php echo url('admin/category/publish');?>" ,
				success: function(data){
					layer.msg(data.msg,{icon:1,time:1000});
					if(0==data.error){
						setTimeout(function(){
							var index = parent.layer.getFrameIndex(window.name);
							parent.location.reload();
							parent.layer.close(index);
						},1000)
					}
				},
                error: function(XmlHttpRequest, textStatus, errorThrown){
					layer.msg('服务器错误',{icon:1,time:1000});
				}
			});
		}
	});
});
</script>
<script>
//上传图片PC LOGO
layui.use('upload', function(){
  var upload = layui.upload;
  //执行实例
  var uploadInst = upload.render({
    elem: '#btn_icon' //绑定元素
    ,url: "{:url('common/upload',['atype'=>'current_cate_icon'])}" //上传接口
    ,done: function(res){
      //上传完毕回调
      if(0==res.error) {
        $('#demo_icon').attr('src',res.src);
        $('#icon').val(res.id);
      } else {
        layer.msg(data.msg,{icon:1,time:1000});
      }
    }
    ,error: function(){
    	layer.msg('接口异常');
    }
  });
});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>