更新:首页填充数据

virtual
zwesy 2020-11-25 18:48:29 +08:00
parent bddec3f2a6
commit ef905cf9f9
15 changed files with 256 additions and 155 deletions

View File

@ -49,4 +49,33 @@ class Article extends Base
$this->data['categoryId'] = $categoryId; $this->data['categoryId'] = $categoryId;
return $this->view($category['template_list'] ?? ''); return $this->view($category['template_list'] ?? '');
} }
//新闻列表
public function news($categoryId)
{
dump('新闻资讯');
dump($categoryId);
}
//新闻详情
public function newsDetail($newsId)
{
dump('新闻资讯详情');
dump($newsId);
}
// 产品列表
public function product($categoryId)
{
dump('产品列表');
dump($categoryId);
}
// 产品列表
public function productDetail($productId)
{
dump('产品详情');
dump($productId);
}
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace app\controller; namespace app\controller;
use app\model\{Category, Block}; use app\model\{Category, Block, Article};
class Index extends Base class Index extends Base
{ {
@ -11,7 +11,18 @@ class Index extends Base
$categoryId = $category['id'] ?? 0; $categoryId = $category['id'] ?? 0;
$this->data['categoryId'] = $categoryId; $this->data['categoryId'] = $categoryId;
$this->setSeo($this->system['seo_title'], $this->system['seo_keywords'], $this->system['seo_description']); $this->setSeo($this->system['seo_title'], $this->system['seo_keywords'], $this->system['seo_description']);
$this->data['blocks'] = Block::getByCategoryId($categoryId); $blocks = Block::getByCategoryId($categoryId);
$blocks = Block::analysisBlock($blocks);
$this->data['blocks'] = $blocks;
// 网络营销栏目ID
$this->data['marketingCId'] = Category::$CIdList['marketing_network'];
// 关联产品中心
$this->data['products'] = Article::getLatestByCategory(Category::$CIdList['products'], 4);;
// 关联企业新闻
$this->data['newsEnterprises'] = Article::getLatestByCategory(Category::$CIdList['news_enterprise'], 4);
// 关联行业资讯
$this->data['newsIndustries'] = Article::getLatestByCategory(Category::$CIdList['news_industry'], 4);;
//dump($this->data);
return $this->view(); return $this->view();
} }
} }

View File

@ -5,21 +5,41 @@ use app\model\{Category, Block};
class Page extends Base class Page extends Base
{ {
public function index($categoryId) private function getPageCommonData($categoryId)
{ {
$resp = true;
$category = Category::getById($categoryId); $category = Category::getById($categoryId);
if ($category) { if ($category) {
$description = $category['description'] ? $category['description'] : $this->system['seo_description']; $description = $category['description'] ? $category['description'] : $this->system['seo_description'];
$this->setSeo($category['title'], $this->system['seo_keywords'], $description); $this->setSeo($category['title'], $this->system['seo_keywords'], $description);
} else { } else {
return $this->error('错误页面'); $resp = false;
} }
$childCategory = Category::getChildrenByParentId($categoryId); $childCategory = Category::getChildrenByParentId($categoryId);
$this->data['categoryId'] = $categoryId; $this->data['categoryId'] = $categoryId;
$this->data['category'] = $category; $this->data['category'] = $category;
$this->data['childCategory'] = $childCategory; $this->data['childCategory'] = $childCategory;
$this->data['blocks'] = Block::getByCategoryId($categoryId); $this->data['blocks'] = Block::getByCategoryId($categoryId);
return $this->view($category['template_detail']); return $resp;
}
// 默认单页页面
public function index($categoryId)
{
$resp = $this->getPageCommonData($categoryId);
if(!$resp) {
return $this->error('错误页面');
}
return $this->view($this->data['category']['template_detail']);
}
// 营销页面
public function marketing($categoryId)
{
$resp = $this->getPageCommonData($categoryId);
if(!$resp) {
return $this->error('错误页面');
}
return $this->view($this->data['category']['template_detail']);
} }
} }

View File

