修改大庆分院
This commit is contained in:
@@ -1,126 +1,126 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Advert;
|
||||
use App\Models\Category;
|
||||
use App\Models\Article;
|
||||
|
||||
function getOneCategory($categoryId, $return = '')
|
||||
{
|
||||
$category = Category::find($categoryId);
|
||||
if ($category) {
|
||||
if ($return) {
|
||||
return $category->{$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();
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
use App\Models\Advert;
|
||||
use App\Models\Category;
|
||||
use App\Models\Article;
|
||||
|
||||
function getOneCategory($categoryId, $return = '')
|
||||
{
|
||||
$category = Category::find($categoryId);
|
||||
if ($category) {
|
||||
if ($return) {
|
||||
return $category->{$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();
|
||||
}
|
||||
|
||||
|
||||
@@ -83,20 +83,22 @@
|
||||
<div class="news">
|
||||
<div class="news-item party">
|
||||
<div class="tabs-title" id="information">
|
||||
<span class="tabs-item show">{{ getOneCategory(10,'title') }}</span>
|
||||
<span class="tabs-item">{{ getOneCategory(9,'title') }}</span>
|
||||
{{-- 党政建设--}}
|
||||
<span class="tabs-item show">{{ getOneCategory(4,'title') }}</span>
|
||||
{{-- 媒体报道--}}
|
||||
<span class="tabs-item"> {{ getOneCategory(17,'title') }}</span>
|
||||
</div>
|
||||
<div class="tabs-content-wrapper" id="informationContent">
|
||||
<!-- 国内资讯 -->
|
||||
<ul class="party-ul tabs-content active">
|
||||
@if (getArticlesBYCate(10,3)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(10,3) as $article)
|
||||
@if (getArticlesBYCate(4,3)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(4,3) as $article)
|
||||
<li class="party-ul-li">
|
||||
<a href="{{ $article->link }}">
|
||||
<span class="party-time">
|
||||
<h3>{{ $article->created_at->format('d') }}</h3>
|
||||
<p>{{ $article->created_at->format('Y-m') }}</p>
|
||||
</span>
|
||||
<span class="party-time">
|
||||
<h3>{{ $article->created_at->format('d') }}</h3>
|
||||
<p>{{ $article->created_at->format('Y-m') }}</p>
|
||||
</span>
|
||||
<h3 class="party-title nowrap">{{ $article->title }}</h3>
|
||||
<p class="party-info nowrap-multi">{{ $article->description }}</p>
|
||||
</a>
|
||||
@@ -105,15 +107,16 @@
|
||||
@endif
|
||||
</ul>
|
||||
|
||||
<!-- 媒体报道 -->
|
||||
<ul class="party-ul tabs-content">
|
||||
@if (getArticlesBYCate(9,12)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(9,12) as $article)
|
||||
@if (getArticlesBYCate(17,12)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(17,12) as $article)
|
||||
<li class="party-ul-li">
|
||||
<a href="{{ $article->link }}">
|
||||
<span class="party-time">
|
||||
<h3>{{ $article->created_at->format('d') }}</h3>
|
||||
<p>{{ $article->created_at->format('Y-m') }}</p>
|
||||
</span>
|
||||
<span class="party-time">
|
||||
<h3>{{ $article->created_at->format('d') }}</h3>
|
||||
<p>{{ $article->created_at->format('Y-m') }}</p>
|
||||
</span>
|
||||
<h3 class="party-title nowrap">{{ $article->title }}</h3>
|
||||
<p class="party-info nowrap-multi">{{ $article->description }}</p>
|
||||
</a>
|
||||
@@ -125,19 +128,18 @@
|
||||
</div>
|
||||
<div class="news-item spirit">
|
||||
<div class="mian-title">
|
||||
<b>{{ getOneCategory(12,'title') }}</b>
|
||||
<span>/ {{ getOneCategory(12,'description') }}</span>
|
||||
<a class="mian-title-more" href="{{ getOneCategory(12,'link') }}">更多<i class="fa fa-angle-right"></i></a>
|
||||
{{-- 交流合作--}}
|
||||
<b>{{ getOneCategory(5,'title') }}</b>
|
||||
<span>/ <!-- {{ getOneCategory(5,'description') }} -->Exchange and cooperation</span>
|
||||
<a class="mian-title-more" href="{{ getOneCategory(5,'link') }}">更多<i class="fa fa-angle-right"></i></a>
|
||||
</div>
|
||||
<ul class="spiritual-ul">
|
||||
@if (getArticlesBYCate(12,3)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(12,3) as $article)
|
||||
@if (getArticlesBYCate(5,3)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(5,3) as $article)
|
||||
<li class="spiritual-ul-li">
|
||||
<a href="{{ $article->link }}">
|
||||
<h3 class="spiritual-title nowrap">{{ $article->title }}</h3>
|
||||
<p class="spiritual-info nowrap-multi">
|
||||
{{ $article->description }}
|
||||
</p>
|
||||
<p class="spiritual-info nowrap-multi">{{ $article->description }}</p>
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
@@ -159,8 +161,8 @@
|
||||
<span class="tabs-item show">{{ getOneCategory(13,'title') }}</span>
|
||||
<span class="tabs-item">{{ getOneCategory(15,'title') }}</span>
|
||||
<span class="tabs-item">{{ getOneCategory(14,'title') }}</span>
|
||||
<span class="tabs-item">{{ getOneCategory(17,'title') }}</span>
|
||||
<span class="tabs-item">{{ getOneCategory(16,'title') }}</span>
|
||||
{{-- <span class="tabs-item">{{ getOneCategory(17,'title') }}</span>--}}
|
||||
{{-- <span class="tabs-item">{{ getOneCategory(16,'title') }}</span> --}}
|
||||
{{-- <a class="mian-title-more" href="">更多<i class="fa fa-angle-right"></i></a>--}}
|
||||
</div>
|
||||
<div class="tabs-content-wrapper" id="newsTabContent">
|
||||
@@ -170,10 +172,11 @@
|
||||
@foreach (getArticlesBYCate(13,4) as $article)
|
||||
<li class="party-ul-li">
|
||||
<a href="{{ $article->link }}">
|
||||
<span class="party-time">
|
||||
<h3>{{ $article->created_at->format('d') }}</h3>
|
||||
<p>{{ $article->created_at->format('Y-m') }}</p>
|
||||
</span>
|
||||
<span class="party-img">
|
||||
<!-- <h3>{{ $article->created_at->format('d') }}</h3>
|
||||
<p>{{ $article->created_at->format('Y-m') }}</p> -->
|
||||
</span><span class="party-img party-cover" style="background-image:url({{ $article->cover_path }})">
|
||||
</span>
|
||||
<h3 class="party-title nowrap">{{ $article->title }}</h3>
|
||||
<p class="party-info nowrap-multi">{{ $article->description }}</p>
|
||||
</a>
|
||||
@@ -183,12 +186,12 @@
|
||||
</ul>
|
||||
<!-- 梯队人才 -->
|
||||
<ul class="party-ul tabs-content">
|
||||
@if (getArticlesBYCate(13,4)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(13,4) as $article)
|
||||
@if (getArticlesBYCate(15,4)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(15,4) as $article)
|
||||
<li class="party-ul-li">
|
||||
<a href="{{ $article->link }}">
|
||||
<span class="party-time party-cover" style="background-image:url({{ $article->cover_path }})">
|
||||
</span>
|
||||
<span class="party-img party-cover" style="background-image:url({{ $article->cover_path }})">
|
||||
</span>
|
||||
<h3 class="party-title nowrap">{{ $article->title }}</h3>
|
||||
<p class="party-info nowrap-multi">{{ $article->description }}</p>
|
||||
</a>
|
||||
@@ -203,42 +206,8 @@
|
||||
@foreach (getArticlesBYCate(14,4) as $article)
|
||||
<li class="party-ul-li">
|
||||
<a href="{{ $article->link }}">
|
||||
<span class="party-time party-cover" style="background-image:url({{ $article->cover_path }})">
|
||||
</span>
|
||||
<h3 class="party-title nowrap">{{ $article->title }}</h3>
|
||||
<p class="party-info nowrap-multi">{{ $article->description }}</p>
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
@endif
|
||||
</ul>
|
||||
<!-- 项目推广 -->
|
||||
<ul class="party-ul tabs-content">
|
||||
@if (getArticlesBYCate(17,4)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(17,4) as $article)
|
||||
<li class="party-ul-li">
|
||||
<a href="{{ $article->link }}">
|
||||
<span class="party-time">
|
||||
<h3>{{ $article->created_at->format('d') }}</h3>
|
||||
<p>{{ $article->created_at->format('Y-m') }}</p>
|
||||
</span>
|
||||
<h3 class="party-title nowrap">{{ $article->title }}</h3>
|
||||
<p class="party-info nowrap-multi">{{ $article->description }}</p>
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
@endif
|
||||
</ul>
|
||||
<!-- 成果专利 -->
|
||||
<ul class="party-ul tabs-content">
|
||||
@if (getArticlesBYCate(16,4)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(16,4) as $article)
|
||||
<li class="party-ul-li">
|
||||
<a href="{{ $article->link }}">
|
||||
<span class="party-time">
|
||||
<h3>{{ $article->created_at->format('d') }}</h3>
|
||||
<p>{{ $article->created_at->format('Y-m') }}</p>
|
||||
</span>
|
||||
<span class="party-img party-cover" style="background-image:url({{ $article->cover_path }})">
|
||||
</span>
|
||||
<h3 class="party-title nowrap">{{ $article->title }}</h3>
|
||||
<p class="party-info nowrap-multi">{{ $article->description }}</p>
|
||||
</a>
|
||||
@@ -250,23 +219,40 @@
|
||||
</div>
|
||||
<!-- 项目推广 -->
|
||||
<div class="news-item spirit">
|
||||
<div class="mian-title">
|
||||
<b>{{ getOneCategory(18,'title') }}</b>
|
||||
<span>/ {{ getOneCategory(18,'description') }}</span>
|
||||
<a class="mian-title-more" href="{{ getOneCategory(18,'link') }}">更多<i class="fa fa-angle-right"></i></a>
|
||||
<div class="tabs-title" id="patentTab">
|
||||
<span class="tabs-item show">{{ getOneCategory(18,'title') }}</span>
|
||||
<span class="tabs-item">{{ getOneCategory(16,'title') }}</span>
|
||||
{{-- <a class="mian-title-more" href="">更多<i class="fa fa-angle-right"></i></a>--}}
|
||||
</div>
|
||||
<div class="tabs-content-wrapper" id="patentTabContent">
|
||||
<!-- 项目推广 -->
|
||||
<ul class="spiritual-ul tabs-content active">
|
||||
@if (getArticlesBYCate(18,4)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(18,4) as $article)
|
||||
<li class="spiritual-ul-li">
|
||||
<a href="{{ $article->link }}">
|
||||
<h3 class="spiritual-title nowrap">{{ $article->title }}</h3>
|
||||
<p class="spiritual-info nowrap-multi">{{ $article->description }}</p>
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
@endif
|
||||
</ul>
|
||||
|
||||
<!-- 成果专利 -->
|
||||
<ul class="spiritual-ul tabs-content">
|
||||
@if (getArticlesBYCate(16,4)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(16,4) as $article)
|
||||
<li class="spiritual-ul-li">
|
||||
<a href="{{ $article->link }}">
|
||||
<h3 class="spiritual-title nowrap">{{ $article->title }}</h3>
|
||||
<p class="spiritual-info nowrap-multi">{{ $article->description }}</p>
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
@endif
|
||||
</ul>
|
||||
</div>
|
||||
<ul class="spiritual-ul">
|
||||
@if (getArticlesBYCate(18,4)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(18,4) as $article)
|
||||
<li class="spiritual-ul-li">
|
||||
<a href="{{ $article->link }}">
|
||||
<h3 class="spiritual-title nowrap">{{ $article->title }}</h3>
|
||||
<p class="spiritual-info nowrap-multi">{{ $article->description }}</p>
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
@endif
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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")
|
||||
})
|
||||
});
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
Reference in New Issue
Block a user