更新:产品中心调整为支持多分类展示
parent
2607864b7d
commit
abb2071c29
|
@ -67,14 +67,17 @@ class Article extends Base
|
|||
} else {
|
||||
$topCategory = Category::getById($TopCId);
|
||||
}
|
||||
$categoryChildren = Category::getChildrenByParentId($topCategory['id']);
|
||||
$this->data['topCategory'] = $topCategory;
|
||||
$this->data['categoryChildren'] = Category::getChildrenByParentId($topCategory['id']);
|
||||
$this->data['categoryChildren'] = $categoryChildren;
|
||||
switch($template) {
|
||||
case 'products' :
|
||||
$this->assignProducts($topCategory, $category, $categoryChildren);
|
||||
break;
|
||||
case 'news' :
|
||||
$this->assignNews($topCategory, $category);
|
||||
break;
|
||||
default :
|
||||
|
||||
$this->data['items'] = MArticle::getListPageByCategory($category['id'], $category['number'] ? $category['number'] : 20);
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +88,21 @@ class Article extends Base
|
|||
|
||||
}
|
||||
|
||||
// 产品中心 - 展示当前分类和所有子类产品
|
||||
private function assignProducts($topCategory, $category, $categoryChildren)
|
||||
{
|
||||
$keyword = input('param.keyword', '');
|
||||
$cateIds[] = $category['id'];
|
||||
if($topCategory['id'] == $category['id']) {
|
||||
$children = $categoryChildren;
|
||||
} else {
|
||||
$children = Category::getChildrenByParentId($category['id']);
|
||||
}
|
||||
foreach ($children as $child) {
|
||||
$cateIds[] = $child['id'];
|
||||
}
|
||||
$this->data['items'] = MArticle::getListPageByCategories($cateIds, $category['number'] ? $category['number'] : 20, $keyword);
|
||||
}
|
||||
|
||||
// 新闻
|
||||
private function assignNews($topCategory, $category)
|
||||
|
|
|
@ -246,7 +246,7 @@ class Article extends Base
|
|||
'query' => $param
|
||||
];
|
||||
if(empty($order)) {
|
||||
$order = ['create_time'=>'desc'];
|
||||
$order = ['sort'=>'desc'];
|
||||
}
|
||||
return self::where($where)
|
||||
->order($order)
|
||||
|
|
|
@ -15,8 +15,6 @@ class Category extends Base
|
|||
'honors_manage' => 26, // 荣誉资质管理
|
||||
'history_manage' => 29, // 发展历程管理
|
||||
'products' => 2, // 产品中心
|
||||
'products' => 2, // 产品中心
|
||||
'products' => 2, // 产品中心
|
||||
'service' => 5, // 品质与服务
|
||||
'service_children' => [
|
||||
'before' => 12, // 售前服务
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
// +----------------------------------------------------------------------
|
||||
use think\facade\Route;
|
||||
|
||||
Route::rule('products', 'article/index')->name('products');
|
||||
Route::get('article/:id', "article/detail");
|
||||
Route::get('articles/:category_id', "article/index");
|
||||
Route::get('page/:category_id', "page/index");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{layout name="layout" /}
|
||||
|
||||
<!-- banner -->
|
||||
<div class="page-banner w-100" style="background-image: url({:getImgSrc($category, '__IMG__/page_ban3.jpg')});">
|
||||
<div class="page-banner w-100" style="background-image: url({:getImgSrc($topCategory, '__IMG__/page_ban3.jpg')});">
|
||||
<div class="info">
|
||||
<div class="w-1200">
|
||||
<strong>{$category.title ?? ''}</strong>
|
||||
|
@ -12,6 +12,20 @@
|
|||
<!-- -->
|
||||
<div class="all-center-box">
|
||||
<div class="product-box w-100">
|
||||
<div class="w-1200">
|
||||
<form action="{:url('products')}" method="get">
|
||||
<select name="category_id">
|
||||
<option value="{$topCategory.id}">产品选择</option>
|
||||
{if isset($categoryChildren) && count($categoryChildren) >0}
|
||||
{foreach $categoryChildren as $cate}
|
||||
<option value="{$cate.id}" {if $categoryId == $cate.id}selected="selected"{/if}>{$cate.title}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
<input name="keyword" placeholder="关键词查询..."/>
|
||||
<button type="submit">查询</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="w-1200">
|
||||
{if isset($items)}
|
||||
<div class="center-block w-100">
|
||||
|
|
Loading…
Reference in New Issue