This commit is contained in:
2021-06-08 10:22:00 +08:00
parent c976279f59
commit 73823d24cb
6 changed files with 79 additions and 90 deletions

View File

@@ -39,7 +39,7 @@ class IndexController extends AdminController
return $this->categories()->pluck('title'); return $this->categories()->pluck('title');
})->label(); })->label();
$grid->column('title', '文章标题'); $grid->column('title', '文章标题');
$grid->column('sort', '序号'); $grid->column('sort', '序号')->editable();
$states = [ $states = [
'on' => ['value' => 1, 'text' => '打开', 'color' => 'primary'], 'on' => ['value' => 1, 'text' => '打开', 'color' => 'primary'],
'off' => ['value' => 2, 'text' => '关闭', 'color' => 'default'], 'off' => ['value' => 2, 'text' => '关闭', 'color' => 'default'],

View File

@@ -53,7 +53,8 @@ function getOneArticleBYCate($categoryId, $result = '')
->whereHas('categories', function ($q) use ($categoryId) { ->whereHas('categories', function ($q) use ($categoryId) {
$q->where('id', $categoryId); $q->where('id', $categoryId);
}) })
->latest() ->latest('sort')
->latest('created_at')
->first(); ->first();
if ($info) { if ($info) {
@@ -87,7 +88,8 @@ function getArticlesBYCate($categoryId, $take = 8, $mark = 'one', $hasCover = fa
->whereHas('categories', function ($q) use ($categoryId) { ->whereHas('categories', function ($q) use ($categoryId) {
$q->where('id', $categoryId); $q->where('id', $categoryId);
}) })
->orderBy('sort', $order) ->latest('sort')
->latest('created_at')
->when($hasCover, function ($q) { ->when($hasCover, function ($q) {
$q->whereNotNull('cover'); $q->whereNotNull('cover');
}) })
@@ -104,7 +106,8 @@ function getArticlesBYCate($categoryId, $take = 8, $mark = 'one', $hasCover = fa
->when($hasCover, function ($q) { ->when($hasCover, function ($q) {
$q->whereNotNull('cover'); $q->whereNotNull('cover');
}) })
->orderBy('sort', $order) ->latest('sort')
->latest('created_at')
->take($take) ->take($take)
->get(); ->get();
} }
@@ -179,7 +182,8 @@ function getArticlesByCateIds($take = 8, $hasCover = false)
->whereHas('categories', function ($q) use ($ids) { ->whereHas('categories', function ($q) use ($ids) {
$q->whereIn('id', $ids); $q->whereIn('id', $ids);
}) })
->latest() ->latest('sort')
->latest('created_at')
->when($hasCover, function ($q) { ->when($hasCover, function ($q) {
$q->whereNotNull('cover')->orWhere('cover', '<>', ''); $q->whereNotNull('cover')->orWhere('cover', '<>', '');
}) })
@@ -200,7 +204,8 @@ function getArticlesByCateIds($take = 8, $hasCover = false)
function getArticlesByPosition($postion) function getArticlesByPosition($postion)
{ {
$articles = Article::ofPosition($postion) $articles = Article::ofPosition($postion)
->latest() ->latest('sort')
->latest('created_at')
->take(5) ->take(5)
->get(); ->get();

View File

@@ -210,6 +210,12 @@ img {max-width: 100%;}
.indexPrize-img {position: relative; width: 100%; padding-top: 70%; margin-bottom: 10px; display: block;} .indexPrize-img {position: relative; width: 100%; padding-top: 70%; margin-bottom: 10px; display: block;}
.indexPrize-title {font-size: 18px;} .indexPrize-title {font-size: 18px;}
.indexPrize-pagination {bottom: -5px !important;} .indexPrize-pagination {bottom: -5px !important;}
.IndexExpertNew {overflow: hidden; margin: 0 20px;}
.IndexExpertNew li { width: calc(33.33% - 40px); float: left; margin: 20px; padding: 15px 0; text-align: center; box-sizing: border-box;border: 1px solid #f5f5f5;border-radius: 5px;background: #f5f5f5;}
.IndexExpertNew-title {font-size: 18px; font-weight: 600}
.IndexExpertNew-tips {margin-bottom: 20px; color: #999; display: block; position: relative;}
.IndexExpertNew-tips::after {position: absolute; content: ''; left: calc(50% - 16px); bottom: -10px; background-color: #ffb993; width: 30px; height: 4px;
border-radius: 22px;}
/* 友情链接 */ /* 友情链接 */

View File

@@ -16,16 +16,19 @@
{{ getOneCategory(12,'title') }} {{ getOneCategory(12,'title') }}
</div> </div>
</div> </div>
<ul class="indexExtend-ul studyExtend"> <ul class="mediaList">
@if (getArticlesBYCate(12,2)->isNotEmpty()) @if (getArticlesBYCate(12,2)->isNotEmpty())
@foreach (getArticlesBYCate(12,2) as $article) @foreach (getArticlesBYCate(12,2) as $article)
<li> <li>
<a href=" {{ $article->link }}"> <a href="{{ $article->link }}">
<div class="ce-nowrap indexExtend-ul-name"> <div class="ce-img mediaList-img">
{{ $article->title }} <span style="background-image: url({{ $article->cover_path }});"></span>
</div> </div>
<div class="ce-nowrap-multi indexExtend-ul-text"> <div class="mediaList-text">
{{ $article->description }} <div class="ce-nowrap-multi mediaList-name">
{{ $article->title }}
</div>
<span>{{ $article->description }}</span>
</div> </div>
</a> </a>
</li> </li>
@@ -67,37 +70,7 @@
</ul> </ul>
</div> </div>
<!-- 媒体报道 -->
<div class="surveyCont">
<div class="secondTop">
<div class="secondTop-name">
<img src="/assets/index/images/surveyIcon_02.png">
{{ getOneCategory(11,'title') }}
</div>
<a href="{{ getOneCategory(11,'link') }}" class="secondTop-more">
查看更多&gt;&gt;
</a>
</div>
<ul class="mediaList">
@if (getArticlesBYCate(30,2)->isNotEmpty())
@foreach (getArticlesBYCate(30,2) as $article)
<li>
<a href="{{ $article->link }}">
<div class="ce-img mediaList-img">
<span style="background-image: url({{ $article->cover_path }});"></span>
</div>
<div class="mediaList-text">
<div class="ce-nowrap-multi mediaList-name">
{{ $article->title }}
</div>
<span>{{ $article->description }}</span>
</div>
</a>
</li>
@endforeach
@endif
</ul>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -3,51 +3,52 @@
@section('title', '首页') @section('title', '首页')
@section('content') @section('content')
<!-- 科学研究 --> <!-- 科学研究 -->
<div class="survey" style="background-image: url(/assets/index/images/studyBack.png);"> <div class="survey" style="background-image: url(/assets/index/images/studyBack.png);">
<div class="container"> <div class="container">
<div class="row"> <div class="row">
@include('category.left') @include('category.left')
<div class="col-xs-12 col-md-9 secondRight"> <div class="col-xs-12 col-md-9 secondRight">
<!-- 科研动态 --> <!-- 科研动态 -->
<div class="surveyCont"> <div class="surveyCont">
<div class="secondTop"> <div class="secondTop">
<div class="secondTop-name"> <div class="secondTop-name">
<img src="/assets/index/images/studyIcon_00.png"/> <img src="/assets/index/images/studyIcon_00.png"/>
{{ $category->title }} {{ $category->title }}
</div>
</div> </div>
</div> <ul class="dateExtend">
<ul class="dateExtend"> @if ($articles->isNotEmpty())
@foreach ($articles as $article)
<li>
<a href="{{ $article->link }}">
<div class="dateExtend-left">
<span>{{ $article->created_at->format('m/d') }}</span>
{{ $article->created_at->format('Y') }}
</div>
<div class="dateExtend-right">
<div class="ce-nowrap indexExtend-ul-name">
{{ $article->title }}
</div>
<div class="ce-nowrap indexExtend-ul-text">
{{ $article->description }}
</div>
</div>
</a>
</li>
@endforeach
@endif
</ul>
<!-- 分页 -->
@if ($articles->isNotEmpty()) @if ($articles->isNotEmpty())
@foreach ($articles as $article) {{ $articles->links('layouts.pagination') }}
<li>
<a href="">
<div class="dateExtend-left">
<span>06/01</span>
2021
</div>
<div class="dateExtend-right">
<div class="ce-nowrap indexExtend-ul-name">
{{ $article->title }}
</div>
<div class="ce-nowrap indexExtend-ul-text">
{{ $article->description }}
</div>
</div>
</a>
</li>
@endforeach
@endif @endif
</ul> </div>
<!-- 分页 -->
@if ($articles->isNotEmpty())
{{ $articles->links('layouts.pagination') }}
@endif
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
@endsection @endsection

View File

@@ -388,19 +388,23 @@
<!-- 专家智库 --> <!-- 专家智库 -->
<div role="screen-2" class="tab-pane fade" id="screen-2"> <div role="screen-2" class="tab-pane fade" id="screen-2">
<ul class="IndexExpert-ul"> <ul class="IndexExpertNew">
@if (getArticlesBYCate(29,3)->isNotEmpty()) @if (getArticlesBYCate(29,9)->isNotEmpty())
@foreach (getArticlesBYCate(29,3) as $article) @foreach (getArticlesBYCate(29,9) as $article)
<li> <li>
<a href="{{ $article->link }}" title="{{ $article->title }}"> <a href="{{ $article->link }}" title="{{ $article->title }}">
<div class="ce-img IndexExpert-img"> <div class="IndexExpertNew-li">
<span class="IndexExpertNew-tips">客座教授</span>
<div class="IndexExpertNew-title">{{ $article->title }}</div>
</div>
<!-- <div class="ce-img IndexExpert-img">
<span style="background-image: url({{ $article->cover_path }});"></span> <span style="background-image: url({{ $article->cover_path }});"></span>
</div> </div>
<div class="IndexExpert-name"> <div class="IndexExpert-name">
<div class="IndexExpert-title"> <div class="IndexExpert-title">
<span>{{ $article->title }}</span>科学专家 <span>{{ $article->title }}</span>客座教授
</div> </div>
</div> </div> -->
</a> </a>
</li> </li>
@endforeach @endforeach