<?php
$this->display(tpl('head',true)); 
?>
<style>

	.wap_comment_list_title{
		line-height: 35PX;
		border-bottom: 1px solid #efefef;
	}

	.content .text{
		padding: 10px;
	}
	.wap_comment_list_action{
		border-top: 1px solid #efefef;
		margin-top: 10px;
		text-align: center;
	}
	.wap_comment_list_action .action_s{
		position: absolute;
		margin-top: -13px;
		font-size: 1.2em;
		left: 43%;
		background-color: #fff;
	}
	.action_a{
		margin-top: 15px;
		margin-bottom: 10px;
	}
</style>

<div class="w-100 left bcf center">
	<div class="layui-form-item mt10 center top_button">
		<a href="/user/comment/alllist/" class="layui-btn layui-btn-normal">全部评论</a>
		<a href="/user/comment/alllist/state/1" class="layui-btn layui-btn-warm">已审核评论</a>
		<a href="/user/comment/alllist/state/0" class="layui-btn layui-btn-danger">未审核评论</a>
	</div>
</div>

<form class="layui-form wap_comment" id="from" method="post" action="/user/comment/del">

<?php 
foreach($data AS $row){
?>
	<div class="wap_comment_list left w-100 bcf mt10"  id="list_<?php echo $row[id] ?>">
		<div class="wap_comment_list_title">
			<div class="left pl10">
				<input name="iddb[]" value="<?php echo $row[id] ?>" class="dr_select"  lay-skin="primary" type="checkbox">
				Id:<?php echo $row[id] ?>
			</div>
			<div class="right pr10">
				时间：{{date('Y-m-d H:i:s',$row[posttime])}}
			</div>
			<div class="c"></div>
		</div>
		<div class="content left w-100 bcf mt10">
			<div class="text">
				<?php echo $row[content] ?>
			</div>
		</div>
		<div class="wap_comment_list_action left w-100">
			<div class="action_s">操&nbsp;&nbsp;&nbsp;&nbsp;作</div>
			<div class="action_a">
				<button class="layui-btn layui-btn-sm"  lay-submit='' lay-filter="del" id="<?php echo $row[id]?>">删除</button>
			</div>
		</div>
	</div>
			<div class="wap_comment_list left w-100 bcf mt10"  id="list_<?php echo $row[id] ?>">
				<div class="wap_comment_list_title">
					<div class="left">
						<input name="iddb[]" value="<?php echo $row[id] ?>" class="dr_select"  lay-skin="primary" type="checkbox">
						Id:<?php echo $row[id] ?>
					</div>
					<div class="right">
						时间：{{date('Y-m-d H:i:s',$row[posttime])}}
					</div>
					<div class="c"></div>
				</div>
				<div class="content left w-100 bcf mt10">
					<div class="text">
						<?php echo $row[content] ?>
					</div>
				</div>
				<div class="wap_comment_list_action left w-100">
					<div class="action_s">操&nbsp;&nbsp;&nbsp;&nbsp;作</div>
					<div class="action_a">
						<button class="layui-btn layui-btn-sm"  lay-submit='' lay-filter="del" id="<?php echo $row[id]?>">删除</button>
					</div>
				</div>
			</div>
<?php } ?>

	<div class="w-100 left bcf mt10">
		<div class="layui-form-item mt10 center w-100 left">
				<button class="layui-btn layui-btn-sm layui-btn-warm" 	onclick="return all_checkbox_check('1')">全选</button>
				<button class="layui-btn layui-btn-sm layui-btn-warm" 	onclick="return all_checkbox_check('-1')">反选</button>
				<button class="layui-btn layui-btn-sm layui-btn-warm" 	onclick="return all_checkbox_check('0')">取消选择</button>
				<button class="layui-btn layui-btn-sm layui-btn-danger" >批量删除</button>
		</div>
	</div>

</form>
<?php if($Get_Page) { ?>
	<div class="w-100 left bcf mt10">
		<div class="layui-form-item mt10 center page">
			<?php echo $Get_Page ?>
		</div>
	</div>
<?php } ?>

<script>
	//function selectAllNullorReserve(obj,type){
function all_checkbox_check(type){
	if(document.getElementsByClassName('layui-form-checkbox')!=undefined && document.getElementsByClassName('layui-form-checkbox').length>0){  
	  var class_box = document.getElementsByClassName('layui-form-checkbox');
	  var ids = document.getElementsByName('iddb[]');
		if(type=="1"){//全选
			for(var i=0;i<class_box.length;i++){
					$(ids[i]).prop("checked", true);
			   	$(class_box[i]).addClass("layui-form-checked");
			}
		}else if(type=="0"){//全不选
			for(var i=0;i<class_box.length;i++){
					$(ids[i]).prop("checked", false);
			    $(class_box[i]).removeClass("layui-form-checked");
			}
		}else if(type=="-1"){//反选
			for(var i=0;i<class_box.length;i++){
					if(ids[i].checked==true){
						$(ids[i]).prop("checked", false);
					}else{
						$(ids[i]).prop("checked", true);
					}
			   	$(class_box[i]).toggleClass("layui-form-checked");
			}
		}
	}
	return false;
}  


layui.use(['form','layer'], function(){
  	var form = layui.form
  	,layer = layui.layer;
  	form.on('submit(del)', function(obj){
		  	$.ajax({
				url:"/user/comment/del/",
				type: 'POST',
				data:{'id':obj.elem.id,'json':true},
				dataType: 'json',
				success: function(data){
					layer.msg(data.text);
					if(data.code==0){
						$('#list_'+obj.elem.id).remove();
					}
					
				}
			})
		  return false;
  	});
});
</script>
<?php 
$this->display(tpl('foot',true)); 
?>
