调整页面

This commit is contained in:
2022-03-04 17:05:16 +08:00
parent 42ba67e4bb
commit 7037180850
4 changed files with 1253 additions and 1120 deletions

View File

@@ -20,6 +20,7 @@ function getOneCategory($categoryId, $return = '')
/**
* Notes: 获取文章分类详情
*
* @Author: 玄尘
* @Date : 2020/9/10 13:21
* @param $categoryId
@@ -49,6 +50,7 @@ function getOneArticleBYCate($categoryId, $result = '')
/**
* Notes: 获取分类下的文章
*
* @Author: 玄尘
* @Date : 2020/9/10 10:05
* @param $categoryId
@@ -79,6 +81,31 @@ function getArticlesBYCate($categoryId, $take = 8, $mark = 'one')
return $articles;
}
/**
* Notes: 获取带图片的文章
*
* @Author: 玄尘
* @Date: 2022/3/4 16:52
* @param $categoryId
* @param $take
* @return mixed
*/
function getArticlesAndCoverBYCate($categoryId, $take = 8)
{
$cate = Category::find($categoryId);
$ids = $cate->getAllChildrenId();
return Article::where('status', 1)
->ByCategory($ids)
->where(function ($query) {
$query->whereNotNull('cover')->orWhere('cover', '<>', '');
})
->latest('sort')
->latest()
->take($take)
->get();
}
//获取子分类
function getCateChild($categoryId)
{

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Models\Advert;
use App\Models\Article;
use App\Models\Category;
class CategoryController extends Controller
@@ -10,6 +11,7 @@ class CategoryController extends Controller
/**
* 显示分类
*
* @param Category $category [description]
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View [type] [description]
*/
@@ -18,11 +20,18 @@ class CategoryController extends Controller
if ($category->type == Category::TYPE_SHOW && $category->article_id) {
return redirect("articles/".$category->article_id);
} else {
$articles = $category->relations(Category::TYPE_ARTICLE)
// $articles = $category->relations(Category::TYPE_ARTICLE)
// ->where('status', 1)
// ->latest('sort')
// ->latest()
// ->paginate();
$articles = Article::ByCategory($category->getAllChildrenId())
->where('status', 1)
->latest('sort')
->latest()
->latest('created_at')
->paginate();
$parent = $category;
if ($category->childrens->isEmpty() && $category->parent) {

View File

@@ -31,9 +31,9 @@ p {
}
.idxTop-back {
background: url(../images/nys_bg01.jpg) #b2eaf9 no-repeat top center;
background: url(../images/nys_bg01.png) #fff no-repeat center;
width: 100%;
background-size: 100% 100%;
background-size: cover;
}
/*
@@ -88,11 +88,15 @@ p {
.idxTop {
box-sizing: border-box;
position: relative;
}
.idxLogo {
width: 100%;
width: 60%;
padding-left:20%;
cursor: pointer;
padding-top:60px;
padding-bottom:80px
}
.idxNav {
@@ -486,14 +490,14 @@ p {
}
.newTwo-list li {
width: calc(25% - 1rem);
width: calc(16.6% - 1rem);
margin: 0 .5rem;
float: left;
}
.newTwo-list-img {
width: 100%;
padding-top: 65%;
padding-top: 100%;
}
.newTwo-list-title {
@@ -843,7 +847,7 @@ p {
尾部
*/
.idxFooter {
background: #585858;
background: #213f88;
color: #fff;
width: 100%;
padding: 40px 0;
@@ -1086,3 +1090,58 @@ p {
font-weight: 600px;
font-size: 18px;
}
.flexrow{
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: flex; /* 新版本语法: Opera 12.1, Firefox 22+ */
-webkit-box-orient: vertical;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
.jc_sb{
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
}
.idxFooter-text a{
display:block;
color:#fff;
font-size:18px;
text-align:left;
padding-bottom:10px
}
.banner_3{
margin-bottom:10px;
}
.swiper-pagination-dian{
text-align:right;
right:10px !important;
width:calc( 100% - 10px ) !important;
}
.swiper-pagination-dian .swiper-pagination-bullet-active{
background:#fff !important;
}

View File

@@ -71,6 +71,25 @@
</div>
<!-- end 第一模板 -->
<!-- 通图 轮播图 start -->
<div class="tong_banner">
</div>
<div class="swiper-container tong_banner1 contant">
<div class="swiper-wrapper">
<div class=" idx_banner swiper-slide">
<img src="/assets/index/images/banner_1.png" alt="节约能源图片">
</div>
<div class=" idx_banner swiper-slide">
<img src="/assets/index/images/banner_2.png" alt="节约能源图片">
</div>
</div>
<div class="swiper-pagination swiper-pagination-dian"></div>
</div>
<!-- 通图 轮播图 end -->
<!-- 第二模板 -->
@if (getArticlesBYCate(24,4)->isNotEmpty())
@@ -85,7 +104,7 @@
</div>
</div>
<ul class="newTwo-list">
@foreach (getArticlesBYCate(24,4) as $article)
@foreach (getArticlesAndCoverBYCate(24,6) as $article)
<li data-href="{{ $article->link }}">
<div class="ce-img newTwo-list-img">
<span style="background-image: url({{ $article->cover_path }});"></span>
@@ -103,6 +122,13 @@
<!-- end 第二模板 -->
<!-- 通图 start -->
<div class="contant banner_3">
<img src="/assets/index/images/banner_3.png" alt="节约能源图片">
</div>
<!-- 通图 end -->
<!-- 第三模板 -->
<div class="idxThree">
<div class="contant">
@@ -241,12 +267,15 @@
@endsection
@push('script')
<!-- Swiper JS -->
<script>
// banner轮播
var banner = new Swiper('.idxBanner', {
pagination: '.swiper-pagination-white'
});
var tong_banner = new Swiper('.tong_banner', {})
// 轮播
var idxFour = new Swiper('.idxFour-container', {
nextButton: '.swiper-button-next',
@@ -255,5 +284,14 @@
paginationClickable: true,
spaceBetween: 30,
});
var tong_banner1 = new Swiper('.tong_banner1', {
pagination: '.swiper-pagination',
paginationClickable: true,
loop: true,
autoplay: 4000,
});
</script>
@endpush