From 6e8327424c4be00182c70e71bf311265cf3f0ccc Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Sat, 7 Jun 2025 15:00:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=B2=A1=E6=9C=89=E8=AF=84=E8=AE=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/Article.php | 15 + app/index/model/ArticleLeaveMessageModel.php | 12 + app/index/view/pc/article/detail.html | 297 +++++++++---------- 3 files changed, 171 insertions(+), 153 deletions(-) diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index 13e0e2e5..46393073 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -99,6 +99,21 @@ class Article extends Common $share_config = $this->getSysConfig($this->lang_id, ['article_share']); View::assign('share_config', $share_config['article_share']); + // 获取文章评论数据 + $comments = ArticleLeaveMessageModel::field([ + 'id', + 'name', + 'email', + 'content', + 'created_at' + ]) + ->article($id) + ->audited(true) + ->order(['id' => 'desc']) + ->limit(5) + ->select(); + View::assign('comments', $comments); + // 获取倒序或发布时间倒序3篇文章做为推荐文章 $recommends = ArticleModel::field([ 'id', diff --git a/app/index/model/ArticleLeaveMessageModel.php b/app/index/model/ArticleLeaveMessageModel.php index 77e40652..793f1c95 100644 --- a/app/index/model/ArticleLeaveMessageModel.php +++ b/app/index/model/ArticleLeaveMessageModel.php @@ -16,4 +16,16 @@ class ArticleLeaveMessageModel extends ArticleLeaveMessageBaseModel use SoftDelete; // 软删除字段 protected $deleteTime = 'deleted_at'; + + // 文章文章范围查询 + public function scopeArticle($query, $article_id) + { + $query->where('article_id', '=', $article_id); + } + + // 审核状态范围查询 + public function scopeAudited($query, bool $is_audited = true) + { + $query->where('is_audited', '=', (int)$is_audited); + } } diff --git a/app/index/view/pc/article/detail.html b/app/index/view/pc/article/detail.html index 7001c60c..abc0b324 100644 --- a/app/index/view/pc/article/detail.html +++ b/app/index/view/pc/article/detail.html @@ -3,170 +3,161 @@ {notempty name="detail.seo_title"}
{$detail.release_time}
-12sdfksdljfksdljdksf是看大家分厘卡聖誕節分厘卡聖誕節付款了
-12sdfksdljfksdljdksf是看大家分厘卡聖誕節分厘卡聖誕節付款了
-12sdfksdljfksdljdksf是看大家分厘卡聖誕節分厘卡聖誕節付款了
-{:lang_i18n('你可能还喜欢')}
-![]()
{$vo.title}
- -{$detail.release_time}
+{$cm.content}
+{:lang_i18n('你可能还喜欢')}
+![]()
{$vo.title}
+ +