diff --git a/app/controller/Article.php b/app/controller/Article.php index 1c4a265..f562b9c 100644 --- a/app/controller/Article.php +++ b/app/controller/Article.php @@ -74,8 +74,9 @@ class Article extends Base case 'products' : $this->assignProducts($topCategory, $category, $categoryChildren); break; + case 'news_center' : case 'news' : - $this->assignNews($topCategory, $category); + $this->assignNews($topCategory, $category, $categoryChildren); break; default : $this->data['items'] = MArticle::getListPageByCategory($category['id'], $category['number'] ? $category['number'] : 20); @@ -88,7 +89,7 @@ class Article extends Base } - // 产品中心 - 展示当前分类和所有子类产品 + // 产品 - 展示当前分类和所有子类产品 private function assignProducts($topCategory, $category, $categoryChildren) { $keyword = input('param.keyword', ''); @@ -101,17 +102,32 @@ class Article extends Base foreach ($children as $child) { $cateIds[] = $child['id']; } - $this->data['items'] = MArticle::getListPageByCategories($cateIds, $category['number'] ? $category['number'] : 20, $keyword); + $items = MArticle::getListPageByCategories($cateIds, $category['number'] ? $category['number'] : 20, $keyword); + $items->appends(['category_id'=>$category['id']]); + $this->data['items'] = $items; + $this->data['keyword'] = $keyword; } // 新闻 - private function assignNews($topCategory, $category) + private function assignNews($topCategory, $category, $categoryChildren) { - - + if($topCategory['id'] == $category['id']) { + // 新闻中心 + $cateList = []; + $newsChildrenFlip = array_flip(Category::$CIdList['news_children']); + foreach ($categoryChildren as $cate) { + $cate['items'] = MArticle::getLatestByCategory($cate['id'], 4); + $cateList[$newsChildrenFlip[$cate['id']]] = $cate; + } + $this->data['cateList'] = $cateList; + } else { + // 新闻子栏目 + $keyword = input('param.keyword', ''); + $category['number'] = 2; + $this->data['items'] = MArticle::getListPageByCategory($category['id'], $category['number'] ? $category['number'] : 20, $keyword); + $this->data['keyword'] = $keyword; + } } - - } \ No newline at end of file diff --git a/app/model/Article.php b/app/model/Article.php index 18d443d..babc195 100644 --- a/app/model/Article.php +++ b/app/model/Article.php @@ -15,7 +15,7 @@ class Article extends Base ->toArray(); } //获取栏目下最新记录 - public static function getLatestByCategory($categoryId, $limit = 5) + public static function getLatestByCategory($categoryId, $limit = 5, $order = []) { if(empty($categoryId)){ return []; @@ -23,8 +23,11 @@ class Article extends Base if($limit <= 0){ $limit = 5; } + if(empty($order)) { + $order = ['create_time' => 'desc']; + } return self::where('category_id', $categoryId) - ->order('create_time', 'desc') + ->order($order) ->limit($limit) ->select() ->toArray(); diff --git a/app/model/Category.php b/app/model/Category.php index 5483b2c..1fa1c78 100644 --- a/app/model/Category.php +++ b/app/model/Category.php @@ -27,11 +27,11 @@ class Category extends Base 'achievement' => 17, // 主要业绩 ], 'achievement_manage' => 30, // 主要业绩管理 - 'news' => 18, //新闻(主) + 'news' => 18, // 新闻动态 'news_children' => [ 'enterprise' => 20, // 企业新闻 'industry' => 21, // 行业资讯 - 'dynamics' => 22, // 新闻动态 + 'dynamics' => 22, // 最新动态 ], ]; diff --git a/public/static/css/style.css b/public/static/css/style.css index e0af9db..e8803e4 100644 --- a/public/static/css/style.css +++ b/public/static/css/style.css @@ -274,7 +274,7 @@ input,select,textarea{outline:medium none; resize: none;} .news-box1 .center-block ul li a{ width: 100%; float: left; margin-top: 3.125rem; border: 0.125rem solid #d7d7d7; background: #fff; padding: 2.5rem;} .news-box1 .center-block ul li a .pull-left{ white-space: nowrap; font-size: 1.25rem; color: #00418f; font-weight: bold; padding-right: 2.5rem;} .news-box1 .center-block ul li a .pull-right{ width: 100%;} -.news-box1 .center-block ul li a .pull-right .imgs{ width: 29%; float: left; height: 10rem; overflow: hidden;} +.news-box1 .center-block ul li a .pull-right .imgs{ width: 29%; float: left; height: 10rem; overflow: hidden; border: 1px solid #f1f1f1;} .news-box1 .center-block ul li a .pull-right .imgs img{ width: 100%; height: 100%; object-fit: cover; transition: all .6s;} .news-box1 .center-block ul li a .pull-right .info{ width: 71%; float: left; padding-left: 2.8125rem;} .news-box1 .center-block ul li a .pull-right .info span{ display: block; font-size: 1.25rem; font-weight: bold; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1;} @@ -294,6 +294,10 @@ input,select,textarea{outline:medium none; resize: none;} .news-box3 .pull-right ul li a{ width: 100%; float: left; line-height: 20px; margin-bottom: 1.5625rem; font-size: 1rem;} .news-box3 .pull-right ul li a span{ width: 70%; float: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;} .news-box3 .pull-right ul li a i{ float: right;} +.news-box3 .more a{ float: right; font-size: 1rem; padding-right: 3.4375rem; line-height: 2.5rem; margin-top: 2.5rem; position: relative; color: #999;} +.news-box3 .more a::after{ content: ''; width: 2.5rem; height: 2.5rem; background: url(../image/icon_jt3.png) no-repeat center; background-size: 100%; position: absolute; right: 0; top: 0; transition: all .6s;} +.news-box3 .more a:hover{ color: #00418f;} +.news-box3 .more a:hover::after{ background-image: url(../image/icon_jt3_1.png);} .news-info{ padding: 10rem 0 6rem;} .news-info .top-box{ border-bottom: 1px solid #9E9E9E; padding-bottom: 1.875rem;} diff --git a/public/static/image/default_bg.jpg b/public/static/image/default_bg.jpg new file mode 100644 index 0000000..ae2f551 Binary files /dev/null and b/public/static/image/default_bg.jpg differ diff --git a/route/app.php b/route/app.php index 7f25354..db02aaf 100644 --- a/route/app.php +++ b/route/app.php @@ -10,10 +10,13 @@ // +---------------------------------------------------------------------- use think\facade\Route; -Route::rule('products', 'article/index')->name('products'); Route::get('article/:id', "article/detail"); Route::get('articles/:category_id', "article/index"); Route::get('page/:category_id', "page/index"); +Route::rule('products', 'article/index')->name('products.search'); // 产品查询 +Route::rule('news', 'article/index')->name('news.search'); // 新闻查询 + + diff --git a/view/article/news.html b/view/article/news.html index 45578a3..d704cee 100644 --- a/view/article/news.html +++ b/view/article/news.html @@ -1,106 +1,48 @@ {layout name="layout" /} -
- {php} - $bgImg = '__IMG__/page_ban1.jpg'; // 默认背景图 - if (isset($category) && !empty(trim($category['src'])) && file_exists('.'.$category['src'])) { - $bgImg = $category.src; - } - {/php} -
-
-
-
-
- {:widget('crumbs/index', ['categoryId' => $categoryId])} -
-
-
- - + +
+
+
+ {$category.title ?? ''} +

