diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index 6d7d85b7..52cfadb4 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -20,8 +20,9 @@ class Article extends Common $param = request()->param([ 'pid', 'cid', - 'page/d' => 1, - 'size/d' => 12, + 'keywords' => null, + 'page/d' => 1, + 'size/d' => 12, ]); // 获取banner焦点图 @@ -55,7 +56,10 @@ class Article extends Common 'desc', 'image' ]) + ->withSearch(['title'], ['title' => $param['keywords']??null]) ->category($param['cid']??$categorys[0]['id']) + ->where('release_time', '<=', date('Y-m-d H:i:s')) + ->order(['sort' => 'asc', 'release_time' => 'desc', 'id' => 'desc']) ->paginate([ 'list_rows' => $param['size'], 'page' => $param['page'], @@ -71,6 +75,29 @@ class Article extends Common */ public function detail() { + $id = request()->param('id'); + $detail = ArticleModel::withoutField([ + 'created_at', + 'updated_at', + 'deleted_at' + ]) + ->bypk($id) + ->find(); + View::assign('detail', $detail); + // 获取倒序或发布时间倒序3篇文章做为推荐文章 + $recommends = ArticleModel::field([ + 'id', + 'title', + 'desc', + 'image' + ]) + ->where('id', '<>', $id) + ->order(['release_time' => 'desc', 'id' => 'desc']) + ->limit(3) + ->select(); + View::assign('recommends', $recommends); + + return View::fetch('detail'); } } diff --git a/app/index/lang/en-us.php b/app/index/lang/en-us.php index 75fa39c3..81f3cb94 100644 --- a/app/index/lang/en-us.php +++ b/app/index/lang/en-us.php @@ -21,5 +21,15 @@ return [ 'faq' => 'FAQ', 'faq_short_desc' => 'What are you most concerned about', 'faq_desc' => 'Our customer support is available Manday to Friday 9am600pmAverage arswer time 24h', + ], + 'article' => [ + 'detail_share' => 'SHARE', + 'detail_leave_reply' => 'Leave a Reply', + 'detail_leave_reply_name' => 'Name', + 'detail_leave_reply_email' => 'Email', + 'detail_leave_reply_email_tip' => 'Your email address will not be pulished.', + 'detail_leave_reply_comment' => 'Comment', + 'detail_leave_reply_submit' => 'POST COMMENT', + 'detail_recommend' => 'Recommended for you', ] ]; \ No newline at end of file diff --git a/app/index/lang/zh-cn.php b/app/index/lang/zh-cn.php index 3ad53f3b..14e93584 100644 --- a/app/index/lang/zh-cn.php +++ b/app/index/lang/zh-cn.php @@ -21,5 +21,15 @@ return [ 'faq' => '常见问题', 'faq_short_desc' => '回答您最关心的问题', 'faq_desc' => '客服团队的工作时间:周一到周五,早9点到晚6点 平均应答时间:24小时内', + ], + 'article' => [ + 'detail_share' => '分享', + 'detail_leave_reply' => '留言', + 'detail_leave_reply_name' => '名称', + 'detail_leave_reply_email' => '电子邮箱', + 'detail_leave_reply_email_tip' => '您的电子邮件地址不会被公开', + 'detail_leave_reply_comment' => '留言', + 'detail_leave_reply_submit' => '提交留言', + 'detail_recommend' => '你可能还喜欢', ] ]; \ No newline at end of file diff --git a/app/index/model/ArticleModel.php b/app/index/model/ArticleModel.php index 8903d51f..03b173da 100644 --- a/app/index/model/ArticleModel.php +++ b/app/index/model/ArticleModel.php @@ -20,18 +20,25 @@ class ArticleModel extends ArticleBaseModel // 语言范围查询 public function scopeLanguage($query, $language) { - return $query->where('language_id', '=', $language); + $query->where('language_id', '=', $language); } // 首页推荐状态范围查询 public function scopeRecommend($query, bool $stat = true) { - return $query->where('recommend', '=', (int)$stat); + $query->where('recommend', '=', (int)$stat); } // 文章分类范围查询 public function scopeCategory($query, $category) { - return $query->where('category_id', '=', $category); + $query->where('category_id', '=', $category); + } + + // 文章标题搜索器 + public function searchTitleAttr($query, $value) + { + if (is_null($value)) return; + $query->where('title', 'like', "%$value%"); } } diff --git a/app/index/view/article/detail.html b/app/index/view/article/detail.html new file mode 100644 index 00000000..ce450117 --- /dev/null +++ b/app/index/view/article/detail.html @@ -0,0 +1,84 @@ +{extend name="public/base" /} +{block name="title"} + {notempty name="detail.seo_title"}{$detail.seo_title}{else /}{__BLOCK__}{/notempty} +{/block} +{block name="seo"} + {notempty name="detail.seo_keywords"} + + + {else /} + {__BLOCK__} + {/notempty} +{/block} +{block name="style"} + +{/block} +{block name="main"} +
+ +
+
+
+