@ -110,4 +110,19 @@ class Block extends Base
} }
return $data; return $data;
} }
// 解析单页块元素内容,把JSON化的内容转为数组格式
public static function analysisBlock(array $items)
{
$arrayToJsonTypes = [4];
if(count($items) > 0) {
foreach ($items as &$item) {
if(in_array($item['type'], $arrayToJsonTypes)) {
$item['value'] = empty($item['value']) ? [] : json_decode($item['value'], true);
}
}
unset($item);
}
return $items;
}
} }

View File

@ -3,6 +3,14 @@ namespace app\model;
class Category extends Base class Category extends Base
{ {
public static $CIdList = [
'marketing_network' => 16, // 网络营销
'products' => 2, // 产品中心
'news_enterprise' => 20, // 企业新闻
'news_industry' => 21, // 行业资讯
'news_dynamic' => 21, // 新闻动态
];
//获取首页栏目ID //获取首页栏目ID
public static function getIndex() public static function getIndex()
{ {

23
app/widget/Footer.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace app\widget;
use app\model\Category;
use app\model\System;
use think\facade\{View,Cache};
class Footer
{
public function index()
{
$menus = Cache::get('front_menus');
if (empty($menus)){
$menus = Category::getListForFrontMenu();
Cache::set('front_menus', $menus, 3600 * 12);
}
$data = [
'system' => System::getSystem(),
'footerMenus' => $menus,
];
return View::assign($data)->fetch('public/footer');
}
}

View File

@ -8,9 +8,10 @@ class Menu
{ {
public function index($categoryId) public function index($categoryId)
{ {
$menus = Cache::get('rules'); $menus = Cache::get('front_menus');
if(empty($menus)){ if(empty($menus)){
$menus = Category::getListForFrontMenu(); $menus = Category::getListForFrontMenu();
Cache::set('front_menus', $menus, 3600 * 12);
} }
$currentFirstId = 0; $currentFirstId = 0;
if (is_numeric($categoryId) && $categoryId > 0) { if (is_numeric($categoryId) && $categoryId > 0) {

View File

@ -161,6 +161,8 @@ tr.table-lv2:nth-child(1){ border:none;}
.layui-form-label{width: 90px; padding: 9px 0; text-align: left;} .layui-form-label{width: 90px; padding: 9px 0; text-align: left;}
.layui-form-label em{ color: #f20000; font-size: 20px; font-weight: bold; font-style: normal; margin-left: 2px; height: 16px; line-height: 16px; display: inline-block;} .layui-form-label em{ color: #f20000; font-size: 20px; font-weight: bold; font-style: normal; margin-left: 2px; height: 16px; line-height: 16px; display: inline-block;}
.layui-input-block{margin-left: 90px;} .layui-input-block{margin-left: 90px;}
.form-w-120 .layui-form-label{width: 120px;}
.form-w-120 .layui-input-block{margin-left: 120px;}
.search-form{display: inline-block} .search-form{display: inline-block}
.search-form .layui-form-item{margin-bottom: 0} .search-form .layui-form-item{margin-bottom: 0}
.search-form .layui-form-item .layui-inline{margin-bottom:0px;margin-right: 0px} .search-form .layui-form-item .layui-inline{margin-bottom:0px;margin-right: 0px}

View File

@ -13,3 +13,11 @@ use think\facade\Route;
Route::get('article/:id', "article/detail"); Route::get('article/:id', "article/detail");
Route::get('articles/:categoryId', "article/index"); Route::get('articles/:categoryId', "article/index");
Route::get('page/:categoryId', "page/index"); Route::get('page/:categoryId', "page/index");
// 新闻
Route::get('news/detail/:newsId', "article/newsDetail");
Route::get('news/:categoryId', "article/news");
// 产品
Route::get('product/detail/:productId', "article/productDetail");
Route::get('product/:categoryId', "article/product");
// 营销
Route::get('marketing/:categoryId', "page/marketing");

View File

@ -3,22 +3,18 @@
<div class="banner-box w-100"> <div class="banner-box w-100">
<div class="swiper-container"> <div class="swiper-container">
<div class="swiper-wrapper"> <div class="swiper-wrapper">
<div class="swiper-slide center-center" style="background-image: url(__IMG__/ban_1.jpg);"> {if isset($blocks['banner_top']) && count($blocks['banner_top']) > 0}
{foreach $blocks['banner_top']['value'] as $banner}
<div class="swiper-slide center-center" style="background-image: url({$banner['src']});">
<div class="w-1500"> <div class="w-1500">
<div class="pull-left"> <div class="pull-left">
<p>致力于将无穷的光明和动力<br>传输到祖国的大江南北</p> <p>{$banner['alt']|raw}</p>
<i>Great Rivers North and South Committed to <br>Transmitting Infinite Light and Power to the Motherland</i> <i>{$banner['desc']|raw}</i>
</div>
</div>
</div>
<div class="swiper-slide center-center" style="background-image: url(__IMG__/ban_1.jpg);">
<div class="w-1500">
<div class="pull-left">
<p>致力于将无穷的光明和动力<br>传输到祖国的大江南北</p>
<i>Great Rivers North and South Committed to <br>Transmitting Infinite Light and Power to the Motherland</i>
</div> </div>
</div> </div>
</div> </div>
{/foreach}
{/if}
</div> </div>
<div class="swiper-page"><div class="w-1500"><div class="swiper-pagination"></div></div></div> <div class="swiper-page"><div class="w-1500"><div class="swiper-pagination"></div></div></div>
</div> </div>
@ -28,64 +24,32 @@
<div class="w-1500"> <div class="w-1500">
<div class="all-title-box1 w-100"><span>产品中心</span><p>product center</p></div> <div class="all-title-box1 w-100"><span>产品中心</span><p>product center</p></div>
<div class="center-block w-100"> <div class="center-block w-100">
{if isset($products) && count($products) > 0}
<ul> <ul>
<li class="active"> {foreach $products as $idx => $product}
<div class="box-info" style="background-image: url(__IMG__/img_1.jpg);"> <li {if $idx == 0}class="active"{/if}>
<div class="box-info" style="background-image: url({$product['src']});">
<div class="box1"> <div class="box1">
<span>高压成套设备</span> <span>{$product['title']}</span>
<p>High-voltage<br>complete equipment</p> <p>{$product['summary']|raw}</p>
</div> </div>
<div class="box2"> <div class="box2">
<a href="">了解详情+</a> <a href="{:url('article/productDetail', ['productId'=>$product['id']])}">了解详情+</a>
<i>01</i> <i>{:str_pad($idx + 1, 2, '0', STR_PAD_LEFT)}</i>
</div>
</div>
</li>
<li>
<div class="box-info" style="background-image: url(__IMG__/img_1.jpg);">
<div class="box1">
<span>高压成套设备</span>
<p>High-voltage<br>complete equipment</p>
</div>
<div class="box2">
<a href="">了解详情+</a>
<i>02</i>
</div>
</div>
</li>
<li>
<div class="box-info" style="background-image: url(__IMG__/img_1.jpg);">
<div class="box1">
<span>高压成套设备</span>
<p>High-voltage<br>complete equipment</p>
</div>
<div class="box2">
<a href="">了解详情+</a>
<i>03</i>
</div>
</div>
</li>
<li>
<div class="box-info" style="background-image: url(__IMG__/img_1.jpg);">
<div class="box1">
<span>高压成套设备</span>
<p>High-voltage<br>complete equipment</p>
</div>
<div class="box2">
<a href="">了解详情+</a>
<i>04</i>
</div> </div>
</div> </div>
</li> </li>
{/foreach}
</ul> </ul>
{/if}
</div> </div>
</div> </div>
</div> </div>
<div class="home-box2 w-100"> <div class="home-box2 w-100" style="background-image: url({$blocks['marketing_background']['value'] ?? ''});">
<div class="w-1500"> <div class="w-1500">
<div class="pull-left column-between"> <div class="pull-left column-between">
<div class="all-title-box1 w-100"><span>网络营销</span><p>MARKETING NETWORK</p></div> <div class="all-title-box1 w-100"><span>{$blocks['marketing_name']['value'] ?? ''}</span><p>{$blocks['marketing_describe']['value'] ?? ''}</p></div>
<a href="">了解详情+</a> <a href="{:url('/marketing/'.$marketingCId)}">了解详情+</a>
</div> </div>
</div> </div>
</div> </div>
@ -95,97 +59,35 @@
<div class="lower-box w-100"> <div class="lower-box w-100">
<ul> <ul>
<p>企业新闻</p> <p>企业新闻</p>
{if isset($newsEnterprises) && count($newsEnterprises) > 0}
{foreach $newsEnterprises as $news}
<li> <li>
<a href=""> <a href="{:url('article/newsDetail', ['newsId'=>$news['id']])}">
<span>超宇助推中国化工企业加速数字化转型</span> <span>{$news['title']|raw}</span>
<i>2020-10-10</i> <i>{$news['create_time']|date='Y-m-d'}</i>
</a>
</li>
<li>
<a href="">
<span>超宇助推中国化工企业加速数字化转型</span>
<i>2020-10-10</i>
</a>
</li>
<li>
<a href="">
<span>超宇助推中国化工企业加速数字化转型</span>
<i>2020-10-10</i>
</a>
</li>
<li>
<a href="">
<span>超宇助推中国化工企业加速数字化转型</span>
<i>2020-10-10</i>
</a> </a>
</li> </li>
{/foreach}
{/if}
</ul> </ul>
<ul> <ul>
<p>行业资讯</p> <p>行业资讯</p>
{if isset($newsIndustries) && count($newsIndustries) > 0}
{foreach $newsIndustries as $news}
<li> <li>
<a href=""> <a href="{:url('article/newsDetail', ['newsId'=>$news['id']])}">
<span>超宇助推中国化工企业加速数字化转型</span> <span>{$news['title']|raw}</span>
<i>2020-10-10</i> <i>{$news['create_time']|date='Y-m-d'}</i>
</a>
</li>
<li>
<a href="">
<span>超宇助推中国化工企业加速数字化转型</span>
<i>2020-10-10</i>
</a>
</li>
<li>
<a href="">
<span>超宇助推中国化工企业加速数字化转型</span>
<i>2020-10-10</i>
</a>
</li>
<li>
<a href="">
<span>超宇助推中国化工企业加速数字化转型</span>
<i>2020-10-10</i>
</a> </a>
</li> </li>
{/foreach}
{/if}
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="foot-box w-100 center-center">
<div class="w-1200">
<div class="top-box w-100 between-top">
<div class="fl"><img src="__IMG__/logo2.png" ></div>
<div class="fr">
<a href="">首页</a>
<a href="">走进超宇</a>
<a href="">产品中心</a>
<a href="">品质与服务</a>
<a href="">营销网络</a>
<a href="">新闻动态</a>
<a href="">联系我们</a>
</div>
</div>
<div class="lower-box w-100">
<div class="column-between">
<p>
四川超宇科技有限公司<br>
Sichuan Chaoyu<br>
Technology Co., Ltd.
</p>
<p><i>Copyright C2020蜀ICP备14003714号-1</i></p>
</div>
<div class="column-between">
<p><span>电话/Tel: 028-8561 6928</span></p>
<p><span>邮箱/E-mail: 1825981925@qq.com</span></p>
<p>
地址/Add:成都市双流区蛟龙工业港南河路318号<br>
<i>No.318 Nanhe Road, Jiaolong Industrial Area <br>Shuangliu District, Chengdu ,Sichuan Province</i>
</p>
</div>
<div class="ewm"><img src="__IMG__/ewm_1.jpg" ><p>微信二维码/Wechant</p></div>
</div>
</div>
</div>
<script> <script>
var swiper = new Swiper('.banner-box .swiper-container', { var swiper = new Swiper('.banner-box .swiper-container', {

View File

@ -29,7 +29,7 @@
<body> <body>
{:widget('menu/index', ['categoryId' => $categoryId])} {:widget('menu/index', ['categoryId' => $categoryId])}
{__CONTENT__} {__CONTENT__}
{include file="public/footer"} {:widget('footer/index')}
<script src="__JS__/script.js?v={$system.js_version}" type="text/javascript" charset="utf-8"></script> <script src="__JS__/script.js?v={$system.js_version}" type="text/javascript" charset="utf-8"></script>
</body> </body>
</html> </html>

View File

@ -83,7 +83,7 @@ use app\service\Image as CImage;
</td> </td>
<td><a class="layui-btn layui-btn-title" data-state="edit" data-href="{:url('manager.article/edit',['id' => $item['id']])}" title="编辑">{$item.title}</a></td> <td><a class="layui-btn layui-btn-title" data-state="edit" data-href="{:url('manager.article/edit',['id' => $item['id']])}" title="编辑">{$item.title}</a></td>
<td>{$item.views}</td> <td>{$item.views}</td>
<td>{$item.create_time}</td> <td>{$item.create_time|date='Y-m-d'}</td>
<td>{$item.sort}</td> <td>{$item.sort}</td>
<td style="color: #2887fc;">{$item.top?'已置顶':''} {$item.hot?'已热门':''} {$item.recommend?'已推荐':''}</td> <td style="color: #2887fc;">{$item.top?'已置顶':''} {$item.hot?'已热门':''} {$item.recommend?'已推荐':''}</td>
<td> <td>

View File

@ -8,20 +8,48 @@
</ul> </ul>
<div class="layui-tab-content"> <div class="layui-tab-content">
<div class="layui-tab-item layui-show"> <div class="layui-tab-item layui-show">
<form data-action="{:url('manager.system/index')}" class="layui-form"> <form data-action="{:url('manager.system/index')}" class="layui-form form-w-120">
<input type="hidden" name="_token" value="{$_token ?? ''}"/> <input type="hidden" name="_token" value="{$_token ?? ''}"/>
<div class="system_title">公司信息</div> <div class="system_title">公司信息</div>
<div class="layui-form-itemBox1 between-center"> <div class="layui-form-itemBox1 between-center">
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">公司名称</label> <label class="layui-form-label">公司名称 [中]</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="item[company_name]" value="{$item['company_name']?$item['company_name']:''}"/> <input class="layui-input" type="text" name="item[company_name]" value="{$item['company_name']?$item['company_name']:''}" placeholder="公司全称,如某某科技有限公司"/>
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">公司地址</label> <label class="layui-form-label">公司地址 [中]</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="item[company_addr]" value="{$item['company_addr']?$item['company_addr']:''}"/> <input class="layui-input" type="text" name="item[company_addr]" value="{$item['company_addr']?$item['company_addr']:''}" />
</div>
</div>
</div>
<div class="layui-form-itemBox1 between-center">
<div class="layui-form-item">
<label class="layui-form-label">公司简称 [英]</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="item[company_name_en]" value="{$item['company_name_en']?$item['company_name_en']:''}" placeholder="公司英文简称, 如Sichuan Dxtc" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">公司区域地址 [英]</label>
<div class="layui-input-block">
<input name="item[company_addr_en]" class="layui-input" type="text" value="{$item['company_addr_en']?$item['company_addr_en']:''}" placeholder="精确到区县一级" />
</div>
</div>
</div>
<div class="layui-form-itemBox1 between-center">
<div class="layui-form-item">
<label class="layui-form-label">公司性质 [英]</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="item[company_type_en]" value="{$item['company_type_en']?$item['company_type_en']:''}" placeholder="如Technology Co., Ltd."/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">公司详细地址 [英]</label>
<div class="layui-input-block">
<input name="item[company_addr_detail_en]" class="layui-input" type="text" value="{$item['company_addr_detail_en']?$item['company_addr_detail_en']:''}" placeholder="精确到街道号"/>
</div> </div>
</div> </div>
</div> </div>
@ -33,7 +61,7 @@
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">联系电话</label> <label class="layui-form-label">公司联系电话</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input name="item[company_tel]" class="layui-input" type="text" value="{$item['company_tel']?$item['company_tel']:''}" /> <input name="item[company_tel]" class="layui-input" type="text" value="{$item['company_tel']?$item['company_tel']:''}" />
</div> </div>
@ -47,9 +75,9 @@
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">域名备案号</label> <label class="layui-form-label">公司联系邮箱</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="item[company_copy]" value="{$item['company_copy']?$item['company_copy']:''}"/> <input class="layui-input" type="text" name="item[company_email]" value="{$item['company_email']?$item['company_email']:''}"/>
</div> </div>
</div> </div>
</div> </div>
@ -60,6 +88,12 @@
<input class="layui-input" type="text" name="item[company_copyright]" value="{$item['company_copyright']?$item['company_copyright']:''}" /> <input class="layui-input" type="text" name="item[company_copyright]" value="{$item['company_copyright']?$item['company_copyright']:''}" />
</div> </div>
</div> </div>
<div class="layui-form-item">
<label class="layui-form-label">域名备案号</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="item[company_copy]" value="{$item['company_copy']?$item['company_copy']:''}"/>
</div>
</div>
</div> </div>
<div class="system_title">SEO信息</div> <div class="system_title">SEO信息</div>
<div class="layui-form-itemBox2 between"> <div class="layui-form-itemBox2 between">

View File

@ -1 +1,47 @@
<div style="display: none;">{$system['statistics']??''}</div> <div class="foot-box w-100 center-center">
<div class="w-1200">
<div class="top-box w-100 between-top">
<div class="fl"><img src="__IMG__/logo2.png" ></div>
<div class="fr">
{if isset($footerMenus) && count($footerMenus) > 0}
{foreach footerMenus as $menu}
{php}
$aHref = 'javascript:;';
if (!empty($menu['url'])) {
$aHref = $menu['url'];
} elseif ($menu['is_index']) {
$aHref = url('/');
} elseif (!empty($menu['template_list'])) {
$aHref = url('/'.$menu['template_list'].'/'.$menu['id']);
} elseif (!empty($menu['template'])) {
$aHref = url('/'.$menu['template'].'/'.$menu['id']);
}
{/php}
<a href="{$aHref}">{$menu['title']}</a>
{/foreach}
{/if}
</div>
</div>
<div class="lower-box w-100">
<div class="column-between">
<p>
{$system['company_name'] ?? ''}<br>
{$system['company_name_en'] ?? ''}<br>
{$system['company_type_en'] ?? ''}
</p>
<p><i>{$system['company_copyright'] ?? ''}{$system['company_copy'] ?? ''}</i></p>
</div>
<div class="column-between">
<p><span>电话/Tel: {$system['company_tel'] ?? ''}</span></p>
<p><span>邮箱/E-mail: {$system['company_email'] ?? ''}</span></p>
<p>
地址/Add:{$system['company_addr'] ?? ''}<br>
<i>{$system['company_addr_detail_en'] ?? ''} <br>{$system['company_addr_en'] ?? ''}</i>
</p>
</div>
<div class="ewm"><img src="__IMG__/ewm_1.jpg" ><p>微信二维码/Wechant</p></div>
</div>
</div>
</div>
<div class="foot-statistics-code" style="display: none;">{$system['statistics']??''}</div>

View File

@ -18,6 +18,8 @@ function getMenus($menus, $level = 1, $currentFirstId, $categoryId) {
$aHref = $menu['url']; $aHref = $menu['url'];
} elseif ($menu['is_index']) { } elseif ($menu['is_index']) {
$aHref = url('/'); $aHref = url('/');
} elseif (!empty($menu['template_list'])) {
$aHref = url('/'.$menu['template_list'].'/'.$menu['id']);
} elseif (!empty($menu['template'])) { } elseif (!empty($menu['template'])) {
$aHref = url('/'.$menu['template'].'/'.$menu['id']); $aHref = url('/'.$menu['template'].'/'.$menu['id']);
} }