<?php if(!defined('IN_SDCMS')) exit;?>{include file="mobile/top.php"}
<title>{$title}_{sdcms[bbs_webname]}</title>
<meta name="keywords" content="{sdcms[bbs_seokey]}">
<meta name="description" content="{sdcms[bbs_seodesc]}">
<script src="{WEB_ROOT}public/ueditor/ueditor.config.js"></script>
<script src="{WEB_ROOT}public/ueditor/ueditor.all.min.js"></script>
</head>

<body>
	{include file="mobile/head.php"}

    <article>
    	<section>
        <div class="bbs_show">
            <div class="title">
                <h1>{$title}</h1>
                <div class="info">{$uname}　　{formatTime($createdate)}　　<span class="am-icon-eye am-icon-fw"></span>{$hits}　　<span class="am-icon-comment-o am-icon-fw"></span>{$replynum}{if $islogin==$userid}　　<a href="{N('bbsedit','','id='.$id.'')}"><span class="ui-icon-edit"></span>编辑</a>{/if}</div>
            </div>
            {if $view_lever==1}
                <div class="content">{$content}</div>
            {else}
                {if $islogin==0}
                <div class="tip">您需要登录后才可以查看，请先<a href="{N('login')}">登录</a>或<a href="{N('reg')}">注册</a></div>
                {elseif $view_lever==0}
                <div class="tip">您所在用户组，无法查看帖子</div>
                {else}
                <div class="content">{$content}</div>
                {/if}
            {/if}
         </div>
         
         <div class="bbs_reply">
                <div class="title">最新回复</div>
                
                <ul class="media-list media-border mb-20">
                    {sdcms:rs pagesize="15" table="sd_bbs_reply" join="left join sd_user on sd_bbs_reply.userid=sd_user.id" where="sd_bbs_reply.islock=1 and bbsid=$id and istopic=0" order="replyid" key="replyid"}
                    <li class="media">
                        <div class="media-img mr-20 radius">
                            <img src="{if strlen($rs[uface])}{$rs[uface]}{else}{WEB_ROOT}upfile/noface.gif{/if}" alt="{$rs[uname]}" width="56" height="56" >
                        </div>
                        <div class="media-body">
                            <div class="media-header row align-items-center">
                                <div class="col-8 font-14">{$rs[uname]}<span class="pl text-gray">{formatTime($rs[createdate])}</span></div>
                                <div class="col-4 text-right font-13 text-gray">{switch ($i+15*($page-1))}{case 1}沙发{/case}{case 2}板凳{/case}{case 3}地板{/case}{default}{$i+15*($page-1)}楼{/switch}</div>
                            </div>
                            <div class="media-text">
                                {if $view_lever==1}
                                    {$rs[content]}
                                    {if $rs[reply]<>''}<div class="line line-left"><span class="text-red">管理员回复：</span></div>{$rs[reply]}</div>{/if}
                                {else}
                                    {if $islogin==0}
                                    <div class="tip">您需要登录后才可以查看，请先<a href="{N('login')}">登录</a>或<a href="{N('reg')}">注册</a></div>
                                    {elseif $view_lever==0 && $rs[userid]==$userid}
                                    <div class="tip">您所在用户组，无法查看帖子</div>
                                    {else}
                                        {$rs[content]}
                                        {if $rs[reply]<>''}<div class="line line-left"><span class="text-red">管理员回复：</span></div>{$rs[reply]}</div>{/if}
                                    {/if}
                                {/if}
                            </div>
                        </div>
                    </li>
                    {/sdcms:rs}
                </ul>


                {if $pg->totalpage>1}
                <div class="page page-center page-mid"><ul>{$showpage}</ul></div>
                {/if}
                {if $islogin==0}
                    <div class="form_reply">
                        <div class="face"><img src="{WEB_ROOT}upfile/noface.gif"><p>{$r_uname}</p></div>
                        <div class="info">
                            <textarea placeholder="您需要登录后才可以回复" disabled></textarea>
                            <input type="submit" value="回复" disabled class="btn btn-blue mt">
                        </div>
                        <div class="clear"></div>
                    </div>
                {else}
                    {if $reply_lever==0}
                    <div class="form_reply">
                        <div class="face"><img src="{WEB_ROOT}upfile/noface.gif"><p>{$r_uname}</p></div>
                        <div class="info">
                            <textarea placeholder="您所在用户组没有回帖权限" disabled></textarea>
                            <input type="submit" value="回复" disabled class="btn btn-blue mt">
                        </div>
                        <div class="clear"></div>
                    </div>
                    {else}
                    <form method="post" class="post_reply">
                        <div class="form_reply">
                            <div class="face"><img src="{if strlen($r_uface)}{$r_uface}{else}{WEB_ROOT}upfile/noface.gif{/if}"><p>{$r_uname}</p></div>
                            <div class="info">
                                <script id="content" name="content" type="text/plain" style="height:150px;"></script>
                                <script>UE.getEditor('content',{serverUrl:'{U('home/upload/index')}',toolbars:editorBbs});</script>
                                {if sdcms[bbs_reply_code]==1}
                                    <div class="input-group mt">
                                        <input type="text" class="form-ip radius-right-none" name="code" id="code" size="8" maxlength="8" placeholder="请输入验证码" data-rule="验证码:required;">
                                        <span class="code"><img src="{U('code')}" height="40" id="verify" title="点击更换验证码"></span>
                                    </div>
                                {/if}
                                <input type="submit" value="回复" class="btn btn-blue btn-block mt">
                            </div>
                            <div class="clear"></div>
                        </div>
                    </form>
                    {/if}
                {/if}
             </div>

            </div>
    	 </section>
    </article>
    {include file="mobile/foot.php"}
    <script>
	$(function()
	{
		{if $islogin!=0&&$reply_lever==1}
		//快捷键提交评论
	    $(".post_reply").find('textarea').on("keydown", function(e){
	    	e.stopPropagation();
	    	if(e.ctrlKey && e.which ==13){
	    		$('.post_reply').submit();
	    	}
	    });
		
		$(".post_reply").form(
		{
			type:2,
			align:'bottom-center',
			result:function(form)
			{
				var content=UE.getEditor('content').getContent();
				if(content=='')
				{
					toastr.error('回复内容不能为空');
					return false;	
				}
				$.ajax(
				{
					type:'post',
					cache:false,
					dataType:'json',
					url:"{U('home/bbs/reply','id='.$id.'')}",
					data:$(form).serialize(),
					error:function(e){alert(e.responseText);},
					success:function(d)
					{
						if(d.state=='success')
						{
							sdcms.success(d.msg);
							setTimeout(function(){location.href='{THIS_LOCAL}';},1500);
						}
						else
						{
							sdcms.error(d.msg);
						}  
					}
				});
			}
		});
		{/if}
	})
	</script>
</body>
</html>