{$detail.title}

+

{$detail.desc}

+
+ +
{$detail.content|raw}
+
+
+
+

{:lang('article.detail_share')}

+ +
+
+

{:lang('article.detail_leave_reply')}

+
+ {:lang('article.detail_leave_reply_name')} + + {:lang('article.detail_leave_reply_email')} + +

{:lang('article.detail_leave_reply_email_tip')}

+ {:lang('article.detail_leave_reply_comment')} + +
{:lang('article.detail_leave_reply_submit')}
+
+
+
+
+ {notempty name="$recommends"} +
+ +
+
+

{:lang('article.detail_recommend')}

+

+
+ +
+
+ {/notempty} +
+{/block} \ No newline at end of file diff --git a/app/index/view/article/index.html b/app/index/view/article/index.html index 75145378..3359967d 100644 --- a/app/index/view/article/index.html +++ b/app/index/view/article/index.html @@ -21,8 +21,10 @@
- - +
+ + +
{notempty name="articles"} @@ -30,7 +32,7 @@
{volist name="articles" id="ar"}
- +

{$ar.title}

{$ar.desc}

@@ -44,7 +46,4 @@ {/notempty}
-{/block} -{block name="script"} - {/block} \ No newline at end of file diff --git a/public/static/index/css/articleDetail.css b/public/static/index/css/articleDetail.css index 03a31f15..70d3ed88 100755 --- a/public/static/index/css/articleDetail.css +++ b/public/static/index/css/articleDetail.css @@ -1,7 +1,8 @@ .orico_Page_articleDetail { width: 100%; position: relative; - height: 100vh; + min-height: 100vh; + padding: 3.75rem 0; overflow-y: auto; overflow-x: hidden; background: #f2f2f2; diff --git a/public/static/index/images/1line.png b/public/static/index/images/1line.png new file mode 100755 index 00000000..648af2f8 Binary files /dev/null and b/public/static/index/images/1line.png differ diff --git a/public/static/index/images/search.png b/public/static/index/images/search.png new file mode 100755 index 00000000..3d39a1db Binary files /dev/null and b/public/static/index/images/search.png differ diff --git a/public/static/index/images/share1.png b/public/static/index/images/share1.png new file mode 100755 index 00000000..fc77bcee Binary files /dev/null and b/public/static/index/images/share1.png differ diff --git a/public/static/index/images/share2.png b/public/static/index/images/share2.png new file mode 100755 index 00000000..e7b3727e Binary files /dev/null and b/public/static/index/images/share2.png differ diff --git a/public/static/index/images/share3.png b/public/static/index/images/share3.png new file mode 100755 index 00000000..d5ee3ef0 Binary files /dev/null and b/public/static/index/images/share3.png differ diff --git a/public/static/index/images/share4.png b/public/static/index/images/share4.png new file mode 100755 index 00000000..04cdfca4 Binary files /dev/null and b/public/static/index/images/share4.png differ