更新:首页数据调整

virtual
zwesy 2020-12-03 16:06:33 +08:00
parent c17d3b62e7
commit c60a8ed350
3 changed files with 32 additions and 27 deletions

View File

@ -19,11 +19,19 @@ class Index extends Base
// 网络营销栏目ID // 网络营销栏目ID
$this->data['marketingCId'] = Category::$CIdList['marketing']; $this->data['marketingCId'] = Category::$CIdList['marketing'];
// 关联产品中心 // 关联产品中心
$this->data['products'] = Article::getLatestByCategory(Category::$CIdList['products'], 4);; $this->data['products'] = [
// 关联企业新闻 'category' => Category::getById(Category::$CIdList['products']),
$this->data['newsEnterprises'] = Article::getLatestByCategory(Category::$CIdList['news_children']['enterprise'], 4); 'items' => Article::getLatestByCategory(Category::$CIdList['products'], 4)
// 关联行业资讯 ];
$this->data['newsIndustries'] = Article::getLatestByCategory(Category::$CIdList['news_children']['industry'], 4);; // 关联新闻
$this->data['newsCenter'] = Category::getById(Category::$CIdList['news']);
$newsCIdList = [Category::$CIdList['news_children']['enterprise'], Category::$CIdList['news_children']['industry']];
$newsList = Category::getListByIds($newsCIdList);
foreach ($newsList as &$cate) {
$cate['items'] = Article::getLatestByCategory($cate['id'], 4);
}
unset($cate);
$this->data['newsList'] = $newsList;
return $this->view(); return $this->view();
} }
} }

View File

@ -7,12 +7,18 @@ class Base extends Model
{ {
protected $autoWriteTimestamp = false; protected $autoWriteTimestamp = false;
//根据Id列表获取列表 //根据Id列表获取列表
public static function getListByIds($ids) public static function getListByIds($ids, $order = [])
{ {
if(count($ids) == 0 || empty($ids)) { if(count($ids) == 0 || empty($ids)) {
return []; return [];
} }
return self::where('id', 'in', $ids)->select()->toArray(); if(empty($order)) {
$order = ['id'=>'asc'];
}
return self::where('id', 'in', $ids)
->order($order)
->select()
->toArray();
} }
//根据ID获取单条数据 //根据ID获取单条数据
public static function getById($id) public static function getById($id)

View File

@ -22,11 +22,11 @@
<div class="all-center-box"> <div class="all-center-box">
<div class="home-box1 w-100"> <div class="home-box1 w-100">
<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>{$products['category']['title'] ?? '产品中心'}</span><p>{$products['category']['description'] ?? 'product center'}</p></div>
<div class="center-block w-100"> <div class="center-block w-100">
{if isset($products) && count($products) > 0} {if isset($products) && count($products['items']) > 0}
<ul> <ul>
{foreach $products as $idx => $product} {foreach $products['items'] as $idx => $product}
<li {if $idx == 0}class="active"{/if}> <li {if $idx == 0}class="active"{/if}>
<div class="box-info" style="background-image: url({$product['src']});"> <div class="box-info" style="background-image: url({$product['src']});">
<div class="box1"> <div class="box1">
@ -55,12 +55,14 @@
</div> </div>
<div class="home-box3 w-100"> <div class="home-box3 w-100">
<div class="w-1200"> <div class="w-1200">
<div class="top-box w-100"><div class="between-bottom"><span>新闻动态</span><i>NEWS</i></div></div> <div class="top-box w-100"><div class="between-bottom"><span>{$newsCenter['title'] ?? '新闻动态'}</span><i>{$newsCenter['description'] ?? ''}</i></div></div>
<div class="lower-box w-100"> <div class="lower-box w-100">
{if isset($newsList) && count($newsList) > 0}
{foreach $newsList as $newsCate}
<ul> <ul>
<p>企业新闻</p> <p>{$newsCate.title ?? ''}</p>
{if isset($newsEnterprises) && count($newsEnterprises) > 0} {if isset($newsCate['items']) && count($newsCate['items']) > 0}
{foreach $newsEnterprises as $news} {foreach $newsCate['items'] as $news}
<li> <li>
<a href="{:url('article/detail', ['id'=>$news['id']])}"> <a href="{:url('article/detail', ['id'=>$news['id']])}">
<span>{$news['title']|raw}</span> <span>{$news['title']|raw}</span>
@ -70,19 +72,8 @@
{/foreach} {/foreach}
{/if} {/if}
</ul> </ul>
<ul>
<p>行业资讯</p>
{if isset($newsIndustries) && count($newsIndustries) > 0}
{foreach $newsIndustries as $news}
<li>
<a href="{:url('article/detail', ['id'=>$news['id']])}">
<span>{$news['title']|raw}</span>
<i>{$news['create_time']|date='Y-m-d'}</i>
</a>
</li>
{/foreach} {/foreach}
{/if} {/if}
</ul>
</div> </div>
</div> </div>
</div> </div>