From b408cf278babda26aa7a179817bf7a1946ac2968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E5=B0=98?= <122383162@qq.com> Date: Wed, 3 Feb 2021 17:24:51 +0800 Subject: [PATCH] =?UTF-8?q?=20=E9=98=B6=E6=AE=B5=E6=80=A7=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Article/IndexController.php | 17 + .../Controllers/Article/TalentController.php | 7 +- app/Helpers/function.php | 43 ++- app/Http/Controllers/IndexController.php | 22 +- app/Models/Article.php | 10 + app/Models/Talent.php | 4 +- config/haai.php | 3 + public/assets/index/css/style.css | 129 +++++-- resources/views/category/kxyj.blade.php | 81 ++-- resources/views/category/left.blade.php | 13 +- resources/views/category/list.blade.php | 13 +- resources/views/category/rcdw.blade.php | 94 +++-- resources/views/category/sjljrc.blade.php | 49 +++ resources/views/category/xhqk.blade.php | 33 ++ resources/views/category/yjzdxk.blade.php | 49 +++ resources/views/index/index.blade.php | 147 ++++---- resources/views/layouts/header.blade.php | 321 +--------------- resources/views/layouts/header.blade_old.php | 345 ++++++++++++++++++ resources/views/layouts/kjcc.blade.php | 35 ++ resources/views/layouts/left.blade.php | 12 +- 20 files changed, 888 insertions(+), 539 deletions(-) create mode 100644 resources/views/category/sjljrc.blade.php create mode 100644 resources/views/category/xhqk.blade.php create mode 100644 resources/views/category/yjzdxk.blade.php create mode 100644 resources/views/layouts/header.blade_old.php create mode 100644 resources/views/layouts/kjcc.blade.php diff --git a/app/Admin/Controllers/Article/IndexController.php b/app/Admin/Controllers/Article/IndexController.php index ba00ff1..5be6ee6 100644 --- a/app/Admin/Controllers/Article/IndexController.php +++ b/app/Admin/Controllers/Article/IndexController.php @@ -25,6 +25,10 @@ class IndexController extends AdminController return $model->where('status', 1)->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW]); }, '所有分类')); }); + $filter->column(1 / 2, function ($filter) { + $filter->equal('position', '定位') + ->select(Article::POSITIONS); + }); $filter->disableIdFilter(); }); @@ -60,6 +64,7 @@ class IndexController extends AdminController 'required' => '必须选择所属分类', 'min' => '必须选择所属分类', ]); + // $form->text('keywords', '关键词')->rules('nullable'); $form->textarea('description', '内容简介')->rules('max:350'); $form->image('cover', '封面') @@ -71,7 +76,19 @@ class IndexController extends AdminController $form->number('sort', '序号')->default(0)->rules('required', ['required' => '序号必须填写'])->help('倒序优先'); $form->switch('status', '状态')->default(1); $form->text('url', '外链地址'); + $form->select('position', '定位') + ->options(Article::POSITIONS); $form->datetime('created_at', '发布时间'); + $form->saved(function ($form) { + if ($form->position) { + $model = $form->model(); + Article::where('position', $form->position) + ->where('id', '<>', $model->id) + ->update([ + 'position' => '', + ]); + } + }); return $form; } diff --git a/app/Admin/Controllers/Article/TalentController.php b/app/Admin/Controllers/Article/TalentController.php index b67a48b..64a02f4 100644 --- a/app/Admin/Controllers/Article/TalentController.php +++ b/app/Admin/Controllers/Article/TalentController.php @@ -12,13 +12,14 @@ use Encore\Admin\Grid; class TalentController extends AdminController { - protected $title = '领军人才梯队'; + protected $title = '人才梯队'; public function grid() { $grid = new Grid(new Talent()); $grid->model()->latest('sort'); $grid->column('id', '#ID#'); + $grid->column('category.title', '所属分类'); $grid->column('sort', '排序(倒序显示)')->editable(); $grid->column('title', '梯队名称'); $grid->column('leader', '带头人'); @@ -33,6 +34,10 @@ class TalentController extends AdminController $form = new Form(new Talent()); $form->text('title', '梯队名称')->required(); + $form->select('category_id', '所属分类') + ->options(Category::whereIn('id', [68, 69])->pluck('title', 'id'), '选择分类') + ->required(); + $form->image('cover', '封面') ->move('images/' . date('Y/m/d')) ->removable() diff --git a/app/Helpers/function.php b/app/Helpers/function.php index 19ddb8d..daf3c0e 100644 --- a/app/Helpers/function.php +++ b/app/Helpers/function.php @@ -8,6 +8,14 @@ use App\Models\Talent; use Encore\Admin\Auth\Database\Menu; use Illuminate\Support\Arr; +/** + * Notes: 获取一个分类 + * @Author: 玄尘 + * @Date : 2021/2/3 16:36 + * @param $categoryId + * @param string $return + * @return \App\Models\Category + */ function getOneCategory($categoryId, $return = '') { $category = Category::find($categoryId); @@ -114,9 +122,13 @@ function getOneAdvert($category_id, $value = '') } //获取人才数据 -function getAllTalent() +function getAllTalent($category_id = '') { - return Talent::latest('sort')->get(); + return Talent::latest('sort') + ->when($category_id, function ($q) use ($category_id) { + $q->where('category_id', $category_id); + }) + ->get(); } //获取一篇人才文章 @@ -125,7 +137,7 @@ function getOneRenById($article_id) return Talent::find($article_id); } -//获取分类信息 +//获取菜单信息 function getCate($id, $value = '') { $info = Menu::find($id); @@ -157,3 +169,28 @@ function getAllParentCate($categoryId): array return $res->all(); } + +/** + * Notes: 获得分类 + * @Author: 玄尘 + * @Date : 2021/2/3 16:38 + * @param $cate_id + * @param $ + */ +function getArtilesByCates($cate_id, $take = 8) +{ + $cate_ids = Category::where('parent_id', $cate_id) + ->orWhere('id', $cate_id) + ->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW]) + ->get(); + + return Article::whereIn('category_id', $cate_ids) + ->latest() + ->get(); +} + +// 根据定位获取文章 +function getArtileByPos($position) +{ + return Article::where('position', $position)->first(); +} diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index 5581e6b..eba1cfb 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -18,29 +18,17 @@ class IndexController extends Controller */ public function index() { - // $ssp = ArticlePicture::orderBy('sort', 'desc')->take(3)->get(); //随手拍 - // $all_articles = Article::orderBy('sort', 'desc') - // ->whereNotIn('category_id', [20, 21, 22]) - // ->take(7) - // ->get(); //最新资讯 - // $danwei = Article::where('category_id', 15)->latest()->first(); //单位概况 - // $ysbj = Article::where('category_id', 12)->latest()->take(3)->get(); //养生保健 - // $dcyfx = Article::where('category_id', 10)->latest()->take(7)->get(); //调研与分析 - // $yyjcyj = Article::where('category_id', 9)->latest()->take(7)->get(); //应用基础研究 - // $jsyt = Article::where('category_id', 11)->latest()->take(7)->get(); //技术研讨 - // $kyyyy = Article::where('category_id', 12)->latest()->take(7)->get(); //科研与应用 - // $qkys = Article::where('category_id', 9)->latest()->take(7)->get(); //全科医学 - // $center_advert = Advert::where('category_id', 18)->first(); - // $qikan_advert = Advert::where('category_id', 19)->take(4)->orderBy('sort', 'desc')->get(); - $data = [ 'ysxw' => Article::where('category_id', 15)->latest('sort')->latest()->take(8)->get(), - 'kjcg' => Article::where('category_id', 19)->latest('sort')->latest()->take(8)->get(), - 'lwzl' => Patent::latest('sort')->latest()->take(11)->get(), + // 'kjcg' => Article::where('category_id', 19)->latest('sort')->latest()->take(8)->get(), + // 'lwzl' => Patent::latest('sort')->latest()->take(11)->get(), 'center_advert' => Advert::latest('sort')->latest()->where('category_id', 23)->take(3)->get(), 'ysxw_right_advert' => Advert::latest('sort')->latest()->where('category_id', 24)->first(), 'kjcg_right_advert' => Advert::latest('sort')->latest()->where('category_id', 25)->take(2)->get(), 'lwzl_right_advert' => Advert::latest('sort')->latest()->where('category_id', 27)->take(2)->get(), + 'pos_a' => Article::where('position', Article::POSITION_A)->first(), + 'pos_b' => Article::where('position', Article::POSITION_B)->first(), + 'pos_c' => Article::where('position', Article::POSITION_C)->first(), ]; return view('index.index', $data); diff --git a/app/Models/Article.php b/app/Models/Article.php index 6fb2f7c..02687a9 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -10,6 +10,16 @@ class Article extends Model use HasOneCover, BelongsToCategory; + const POSITION_A = 1; + const POSITION_B = 2; + const POSITION_C = 3; + + const POSITIONS = [ + self::POSITION_A => '院所新闻', + self::POSITION_B => '科学研究', + self::POSITION_C => '科技成果', + ]; + public function getLinkAttribute() { return route('article.show', $this); diff --git a/app/Models/Talent.php b/app/Models/Talent.php index 1d1c53f..a55e72f 100644 --- a/app/Models/Talent.php +++ b/app/Models/Talent.php @@ -2,10 +2,12 @@ namespace App\Models; +use App\Models\Traits\BelongsToCategory; use App\Models\Traits\HasOneCover; class Talent extends Model { - use HasOneCover; + use HasOneCover, + BelongsToCategory; } diff --git a/config/haai.php b/config/haai.php index 0199218..f29130e 100644 --- a/config/haai.php +++ b/config/haai.php @@ -10,6 +10,9 @@ return [ 'rcdw' => 28,//人才队伍 'djkxwh' => 31,//党建与科学文化 'gjzczj' => 29,//党建与科学文化 + 'sjljrc' => 69,//省级领军人才梯队 + 'yjzdxk' => 68,//院级重点学科 + 'xhqk' => 66,//院级重点学科 ], //分类使用的模板 'template' => [ diff --git a/public/assets/index/css/style.css b/public/assets/index/css/style.css index 1b80438..2e2c335 100644 --- a/public/assets/index/css/style.css +++ b/public/assets/index/css/style.css @@ -116,27 +116,27 @@ img { } .header-logo { - width: 380px; - height: 55px; + width: 521px; + height: 75px; } .header-text { padding-left: 95px; -} - -.header-text p { + width: 669px; + box-sizing: border-box; text-align: right; - font-size: 15px; + line-height: 50px; color: #273981; font-weight: bold; + font-size: 20px; } -.header-text p.header-text-sign { - padding-top: 5px; +.header-text-sign { color: #4864ae; + padding-left: 5px; + font-size: 80%; } - /* nav */ .nav { background-color: #273981; @@ -621,6 +621,15 @@ img { width: 970px; } +.mian-nav-title{ + background: #273981; + padding: 20px 30px; + text-align: center; + color: white; + font-weight: bold; + font-size: 26px +} + .mian-nav-cover { width: 100%; } @@ -641,7 +650,7 @@ img { .mian-nav-ul li a:hover, .mian-nav-ul li.show a { - background-color: #273981; + background-color: #4864ae; } .mian-content-header { @@ -859,7 +868,7 @@ img { .index-mian-right-ads { display: flex; - margin: 0 -10px 20px -10px; + margin: 0 -10px 40px -10px; } .index-mian-right-ad-5 { @@ -881,7 +890,7 @@ img { } .index-mian-right-video { - margin: 20px 0; + margin: 20px 0 40px; position: relative; min-height: 170px; padding-left: 200px; @@ -933,6 +942,28 @@ img { color: #273981; } +/* 通知公告 */ +.index-mian-notice-ul{ + padding-right: 0; +} + +.index-mian-notice-ul li { + line-height: 17px; + margin: 20px 0; +} + +.index-mian-notice-ul li a{ + position: relative; + padding-right: 0; + padding-left: 20px; +} + +.index-mian-notice-ul li a i{ + position: absolute; + left: 0; + top: 0; +} + /* footer */ .footer { background-color: #273981; @@ -1337,26 +1368,44 @@ img { .lw { position: relative; - padding: 0 50px; + padding: 15px 70px; min-height: 120px; } -.lw-left { +.lw-left,.lw-right { position: absolute; width: 40px; height: 80px; background-color: #273981; text-align: center; top: calc(50% - 40px); - left: 0; display: flex; justify-content: center; align-items: center; color: white; } +.lw-left{ + left: 15px; +} + +.lw-right{ + right: 15px; + background-color: #c0c4d2; + transition: all .3s; +} + +.lw-right:hover{ + background-color: #273981; +} + .lw-center li { - line-height: 30px; + line-height: 35px; + border-bottom: dashed 1px #c0c4d2; +} + +.lw-center li:last-child{ + border-bottom: none; } .lw-left2 { @@ -1380,8 +1429,8 @@ img { } .lw-lg { - min-height: 240px; - padding-right: 0; + min-height: 288px; + background: #f1f3f8; } .lw-left-lg { @@ -1463,6 +1512,40 @@ img { font-size: 12px; } +/* 人才队伍 - 高级职称专家无照片 */ +.rcdw-text{ + padding-bottom: 20px; +} + +.rcdw-text-item{ + position: relative; + font-size: 16px; + padding-left: 100px; + line-height: 35px; +} + +.rcdw-text-item > b{ + position: absolute; + left: 0; + top: 0; + padding-left: 30px; +} + +.rcdw-text-item > b > i{ + color: #273981; + margin-right: 5px; +} + +.rcdw-text-item span{ + color: #555; + margin-right: 10px; + cursor: pointer; +} + +.rcdw-text-item span:hover{ + color: #273981; +} + /* 人才队伍 - 省领军人才梯队 */ .rctd-boeder { border-bottom: 1px solid #eee; @@ -1602,9 +1685,13 @@ img { height: 40px; line-height: 40px; text-align: center; - background: #4864ae; + background-image: url(../img/z19_scroll_wx.png); + background-repeat: no-repeat; + background-size: cover; + background-position: center; font-size: 18px; transition: background .3s; + border-radius: 5px; } .wechat-code { @@ -1625,10 +1712,10 @@ img { color: white; } -.laytool-ul li:hover { +/*.laytool-ul li:hover { background: #273981; } - +*/ .laytool-ul li:hover .wechat-code { display: block; } diff --git a/resources/views/category/kxyj.blade.php b/resources/views/category/kxyj.blade.php index 90f935d..08e5948 100644 --- a/resources/views/category/kxyj.blade.php +++ b/resources/views/category/kxyj.blade.php @@ -11,18 +11,29 @@
-
- 首页 - - {{ $category->title }} -
- + @include('layouts.navigation',['category'=>$category]) +
- {{ getOneCategory(13,'title') }} - 更多 + {{ getOneCategory(14,'title') }} + 更多 +
+ + +
+ {{ getOneCategory(11,'title') }}
- -
- {{ getOneCategory(12,'title') }} + +
+ {{ getOneCategory(67,'title') }} + 更多
-
diff --git a/resources/views/category/left.blade.php b/resources/views/category/left.blade.php index 6f429d9..07c541b 100644 --- a/resources/views/category/left.blade.php +++ b/resources/views/category/left.blade.php @@ -1,9 +1,12 @@ -@if($parent->cover_path) - 导航封面 -@endif + +
+ + {{ $category->title }} + +