From 154842d92dc856aca86bee01d1e3ce00bf0d6510 Mon Sep 17 00:00:00 2001
From: "DESKTOP-4RNDQIC\\29019" <290198252@qq.com>
Date: Mon, 13 Apr 2020 18:14:56 +0800
Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E7=95=8C=E9=9D=A2=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E8=AF=84=E8=AE=BA=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
App/Controllers/Blog.php | 5 +-
App/Controllers/DocComment.php | 5 ++
App/Models/DocComment.php | 5 ++
App/Views/blog/basic.html | 113 +++++++++++++++++++++++++++++++++
App/Views/blog/css/comment.css | 103 ++++++++++++++++++++++++++++++
App/Views/blog/js/comment.js | 77 ++++++++++++++++++++++
6 files changed, 307 insertions(+), 1 deletion(-)
create mode 100644 App/Views/blog/css/comment.css
create mode 100644 App/Views/blog/js/comment.js
diff --git a/App/Controllers/Blog.php b/App/Controllers/Blog.php
index e0dce5c..02f518b 100644
--- a/App/Controllers/Blog.php
+++ b/App/Controllers/Blog.php
@@ -37,11 +37,14 @@ class Blog extends Controller
if(sizeof($this->querys) != 0){
echo '
';
$docModel = new Models\Doc();
+ $commentModel = new Models\DocComment();
$doc = $docModel->titleDoc(rawurldecode( $this->querys['title']));
+ $id = $doc[0]["id"];
$markdown = new Parsedown;
$content = $markdown->text($doc[0]['content']);
$typedocs = $docModel->getAllTypeDocs();
-
+ $doccoment = $commentModel->DocComments($id);
+ var_dump($doccoment);
echo '
';
if(\App\Config::$DEBUG)
View::renderTemplate("/blog/basic.html",
diff --git a/App/Controllers/DocComment.php b/App/Controllers/DocComment.php
index b3e9d2c..fd342f3 100644
--- a/App/Controllers/DocComment.php
+++ b/App/Controllers/DocComment.php
@@ -20,4 +20,9 @@ class DocComment extends Controller
$comment->InsertObject($this->input);
//$this->JsonResp(200,$all,"OK");
}
+ public function getDocCommentAction(){
+ $comment = new Models\DocComment();
+ var_dump($this->input);
+ var_dump($comment->DocComments(1));
+ }
}
\ No newline at end of file
diff --git a/App/Models/DocComment.php b/App/Models/DocComment.php
index be6c079..31cf0e5 100644
--- a/App/Models/DocComment.php
+++ b/App/Models/DocComment.php
@@ -13,4 +13,9 @@ class DocComment extends Model
{
return parent::InsertObject($obj); // TODO: Change the autogenerated stub
}
+ function DocComments($docid){
+ $db = static::getDB();
+ $stmt = $db->query('SELECT * FROM doc_comment where doc_comment.doc_id = '.strval($docid));
+ return $stmt->fetchAll();
+ }
}
\ No newline at end of file
diff --git a/App/Views/blog/basic.html b/App/Views/blog/basic.html
index 13b6767..ed8a09d 100644
--- a/App/Views/blog/basic.html
+++ b/App/Views/blog/basic.html
@@ -5,8 +5,10 @@
crystal blue
+
+
@@ -220,6 +222,117 @@ ul li a{
word-break: break-all; word-wrap:break-word;">
{{ content | raw}}
+
+
{% endif %}
{% if donate == true %}
diff --git a/App/Views/blog/css/comment.css b/App/Views/blog/css/comment.css
new file mode 100644
index 0000000..d68bb40
--- /dev/null
+++ b/App/Views/blog/css/comment.css
@@ -0,0 +1,103 @@
+.comment-filed{
+ width:640px;
+ margin-left: 20px;
+ margin-top: 50px;
+
+}
+
+.comment-num{
+ text-align: right;
+ font-size:14px;
+}
+.div-txt-submit{
+ text-align:right;
+ margin-top:8px;
+
+}
+
+.comment-submit{
+ background-color:#63B8FF;
+ margin-top:15px;
+ text-decoration:none;
+ color:#fff;
+ padding:5px;
+ font-size:14px;
+}
+
+.txt-commit{
+ border:1px solid blue;
+ width:620px;
+ height: 60px;
+ padding: 10px;
+}
+
+.txt-reply{
+ width: 100%;
+ height: 60px;
+}
+
+
+
+.comment-filed-list{
+ margin-top:20px;
+}
+
+.comment-list{
+ margin-top:2px;
+ width:herit;
+ height:50px;
+ border-top:1px solid gray;
+}
+
+.comment-ul{
+ list-style:none;
+ padding-left:0;
+}
+
+.head-pic{
+ width:40px;
+ height:40px;
+}
+
+.cm{
+ position:relative;
+ top:0px;
+ left:40px;
+ top:-40px;
+ width:600px;
+}
+
+.cm-header{
+ padding-left:5px;
+}
+
+.cm-content{
+ padding-left:5px;
+}
+
+.cm-footer{
+ padding-bottom:15px;
+ text-align:right;
+ border-bottom: 1px dotted #CCC;
+}
+
+.comment-reply{
+ text-decoration:none;
+ color:gray;
+ font-size: 14px;
+}
+
+.children{
+ list-style:none;
+ background-color:#FAFAFA;
+ padding-left:0;
+ margin-left:40px;
+}
+
+.children-cm{
+ position:relative;
+ left:40px;
+ top:-40px;
+ width:90%;
+}
+
diff --git a/App/Views/blog/js/comment.js b/App/Views/blog/js/comment.js
new file mode 100644
index 0000000..07061c9
--- /dev/null
+++ b/App/Views/blog/js/comment.js
@@ -0,0 +1,77 @@
+$(function(){
+
+ //点击提交评论内容
+ $('body').delegate('.comment-submit','click',function(){
+ var content = $.trim($(this).parent().prev().children("textarea").val());//根据布局结构获取当前评论内容
+ $(this).parent().prev().children("textarea").val("");//获取完内容后清空输入框
+ if(""==content){
+ alert("评论内容不能为空!");
+ }else{
+ var cmdata = new Object();
+ cmdata.parent_id = $(this).attr("parent_id");//上级评论id
+ cmdata.content = content;
+ cmdata.nickname = "游客";//测试用数据
+ cmdata.head_pic = "/Public/images/default.jpg";//测试用数据
+ var replyswitch = $(this).attr("replyswitch");//获取回复开关锁属性
+ $.ajax({
+ type:"POST",
+ url:"/index.php/home/index/addComment",
+ data:{
+ comment:JSON.stringify(cmdata)
+ },
+ dataType:"json",
+ success:function(data){
+ if(typeof(data.error)=="undefined"){
+ $(".comment-reply").next().remove();//删除已存在的所有回复div
+ //更新评论总数
+ $(".comment-num").children("span").html(data.num+"条评论");
+ //显示新增评论
+ var newli = "";
+ if(cmdata.parent_id == "0"){
+ //发表的是一级评论时,添加到一级ul列表中
+ newli = "";
+ $(".comment-ul").prepend(newli);
+ }else{
+ //否则添加到对应的孩子ul列表中
+ if('off'==replyswitch){//检验出回复关闭锁存在,即三级评论不再提供回复功能
+ newli = "";
+ }else{//二级评论的回复按钮要添加回复关闭锁属性
+ newli = "";
+ }
+ $("li[comment_id='"+data.parent_id+"']").children("ul").prepend(newli);
+ }
+
+ }else{
+ //有错误信息
+ alert(data.error);
+ }
+
+ }
+ });
+ }
+
+
+ });
+
+
+
+ //点击"回复"按钮显示或隐藏回复输入框
+ $("body").delegate(".comment-reply","click",function(){
+ if($(this).next().length>0){//判断出回复div已经存在,去除掉
+ $(this).next().remove();
+ }else{//添加回复div
+ $(".comment-reply").next().remove();//删除已存在的所有回复div
+ //添加当前回复div
+ var parent_id = $(this).attr("comment_id");//要回复的评论id
+
+ var divhtml = "";
+ if('off'==$(this).attr("replyswitch")){//二级评论回复后三级评论不再提供回复功能,将关闭属性附加到"提交回复"按钮"
+ divhtml = "";
+ }else{
+ divhtml = "";
+ }
+ $(this).after(divhtml);
+ }
+ });
+
+})
\ No newline at end of file
+
+ -
+
+
+
+
+
+
+ {$data.nickname}
+ {$data.create_time}
+
+
+
+
+ 回复
+
+
+
+
+
+
+
+
+ ++ {$data.content} +
++
+ -
+
+
+
+
+
+
+ {$child.nickname}
+ {$child.create_time}
+
+
+
+
+ 回复
+
+
+
+
+
+
+
+
+ + ++ {$child.content} +
++
+ -
+
+
+
+
+
+
+ {$grandson.nickname}
+ {$grandson.create_time}
+
+
+
+
+
+
+
+
+
+
+
+ + ++ {$grandson.content} +
+