{:nl2br($category.description ?? '')}

-
- {if isset($childList) && count($childList) > 0} - {foreach $childList as $child} -
-
{$child['category']['title'] ?? ''}
- {if count($child['items']) > 0} -
    - {foreach $child['items'] as $item} - {php} - if (!empty($item['link'])){ - $url = $item['link']; - $target = 'target="_blank"'; - } else { - $url = url('article/detail', ['id'=>$item['id']]); - $target = ''; - } - $imgSrc = '__IMG__/article_bg.jpg'; - if (!empty(trim($item['src'])) && file_exists('.'.$item['src'])) { - $imgSrc = $item['src']; - } - {/php} +
+ +
+
+ +
+ {if isset($items)} +
+ - {/if} - {/foreach} - - {elseif isset($items) && count($items) > 0 /} - - {/if} +
+
+ {$items->render()|raw} +
+ {/if} +
-
\ No newline at end of file diff --git a/view/article/news_center.html b/view/article/news_center.html new file mode 100644 index 0000000..1102284 --- /dev/null +++ b/view/article/news_center.html @@ -0,0 +1,94 @@ +{layout name="layout"} + + +
+
+
+ {$topCategory.title ?? ''} +

{:nl2br($topCategory.description ?? '')}

+
+
+
+ +
+ + {if isset($cateList['enterprise']) && !empty($cateList['enterprise'])} +
+
+
{$cateList['enterprise']['title'] ?? ''}

{$cateList['enterprise']['description'] ?? ''}

+
+ +
+ +
+
+ {/if} + + {if isset($cateList['industry']) && !empty($cateList['industry'])} +
+
+
{$cateList['industry']['title'] ?? ''}

{$cateList['industry']['description'] ?? ''}

+
+ +
+ +
+
+ {/if} + + {if isset($cateList['dynamics']) && !empty($cateList['dynamics'])} +
+
+
+
{$cateList['dynamics']['title'] ?? ''}

{$cateList['dynamics']['description'] ?? ''}

+
+ +
+
+ +
+
+ {/if} +
diff --git a/view/article/products.html b/view/article/products.html index 92acf52..e18bb58 100644 --- a/view/article/products.html +++ b/view/article/products.html @@ -12,8 +12,8 @@
-
-
+
@@ -31,7 +31,7 @@