<?php /*a:1:{s:65:"/www/wwwroot/666.u7u.top/application/ohbbs/view/article/edit.html";i:1552457560;}*/ ?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link rel="stylesheet" href="/public/static/layui/css/layui.css" media="all">
	<link rel="stylesheet" href="/public/static/css/admin.css" media="all">
</head>
<body>
	<form class="layui-form column-content-detail">
		<div class="layui-tab-item layui-show">
			<div class="layui-form-item">
				<label class="layui-form-label">文章名称：</label>
				<div class="layui-input-block">
					<input type="text" name="title" required lay-verify="required" placeholder="请输入文章名称" autocomplete="off" class="layui-input" value="<?php echo htmlentities($data['title']); ?>">
				</div>
			</div>
			<div class="layui-form-item">
			<label class="layui-form-label">所属分类</label>
			<div class="layui-input-block">
			  <select name="pid" lay-verify="required">
			    <option value=""></option>
			    <?php foreach($res as $k=>$vo): ?>
			    	<option value="<?php echo htmlentities($vo['id']); ?>" <?php if($vo['id'] == $data['pid']): ?>selected<?php endif; ?>><?php echo htmlentities($vo['name']); ?></option>
			    <?php endforeach; ?>
			  </select>
			</div>
			</div>
			<div class="layui-form-item form-group">
				<label class="layui-form-label control-label">缩略图：</label>
				<div class="layui-input-block">
					<div class="row" style="margin:0">
						<input type="hidden" value="<?php echo htmlentities($data['img']); ?>" name="img" id="fileid_thumb">
						<div class="btn btn-sm blue uploader layui-left layui-btn layui-btn-sm" style="margin-right:15px" id="img">
							<i class="fa fa-cloud-upload layui-icon"></i> 上传
						</div>
					</div>
				</div>
			</div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">文章内容：</label>
		    <div class="layui-input-block">
		      <textarea id="content" name="content" style="display: none;"><?php echo htmlentities($data['content']); ?></textarea>
		    </div>
		  </div>
		</div>
		<div class="layui-form-item" style="padding-left: 10px;">
			<div class="layui-input-block">
				<input type="hidden" name="id" value="<?php echo htmlentities($data['id']); ?>">
				<button class="layui-btn layui-btn-normal" lay-submit lay-filter="addform">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
<script src="/public/static/layui/layui.js"></script>
<script src="/public/static/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
layui.use(['layedit','form'], function(){
  	var layedit = layui.layedit;
  	var form = layui.form;
  	var $ = layui.jquery;
	layedit.set({
	    uploadImage: {
	        url: "<?php echo url('api/scode/lay_img_upload'); ?>",
	        type: 'post',
	    }
	});
  	var index = layedit.build('content');
	form.on('submit(addform)', function(data){
  		var content = layedit.getContent(index);
  		data.field.content = content;
		$.post("<?php echo url(''); ?>",data.field,function(data){
		  if(data.code == 1){
		    layer.msg(data.msg, {time: 2000}, function(){
		      location.href = data.url;
		    });
		  }else{
		    layer.msg(data.msg, {time: 2000});
		  }
		});
		return false;
	});
});
</script>
<script>
layui.use(['upload','jquery'], function(){
	var $ = layui.jquery;
	var upload = layui.upload;
  	var uploadInst = upload.render({
    elem: '#img'
    ,url: "<?php echo url('api/scode/upthumb'); ?>"
    ,exts: 'jpg|png|gif|jpeg'
	,dataType: 'json'
	,acceptMime: 'image/jpg,image/png'
    ,done:function(res){
        if (res.code == 0){
        	layer.msg(res.msg, {time: 2000});
        }else{
        	layer.msg(res.msg, {time: 2000});
        }
        $('#fileid_thumb').val(res.filepath);
    }
  });
});
</script>
</body>
</html>