
{if (config::get('comment_switch')==2)}
{elseif (config::get('comment_switch')==0 || (session::get('username')!='' && config::get('comment_switch')==1))}

{if config::get('comment_list')=='1'}



	{if config::get('reply_comment')=='1'}
	<link href="{$template_path}/visual/list/listcommenttag/list/css/reply-comment.css" rel="stylesheet">
	<script src="{$base_url}/common/js/layer/layer.js"></script>
	<script type="text/javascript" src="{$base_url}/common/plugins/pagenav/pagenav1.1.cn.js"></script>
	<script type="text/javascript">

		function getcommentdata(p){
			$.ajax({
				type: "get",
				url: "<?php echo url('comment/ajax/aid/'.$aid); ?>",
				dataType: 'json',
				data: "p="+p,
				success: function(msg){
					//console.log(msg);
					$('#comment-list').empty();
					for(row in msg){
						//console.log(msg['row']);
						$('#comment-list').append("<li><div class='h'><span class='name'>"+msg[row].username+"</span><span class='date'>"+msg[row].adddate+"</span></div><div class='p'>"+msg[row].content+"</div><div class='f'><span class='zan_btn' data-aid='<?php echo $aid; ?>' data-cid='"+msg[row].id+"'>{lang('praise')}[<i id='zan_"+msg[row].id+"'>"+msg[row].zannum+"</i>]</span><span class='reply_btn' id='reply_btn_"+msg[row].id+"' data-raid='<?php echo $aid; ?>' data-rcid='"+msg[row].id+"'>{lang('reply')}</span></div><div class='clear'></div></li>");
						//<div style='display:none;' id='rcid_"+msg[row].id+"'><textarea id='trid_"+msg[row].id+"' name='content' rows='6' cols='50'></textarea><br /><input name='submit' value='发表回复' type='button' data-baid='<?php echo $archive['aid']; ?>' data-brid='"+msg[row].id+"' class='re_btn' /></div>
					}
					$('.zan_btn').click(function(e) {
						var id = $(this).data('cid');
						var aid = $(this).data('aid');
						$.get("{url('comment/zan')}",{"id":id,"aid":aid},function(data){
							if(data != "unsign"){
								alert('{lang("point-like")}{lang("success")}');
								$('#zan_'+id).html(data);
							}else{
								alert('{lang("not_logged")}');
							}
						});
						//console.log(aid);
					});

					$('.reply_btn').click(function(){
						var rcid = $(this).data('rcid');
						var raid = $(this).data('raid');

						layer.open({
							type: 1,
							skin: 'layui-layer-rim', //加上边框
							title: '{lang("submit_on")}{lang("reply")}',
							area: ['300px', '300px'], //宽高
							content: "<div class='reply-info'><form id='frmreply' action='<?php echo url('comment/reply');?>' method='post' name='frmreply'><textarea name='content' class='reply-textarea' style='width:256px;height:120px; padding:10px; '></textarea><input name='aid' value='"+raid+"' type='hidden' /><input name='rid' value='"+rcid+"' type='hidden' /><div class='blank10'></div><button class='btn btn-primary'  type='submit' name='submit' value='{lang("submit_on")}'>{lang("submit_on")} <span class='badge'>Guestbook</span></button></div>"
						});

					});
					$('.re_btn').click(function(e) {
						var brid = $(this).data('brid');
						var baid = $(this).data('baid');
						var content = $('#trid_'+brid).val();
						if(content == ''){
							alert('{lang("please_fill_in_the_content")}');
							$('#trid_'+brid).focus();
							return;
						}else{
							$.post("{url('comment/reply')}",{"rid":brid,"aid":baid,"content":content},function(data){
								if(data != "unsign"){
									alert('{lang("reply")}{lang("success")}');
									//$('#zan_'+id).html(data);
									getcommentdata(1);
								}else{
									alert('{lang("not_logged")}');
								}
							});
						}
					});
				}
			});
		}

		//$(function(){ //for jquery
		$(function(){
			//getcommentdata(1);
			//optional set
			pageNav.pre="{lang('uppage')}";
			pageNav.next="{lang('downpage')}";


			//  p,当前页码,pn,总页面
			pageNav.fn = function(p,pn){
				//document.getElementById("test").innerHTML ="当前页:"+p+"  ,  总页: "+pn;
				//$("#test").text("Page:"+p+" of "+pn + " pages."); // jquery调用方式
				getcommentdata(p);
			};

			//重写分页状态,跳到第三页,总页33页
			pageNav.go(1,{$pages});



		});

	</script>
	<script src="{$base_url}/common/plugins/mobilechk/mobilechk.js"></script>
	{else}
	<link href="{$template_path}/visual/list/listcommenttag/list/css/comment-list.css" rel="stylesheet">


	<!-- 评论列表开始 -->
	<div class="comment-list comment-list-$_id">
		{loop $comments $comment}
		<div class="comment-content-item">
			<div class="comment-head col-xs-3 col-sm-1">
				<img src="{user::getuserimg($comment['username'])}" alt="headimage" class="img-responsive">
			</div>
			<div class="col-xs-9 col-sm-11">
				<p>
					<span class="pull-right">{sdate($comment['adddate'],'Y-m-d H:i')}</span>
					<strong>{$comment['username']}</strong>
				</p>
				<div class="comment-content ">
					<p>
						{strip_tags($comment['content'])}
					</p>
					<div class="clearfix"></div>
				</div>
				{if $comment['reply']}
				<div style="margin:10px 0px 0px 15px;">
					<p>{lang('adminreply')}：</p>
					<div class="comment-content">
						<dd class="comment-admin-reply">
							<p>{$comment['reply']}</p>
						</dd>
						<div class="clearfix"></div>
					</div>
				</div>
				{/if}
				<div class="blank10"></div>
			</div>
		</div>
		{/loop}
	</div>
	<style>
		.comment-list-$_id .btn {
			font-size:$_btn-size;
			color:$_btn-text-color;
			border-color:$_btn-border-color;
			border-radius: $_btn-border-radius;
			background:$_btn-background-color;
		}
		.comment-list-$_id .btn:hover {
			color:$_btn-text-hover-color;
			border-color:$_btn-border-hover-color;
			border-radius: $_btn-border-hover-radius;
			background:$_btn-background-hover-color;
		}
		.comment-list-$_id .comment-content {
			font-size:$_p-size;
			color:$_p-color;
			background:$_background-color;
			border-color:$_background-border-color;
		}
		.comment-list-$_id .comment-content-item:hover .comment-content {
			color:$_p-hover-color;
			background:$_background-hover-color;
			border-color:$_background-border-hover-color;
		}
		.comment-list-$_id .comment-content-item p strong {
			font-size:$_title-size;
			color:$_title-color;
		}
		.comment-list-$_id .comment-content-item:hover p strong {
			color:$_title-hover-color;
		}
		.comment-list-$_id .comment-content-item p span.pull-right {
			font-size:$_subtitle-size;
			color:$_subtitle-color;
		}
		.comment-list-$_id .comment-content-item:hover p span.pull-right {
			color:$_subtitle-hover-color;
		}
		.comment-list-$_id .comment-content:before {
			border-bottom: 10px solid $_background-border-color;
		}
		.comment-list-$_id .comment-content:after {
			border-bottom: 8px solid $_background-color;
		}
		.comment-list-$_id .comment-content-item:hover .comment-content:before {
			border-bottom: 10px solid $_background-border-hover-color;;
		}
		.comment-list-$_id .comment-content-item:hover .comment-content:after {
			border-bottom: 8px solid $_background-hover-color;
		}
	</style>
	{/if}



{else}

<div class="comment-list comment-list-$_id">

	<div class="blank30"></div>
	<div class="text-center">
		<h3>
			{lang('no_guestbook_list')}
		</h3>
	</div>


</div>
{/if}

{/if}

