comment.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. {pboot:if({pboot:commentstatus})}
  2. <div class="container">
  3. <div class="shadow-sm p-3 my-5 bg-white rounded">
  4. <h4>发表评论:</h4>
  5. <form class="my-4" onsubmit="return submitcomment(this);" data-action="{pboot:commentaction}" >
  6. <div class="form-group">
  7. <textarea name="comment" id="comment" class="form-control" placeholder="请输入评论内容"></textarea>
  8. </div>
  9. {pboot:2if({pboot:commentcodestatus})}
  10. <div class="form-group">
  11. <div class="row">
  12. <div class="col-6 col-md-3">
  13. <input type="text" name="checkcode" required id="checkcode" class="form-control" placeholder="请输入验证码">
  14. </div>
  15. <div class="col-6 col-md-3">
  16. <img title="点击刷新" class="codeimg" style="height:33px;" src="{pboot:checkcode}" onclick="this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);" />
  17. </div>
  18. </div>
  19. </div>
  20. {/pboot:2if}
  21. <div class="form-group">
  22. <button type="submit" class="btn btn-info mb-2">提交评论</button>
  23. </div>
  24. </form>
  25. <h4>评论记录:</h4>
  26. <a name="comment"></a>
  27. {pboot:comment contentid={content:id} num=20}
  28. <div class="media border-bottom pb-3 pt-3">
  29. <img class="mr-3" src="[comment:headpic]" height="25">
  30. <div class="media-body">
  31. <h6 class="mt-0">
  32. <strong>[comment:nickname]</strong>
  33. <small style="color:#999">[comment:date]</small>
  34. </h6>
  35. <p>[comment:comment]
  36. <span class="badge badge-light text-secondary font-weight-normal replybtn" data-action="[comment:replyaction]">回复</span>
  37. </p>
  38. {pboot:commentsub} <!-- 调用子评论 -->
  39. <div class="media mt-3 border-top-dashed pt-3">
  40. <img class="mr-3" src="[commentsub:headpic]" height="25">
  41. <div class="media-body">
  42. <h6 class="mt-0"><strong>[commentsub:nickname]</strong> <small style="color:#999">[commentsub:date]</small></h6>
  43. <p>
  44. @[commentsub:pnickname] [commentsub:comment]
  45. <span class="badge badge-light text-secondary font-weight-normal replybtn" data-action="[commentsub:replyaction]">回复</span>
  46. </p>
  47. </div>
  48. </div>
  49. {/pboot:commentsub}
  50. </div>
  51. </div>
  52. {/pboot:comment}
  53. <!-- 分页 -->
  54. {pboot:2if({page:rows}>0)}
  55. <nav aria-label="page navigation" class="my-4">
  56. <div class="pagination justify-content-center">
  57. <a class="page-item page-link" href="{page:index}#comment">首页</a>
  58. <a class="page-item page-link" href="{page:pre}#comment">上一页</a>
  59. <a class="page-item page-link" href="{page:next}#comment">下一页</a>
  60. <a class="page-item page-link" href="{page:last}#comment">尾页</a>
  61. </div>
  62. </nav>
  63. {2else}
  64. <div class="text-center my-5 text-secondary">未查询到任何数据!</div>
  65. {/pboot:2if}
  66. </div>
  67. </div>
  68. <!-- 评论回复弹框 -->
  69. <div class="modal" tabindex="-1" role="dialog" id="reply">
  70. <div class="modal-dialog">
  71. <div class="modal-content">
  72. <div class="modal-header">
  73. <h5 class="modal-title">回复评论:</h5>
  74. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  75. <span aria-hidden="true">&times;</span>
  76. </button>
  77. </div>
  78. <form onsubmit="return submitcomment(this);" data-action="" id="replyform">
  79. <div class="modal-body">
  80. <div class="form-group">
  81. <textarea name="comment" id="comment" class="form-control" placeholder="请输入评论内容"></textarea>
  82. </div>
  83. {pboot:2if({pboot:commentcodestatus})}
  84. <div class="form-group">
  85. <div class="row">
  86. <div class="col-6">
  87. <input type="text" name="checkcode" required id="checkcode" class="form-control" placeholder="请输入验证码">
  88. </div>
  89. <div class="col-6">
  90. <img title="点击刷新" class="codeimg" style="height:33px;" src="{pboot:checkcode}" onclick="this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);" />
  91. </div>
  92. </div>
  93. </div>
  94. {/pboot:2if}
  95. </div>
  96. <div class="modal-footer">
  97. <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
  98. <button type="submit" class="btn btn-info">提交评论</button>
  99. </div>
  100. </form>
  101. </div>
  102. </div>
  103. </div>
  104. <script>
  105. //评论回复弹框
  106. $('.replybtn').on("click",function(){
  107. var url=$(this).data("action");
  108. $("#reply").modal("show");
  109. $("#replyform").data("action",url);
  110. });
  111. //提交评论
  112. function submitcomment(obj){
  113. var url= $(obj).data("action");
  114. var comment=$(obj).find("#comment").val();
  115. var checkcode=$(obj).find("#checkcode").val();
  116. $.ajax({
  117. type: 'POST',
  118. url: url,
  119. dataType: 'json',
  120. data: {
  121. comment: comment,
  122. checkcode: checkcode
  123. },
  124. success: function (response, status) {
  125. if(response.code){
  126. alert(response.data);
  127. $(obj)[0].reset();
  128. $(".modal").modal("hide");
  129. window.location.reload()
  130. }else{
  131. if(response.tourl!=""){
  132. if(confirm(response.data+'是否立即跳转登录?')){
  133. location.href=response.tourl;
  134. }
  135. }
  136. $('.codeimg').click();//更新验证码
  137. }
  138. },
  139. error:function(xhr,status,error){
  140. alert('返回数据异常!');
  141. }
  142. });
  143. return false;
  144. }
  145. </script>
  146. {/pboot:if}