pbootcms會員中心 文章評論代碼
{pboot@if({pboot:commentstatus})} <div class="container"> <div class="shadow-sm p-3 my-5 bg-white rounded"> <h4>發(fā)表評論:</h4> <form class="my-4" onsubmit="return submitcomment(this);" data-action="{pboot:commentaction}" > <div class="form-group"> <textarea name="comment" id="comment" class="form-control" placeholder="請輸入評論內(nèi)容"></textarea> </div> {pboot:2if({pboot:commentcodestatus})} <div class="form-group"> <div class="row"> <div class="col-6 col-md-3"> <input type="text" name="checkcode" required id="checkcode" class="form-control" placeholder="請輸入驗(yàn)證碼"> </div> <div class="col-6 col-md-3"> <img title="點(diǎn)擊刷新" class="codeimg" style="height:33px;" src="{pboot:checkcode}" onclick="this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);" /> </div> </div> </div> {/pboot:2if} <div class="form-group"> <button type="submit" class="btn btn-info mb-2">提交評論</button> </div> </form> <h4>評論記錄:</h4> <a name="comment"></a> {pboot:comment contentid={content:id} num=20} <div class="media border-bottom pb-3 pt-3"> <img class="mr-3" src="[comment:headpic]" height="25"> <div class="media-body"> <h6 class="mt-0"> <strong>[comment:nickname]</strong> <small style="color:#999">[comment:date]</small> </h6> <p>[comment:comment] <span class="badge badge-light text-secondary font-weight-normal replybtn" data-action="[comment:replyaction]">回復(fù)</span> </p> {pboot:commentsub} <!-- 調(diào)用子評論 --> <div class="media mt-3 border-top-dashed pt-3"> <img class="mr-3" src="[commentsub:headpic]" height="25"> <div class="media-body"> <h6 class="mt-0"><strong>[commentsub:nickname]</strong> <small style="color:#999">[commentsub:date]</small></h6> <p> @[commentsub:pnickname] [commentsub:comment] <span class="badge badge-light text-secondary font-weight-normal replybtn" data-action="[commentsub:replyaction]">回復(fù)</span> </p> </div> </div> {/pboot:commentsub} </div> </div> {/pboot:comment} <!-- 分頁 --> {pboot:2if({page:rows}>0)} <nav aria-label="page navigation" class="my-4"> <div class="pagination justify-content-center"> <a class="page-item page-link" href="{page:index}#comment">首頁</a> <a class="page-item page-link" href="{page:pre}#comment">上一頁</a> <a class="page-item page-link" href="{page:next}#comment">下一頁</a> <a class="page-item page-link" href="{page:last}#comment">尾頁</a> </div> </nav> {2else} <div class="text-center my-5 text-secondary">未查詢到任何數(shù)據(jù)!</div> {/pboot:2if} </div> </div> <!-- 評論回復(fù)彈框 --> <div class="modal" tabindex="-1" role="dialog" id="reply"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">回復(fù)評論:</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <form onsubmit="return submitcomment(this);" data-action="" id="replyform"> <div class="modal-body"> <div class="form-group"> <textarea name="comment" id="comment" class="form-control" placeholder="請輸入評論內(nèi)容"></textarea> </div> {pboot:2if({pboot:commentcodestatus})} <div class="form-group"> <div class="row"> <div class="col-6"> <input type="text" name="checkcode" required id="checkcode" class="form-control" placeholder="請輸入驗(yàn)證碼"> </div> <div class="col-6"> <img title="點(diǎn)擊刷新" class="codeimg" style="height:33px;" src="{pboot:checkcode}" onclick="this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);" /> </div> </div> </div> {/pboot:2if} </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">關(guān)閉</button> <button type="submit" class="btn btn-info">提交評論</button> </div> </form> </div> </div> </div> <script> //評論回復(fù)彈框 $('.replybtn').on("click",function(){ var url=$(this).data("action"); $("#reply").modal("show"); $("#replyform").data("action",url); }); //提交評論 function submitcomment(obj){ var url= $(obj).data("action"); var comment=$(obj).find("#comment").val(); var checkcode=$(obj).find("#checkcode").val(); $.ajax({ type: 'POST', url: url, dataType: 'json', data: { comment: comment, checkcode: checkcode }, success: function (response, status) { if(response.code){ alert(response.data); $(obj)[0].reset(); $(".modal").modal("hide"); window.location.reload() }else{ if(response.tourl!=""){ if(confirm(response.data+'是否立即跳轉(zhuǎn)登錄?')){ location.href=response.tourl; } } $('.codeimg').click();//更新驗(yàn)證碼 } }, error:function(xhr,status,error){ alert('返回?cái)?shù)據(jù)異常!'); } }); return false; } </script> {/pboot@if}
如果您的問題還未解決可以聯(lián)系站長付費(fèi)協(xié)助。

有問題可以加入技術(shù)QQ群一起交流學(xué)習(xí)
本站vip會員 請加入無憂模板網(wǎng) VIP群(50604020) PS:加入時備注用戶名或昵稱
普通注冊會員或訪客 請加入無憂模板網(wǎng) 技術(shù)交流群(50604130)
客服微信號:15898888535
聲明:本站所有文章資源內(nèi)容,如無特殊說明或標(biāo)注,均為采集網(wǎng)絡(luò)資源。如若內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系站長刪除。