diff --git a/app/controller/Index.php b/app/controller/Index.php index d0badca..6ad0812 100755 --- a/app/controller/Index.php +++ b/app/controller/Index.php @@ -2,9 +2,10 @@ namespace app\controller; -use app\model\{Article as MArticle, Category, Block, Message, Article, Slide}; +use app\model\{Article as MArticle, CasesModel, Category, Block, Message, Article, Slide}; use Exception; use think\exception\ValidateException; +use think\facade\Db; use think\facade\View; use app\service\Tool; @@ -16,34 +17,66 @@ class Index extends Base $categoryId = $category['id'] ?? 0; $blocks = Block::getByCategoryId($categoryId); - $this->news(5); + $this->news(); + $this->cases(); $this->companyHistory($blocks['company_history_list']['value']); - $this->data['categoryId'] = $categoryId; - $this->data['blocks'] = Block::convertValue($blocks); - $this->data['category'] = $category; - $this->data['topCategoryId'] = Category::firstGradeById($category['id']) ; - $this->data['isIndex'] = true; - $this->data['slide'] = Slide::getList(); + $this->data['categoryId'] = $categoryId; + $this->data['blocks'] = Block::convertValue($blocks); + $this->data['category'] = $category; + $this->data['topCategoryId'] = Category::firstGradeById($category['id']); + $this->data['isIndex'] = true; + $this->data['slide'] = Slide::getList(); $this->setSeo($this->system['seo_title'], $this->system['seo_keywords'], $this->system['seo_description']); return $this->view(); } - // 新闻动态 - private function news($num) + // 新闻 + private function news() { - $this->data['newsList'] = MArticle::getIndexList(Category::CATEGORY_NEWS, $num); - $topNews = MArticle::getIndexTop(Category::CATEGORY_NEWS); - $this->data['topNews'] = $topNews; + $newsCategory = Category::where('parent_id', Category::CATEGORY_NEWS) + ->order('sort', 'asc') + ->column('id,title,route,url'); + + $sql = ''; + foreach ($newsCategory as $cate) { + $sql .= empty($sql) ? '' : ' union '; + $sql .= '(select `id`,`title`,`summary`,`category_id`,`src`,`src_mobile`,`create_time` from bee_article where `category_id` = '.$cate['id'].' order by `top` desc, `sort` desc limit 5)'; + } + + $res = Db::query($sql); + $list = []; + + foreach (array_column($newsCategory, 'id') as $categoryId) { + if (!isset($list[$categoryId])) { + $list[$categoryId] = []; + } + foreach ($res as $re) { + if ($re['category_id'] == $categoryId) { + $list[$categoryId][] = $re; + } + } + } + + $this->data['newsCategory'] = $newsCategory; + $this->data['newsList'] = $list; + } + + // 案例 + private function cases() + { + $casesList = CasesModel::where('home', 1)->order('sort', 'desc')->order('id', 'desc')->select(); + + $this->data['casesList'] = $casesList; } private function companyHistory(string $companyHistory) { - $companyHistory = nl2br($companyHistory); - $companyHistory = explode('
', $companyHistory); + $companyHistory = nl2br($companyHistory); + $companyHistory = explode('
', $companyHistory); $companyHistoryList = []; foreach ($companyHistory as $v) { - $arr = explode(';', $v); + $arr = explode(';', $v); $companyHistoryList[] = [ 'year' => $arr[0] ?? '', 'desc' => $arr[1] ?? '' @@ -62,10 +95,10 @@ class Index extends Base if ($this->request->isPost()) { $item = input('item/a', [], 'strip_tags'); $validate = $this->validateByApi($item, [ - 'code|验证码' => 'require', - 'name|姓名' => 'require', - 'email|邮箱' => 'email', - 'tel|联系方式' => 'require|mobile', + 'code|验证码' => 'require', + 'name|姓名' => 'require', + 'email|邮箱' => 'email', + 'tel|联系方式' => 'require|mobile', 'content|留言内容' => 'require', ]); if ($validate !== true) { diff --git a/public/static/web/css/style.css b/public/static/web/css/style.css index a55ff51..568aea5 100644 --- a/public/static/web/css/style.css +++ b/public/static/web/css/style.css @@ -466,6 +466,10 @@ flex-wrap: wrap; } +.project-case-list { + flex-wrap: wrap; +} + .project-case-list>a { width: calc(25% - 19.5px); margin: 24px 26px 0 0; diff --git a/view/index/index.html b/view/index/index.html index 32014d0..ed40caf 100755 --- a/view/index/index.html +++ b/view/index/index.html @@ -56,104 +56,31 @@
project case
- 总部新闻 - 区域动态 + {foreach $newsCategory as $c} + {$c.title} + {/foreach}
- News > + {$blocks['news_more_mobile']['value']}
+ {foreach $newsList as $news}
+ {foreach $news as $n} - - - - -
-
-
- -
-
- - - - - + {/foreach}
+ {/foreach}
@@ -199,34 +126,15 @@ {$blocks['project_case_more']['value'] ?? ''}
- -
成都领地环金广场
+ {foreach $casesList as $case} +
+
{$case.title}
-

成都领地环金广场

- + -
-
- -
成都领地环金广场
-
-

成都领地环金广场

- + -
-
- -
成都领地环金广场
-
-

成都领地环金广场

- + -
-
- -
成都领地环金广场
-
-

成都领地环金广场

+

{$case.title}

+
+ {/foreach}
\ No newline at end of file diff --git a/view/manager/cases/add.html b/view/manager/cases/add.html index 1f64778..a5203f0 100755 --- a/view/manager/cases/add.html +++ b/view/manager/cases/add.html @@ -81,6 +81,14 @@ +
+ +
+ + +
+
+
diff --git a/view/manager/cases/edit.html b/view/manager/cases/edit.html index cccc1fe..631d134 100755 --- a/view/manager/cases/edit.html +++ b/view/manager/cases/edit.html @@ -80,6 +80,14 @@
+
+ +
+ + +
+
+
diff --git a/view/manager/content/cases.html b/view/manager/content/cases.html index 09f5c30..acf76e8 100755 --- a/view/manager/content/cases.html +++ b/view/manager/content/cases.html @@ -25,6 +25,7 @@ use app\model\Category as VCategory; + @@ -34,6 +35,7 @@ use app\model\Category as VCategory; 封面图-手机 状态 推荐 + 首页展示 操作 @@ -53,6 +55,7 @@ use app\model\Category as VCategory; {:$item.visible == 0 ? '隐藏' : '正常'} {$item.recommend == 0 ? '否' : '是'} + {$item.home == 0 ? '否' : '是'} 向上