更新:首页数据调整
parent
c17d3b62e7
commit
c60a8ed350
|
@ -19,11 +19,19 @@ class Index extends Base
|
|||
// 网络营销栏目ID
|
||||
$this->data['marketingCId'] = Category::$CIdList['marketing'];
|
||||
// 关联产品中心
|
||||
$this->data['products'] = Article::getLatestByCategory(Category::$CIdList['products'], 4);;
|
||||
// 关联企业新闻
|
||||
$this->data['newsEnterprises'] = Article::getLatestByCategory(Category::$CIdList['news_children']['enterprise'], 4);
|
||||
// 关联行业资讯
|
||||
$this->data['newsIndustries'] = Article::getLatestByCategory(Category::$CIdList['news_children']['industry'], 4);;
|
||||
$this->data['products'] = [
|
||||
'category' => Category::getById(Category::$CIdList['products']),
|
||||
'items' => Article::getLatestByCategory(Category::$CIdList['products'], 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();
|
||||
}
|
||||
}
|
|
@ -7,12 +7,18 @@ class Base extends Model
|
|||
{
|
||||
protected $autoWriteTimestamp = false;
|
||||
//根据Id列表获取列表
|
||||
public static function getListByIds($ids)
|
||||
public static function getListByIds($ids, $order = [])
|
||||
{
|
||||
if(count($ids) == 0 || empty($ids)) {
|
||||
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获取单条数据
|
||||
public static function getById($id)
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
<div class="all-center-box">
|
||||
<div class="home-box1 w-100">
|
||||
<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">
|
||||
{if isset($products) && count($products) > 0}
|
||||
{if isset($products) && count($products['items']) > 0}
|
||||
<ul>
|
||||
{foreach $products as $idx => $product}
|
||||
{foreach $products['items'] as $idx => $product}
|
||||
<li {if $idx == 0}class="active"{/if}>
|
||||
<div class="box-info" style="background-image: url({$product['src']});">
|
||||
<div class="box1">
|
||||
|
@ -55,12 +55,14 @@
|
|||
</div>
|
||||
<div class="home-box3 w-100">
|
||||
<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">
|
||||
{if isset($newsList) && count($newsList) > 0}
|
||||
{foreach $newsList as $newsCate}
|
||||
<ul>
|
||||
<p>企业新闻</p>
|
||||
{if isset($newsEnterprises) && count($newsEnterprises) > 0}
|
||||
{foreach $newsEnterprises as $news}
|
||||
<p>{$newsCate.title ?? ''}</p>
|
||||
{if isset($newsCate['items']) && count($newsCate['items']) > 0}
|
||||
{foreach $newsCate['items'] as $news}
|
||||
<li>
|
||||
<a href="{:url('article/detail', ['id'=>$news['id']])}">
|
||||
<span>{$news['title']|raw}</span>
|
||||
|
@ -70,19 +72,8 @@
|
|||
{/foreach}
|
||||
{/if}
|
||||
</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}
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue