From f8da74af198d52a91b7e7d09cd147076274f02af Mon Sep 17 00:00:00 2001 From: xuanchen <122383162@qq.com> Date: Mon, 7 Dec 2020 15:36:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=A7=E5=BA=86=E5=88=86?= =?UTF-8?q?=E9=99=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Helpers/function.php | 252 +++++++++++++------------- resources/views/index/index.blade.php | 163 ++++++++--------- 2 files changed, 205 insertions(+), 210 deletions(-) diff --git a/app/Helpers/function.php b/app/Helpers/function.php index c8f8369..aa51933 100644 --- a/app/Helpers/function.php +++ b/app/Helpers/function.php @@ -1,126 +1,126 @@ -{$return}; - } - - return $category; - } - - return new Category; -} - -/** - * Notes: 获取文章分类详情 - * @Author: 玄尘 - * @Date : 2020/9/10 13:21 - * @param $categoryId - * @param string $result - * @return \App\Models\Article - */ -function getOneArticleBYCate($categoryId, $result = '') -{ - $info = Article::where('category_id', $categoryId)->latest('sort')->latest()->first(); - - if ($info) { - if ($result) { - return $info->{$result}; - } - - return $info; - } else { - return ''; - } - - return new Article; -} - -/** - * Notes: 获取分类下的文章 - * @Author: 玄尘 - * @Date : 2020/9/10 10:05 - * @param $categoryId - * @param $take - * @return \App\Models\Article - */ -function getArticlesBYCate($categoryId, $take = 8, $mark = 'one') -{ - if ($mark == 'one') { - $articles = Article::where('category_id', $categoryId) - ->where('status', 1) - ->latest('sort') - ->latest() - ->take($take) - ->get(); - } else { - $cate = Category::find($categoryId); - $ids = $cate->getAllChildrenId(); - - $articles = Article::whereIn('category_id', $ids) - ->where('status', 1) - ->latest('sort') - ->latest() - ->take($take) - ->get(); - } - - return $articles; -} - -//获取子分类 -function getCateChild($categoryId) -{ - return Category::where('status', 1) - ->where('parent_id', $categoryId) - ->orderBy('order', 'asc') - ->get(); -} - -//获取顶级分类 -function getTopCate($categoryId) -{ - $parent = Category::find($categoryId); - - while ($parent->parent_id != 0) { - $parent = $parent->parent; - } - - return $parent; -} - -//获取一个广告 -function getOneAdvertByCate($categoryId, $result = '') -{ - $info = Advert::where('category_id', $categoryId) - ->latest('sort') - ->latest() - ->first(); - if ($info) { - if ($result) { - return $info->{$result}; - } - - return $info; - } else { - return ''; - } - - return new Advert; -} - -function getAdvertsByCate($categoryId, $take = 8) -{ - return Advert::where('category_id', $categoryId) - ->latest('sort') - ->latest() - ->take($take)->get(); -} - +{$return}; + } + + return $category; + } + + return new Category; +} + +/** + * Notes: 获取文章分类详情 + * @Author: 玄尘 + * @Date : 2020/9/10 13:21 + * @param $categoryId + * @param string $result + * @return \App\Models\Article + */ +function getOneArticleBYCate($categoryId, $result = '') +{ + $info = Article::where('category_id', $categoryId)->latest('sort')->latest()->first(); + + if ($info) { + if ($result) { + return $info->{$result}; + } + + return $info; + } else { + return ''; + } + + return new Article; +} + +/** + * Notes: 获取分类下的文章 + * @Author: 玄尘 + * @Date : 2020/9/10 10:05 + * @param $categoryId + * @param $take + * @return \App\Models\Article + */ +function getArticlesBYCate($categoryId, $take = 8, $mark = 'one') +{ + if ($mark == 'one') { + $articles = Article::where('category_id', $categoryId) + ->where('status', 1) + ->latest('sort') + ->latest() + ->take($take) + ->get(); + } else { + $cate = Category::find($categoryId); + $ids = $cate->getAllChildrenId(); + + $articles = Article::whereIn('category_id', $ids) + ->where('status', 1) + ->latest('sort') + ->latest() + ->take($take) + ->get(); + } + + return $articles; +} + +//获取子分类 +function getCateChild($categoryId) +{ + return Category::where('status', 1) + ->where('parent_id', $categoryId) + ->orderBy('order', 'asc') + ->get(); +} + +//获取顶级分类 +function getTopCate($categoryId) +{ + $parent = Category::find($categoryId); + + while ($parent->parent_id != 0) { + $parent = $parent->parent; + } + + return $parent; +} + +//获取一个广告 +function getOneAdvertByCate($categoryId, $result = '') +{ + $info = Advert::where('category_id', $categoryId) + ->latest('sort') + ->latest() + ->first(); + if ($info) { + if ($result) { + return $info->{$result}; + } + + return $info; + } else { + return ''; + } + + return new Advert; +} + +function getAdvertsByCate($categoryId, $take = 8) +{ + return Advert::where('category_id', $categoryId) + ->latest('sort') + ->latest() + ->take($take)->get(); +} + diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index baac99a..8ccee90 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -83,20 +83,22 @@
- {{ getOneCategory(10,'title') }} - {{ getOneCategory(9,'title') }} + {{-- 党政建设--}} + {{ getOneCategory(4,'title') }} + {{-- 媒体报道--}} + {{ getOneCategory(17,'title') }}
+
- {{ getOneCategory(12,'title') }} - /  {{ getOneCategory(12,'description') }} - 更多 + {{-- 交流合作--}} + {{ getOneCategory(5,'title') }} + /  Exchange and cooperation + 更多
    - @if (getArticlesBYCate(12,3)->isNotEmpty()) - @foreach (getArticlesBYCate(12,3) as $article) + @if (getArticlesBYCate(5,3)->isNotEmpty()) + @foreach (getArticlesBYCate(5,3) as $article)
  • {{ $article->title }}

    -

    - {{ $article->description }} -

    +

    {{ $article->description }}

  • @endforeach @@ -159,8 +161,8 @@ {{ getOneCategory(13,'title') }} {{ getOneCategory(15,'title') }} {{ getOneCategory(14,'title') }} - {{ getOneCategory(17,'title') }} - {{ getOneCategory(16,'title') }} + {{-- {{ getOneCategory(17,'title') }}--}} + {{-- {{ getOneCategory(16,'title') }} --}} {{-- 更多--}}
@@ -170,10 +172,11 @@ @foreach (getArticlesBYCate(13,4) as $article)
  • - -

    {{ $article->created_at->format('d') }}

    -

    {{ $article->created_at->format('Y-m') }}

    -
    + + + +

    {{ $article->title }}

    {{ $article->description }}

    @@ -183,12 +186,12 @@ - - - -
  • -
    - {{ getOneCategory(18,'title') }} - /  {{ getOneCategory(18,'description') }} - 更多 +
    + {{ getOneCategory(18,'title') }} + {{ getOneCategory(16,'title') }} + {{-- 更多--}} +
    +
    + + + + +
    -
    @@ -300,5 +286,14 @@ $("#informationContent .tabs-content").eq($(this).index()).addClass("active").siblings().removeClass("active") }) }); + + //项目推广 + $(function () { + $('#patentTab .tabs-item').hover(function () { + $(this).addClass("show").siblings().removeClass("show") + $("#patentTabContent .tabs-content").eq($(this).index()).addClass("active").siblings().removeClass("active") + }) + }); + @endpush