mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2026-06-07 02:12:25 +08:00
新增面包屑导航
This commit is contained in:
@ -152,6 +152,10 @@ class Goods extends Common
|
||||
// 是否商品详情页展示相册
|
||||
MyViewAssign('common_is_goods_detail_show_photo', MyC('common_is_goods_detail_show_photo', 0, true));
|
||||
|
||||
// 面包屑导航
|
||||
$breadcrumb_data = GoodsService::GoodsBreadcrumbData($goods);
|
||||
MyViewAssign('breadcrumb_data', $breadcrumb_data);
|
||||
|
||||
// 加载放大镜
|
||||
MyViewAssign('is_load_imagezoom', 1);
|
||||
|
||||
|
||||
@ -109,6 +109,10 @@ class Search extends Common
|
||||
// 排序方式
|
||||
MyViewAssign('map_order_by_list', SearchService::SearchMapOrderByList($this->data_request));
|
||||
|
||||
// 面包屑导航
|
||||
$breadcrumb_data = SearchService::SearchBreadcrumbData($params);
|
||||
MyViewAssign('breadcrumb_data', $breadcrumb_data);
|
||||
|
||||
// 搜索记录
|
||||
$params['user_id'] = empty($this->user) ? 0 : $this->user['id'];
|
||||
$params['search_result_data'] = $ret['data'];
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
{{foreach $goods_category_list as $v}}
|
||||
<li class="am-fl">
|
||||
<div class="item-content am-text-center am-margin-xs">
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$v['id']])}}" title="{{$v.name}}" class="am-block am-padding-xs">
|
||||
<a href="{{:MyUrl('index/search/index', ['cid'=>$v['id']])}}" title="{{$v.name}}" class="am-block am-padding-xs">
|
||||
{{if !empty($v['icon'])}}
|
||||
<img src="{{$v.icon}}" alt="{{$v.name}}" class="category-icon am-block am-margin-bottom-xs" />
|
||||
{{/if}}
|
||||
@ -37,14 +37,14 @@
|
||||
{{else /}}
|
||||
<ul class="category-nav am-fl">
|
||||
{{foreach $goods_category_list as $k=>$v}}
|
||||
<li class="am-text-break am-padding-horizontal-sm {{if $k eq 0}} active{{/if}}" data-url="{{:MyUrl('index/search/index', ['category_id'=>$v['id']])}}">{{$v.name}}</li>
|
||||
<li class="am-text-break am-padding-horizontal-sm {{if $k eq 0}} active{{/if}}" data-url="{{:MyUrl('index/search/index', ['cid'=>$v['id']])}}">{{$v.name}}</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
{{foreach $goods_category_list as $k=>$v}}
|
||||
<div class="category-content category-content-{{$k}} am-fr am-padding-vertical-xs {{if $k neq 0}} none{{/if}}">
|
||||
{{if !empty($v['vice_name']) or !empty($v['describe'])}}
|
||||
<div class="category-item am-padding-sm am-margin-bottom-sm one-cetegory">
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$v['id']])}}" title="{{$v.name}}">
|
||||
<a href="{{:MyUrl('index/search/index', ['cid'=>$v['id']])}}" title="{{$v.name}}">
|
||||
<div>
|
||||
{{if !empty($v['vice_name'])}}
|
||||
<strong {{if !empty($v['bg_color'])}}style="color:{{$v.bg_color}};"{{/if}} class="am-text-sm am-margin-right-sm">{{$v.vice_name}}</strong>
|
||||
@ -63,12 +63,12 @@
|
||||
{{foreach $v.items as $vs}}
|
||||
<li class="am-fl am-text-center">
|
||||
{{if !empty($vs['icon'])}}
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$vs['id']])}}" title="{{$vs.name}}" class="am-block">
|
||||
<a href="{{:MyUrl('index/search/index', ['cid'=>$vs['id']])}}" title="{{$vs.name}}" class="am-block">
|
||||
<img src="{{$vs.icon}}" alt="{{$vs.name}}" class="category-icon am-block am-margin-bottom-xs" />
|
||||
</a>
|
||||
{{/if}}
|
||||
<p>
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$vs['id']])}}" title="{{$vs.name}}" class="am-block">{{$vs.name}}</a>
|
||||
<a href="{{:MyUrl('index/search/index', ['cid'=>$vs['id']])}}" title="{{$vs.name}}" class="am-block">{{$vs.name}}</a>
|
||||
</p>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
@ -77,7 +77,7 @@
|
||||
{{elseif $category_show_level eq 3}}
|
||||
{{foreach $v.items as $vs}}
|
||||
<div class="category-item am-padding-sm">
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$vs['id']])}}" title="{{$vs.name}}">
|
||||
<a href="{{:MyUrl('index/search/index', ['cid'=>$vs['id']])}}" title="{{$vs.name}}">
|
||||
<div class="am-text-center">
|
||||
<strong>{{$vs.name}}</strong>
|
||||
</div>
|
||||
@ -87,12 +87,12 @@
|
||||
{{foreach $vs.items as $kss=>$vss}}
|
||||
<li class="am-fl am-text-center">
|
||||
{{if !empty($vss['icon'])}}
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$vss['id']])}}" title="{{$vss.name}}" class="am-block">
|
||||
<a href="{{:MyUrl('index/search/index', ['cid'=>$vss['id']])}}" title="{{$vss.name}}" class="am-block">
|
||||
<img src="{{$vss.icon}}" alt="{{$vss.name}}" class="category-icon am-block am-margin-bottom-xs" />
|
||||
</a>
|
||||
{{/if}}
|
||||
<p>
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$vss['id']])}}" title="{{$vss.name}}" class="am-block">{{$vss.name}}</a>
|
||||
<a href="{{:MyUrl('index/search/index', ['cid'=>$vss['id']])}}" title="{{$vss.name}}" class="am-block">{{$vss.name}}</a>
|
||||
</p>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
@ -106,7 +106,7 @@
|
||||
<i class="am-icon-warning"></i>
|
||||
<span>没有子分类数据</span>
|
||||
<p class="am-margin-top-lg am-text-center">
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$v['id']])}}" class="am-text-secondary" title="查看分类下商品">查看分类下商品 >></a>
|
||||
<a href="{{:MyUrl('index/search/index', ['cid'=>$v['id']])}}" class="am-text-secondary" title="查看分类下商品">查看分类下商品 >></a>
|
||||
</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
@ -12,6 +12,10 @@
|
||||
<!-- goods category -->
|
||||
{{include file="public/goods_category" /}}
|
||||
|
||||
<!-- 面包屑导航 -->
|
||||
{{include file="public/breadcrumb_data" /}}
|
||||
|
||||
<!-- 商品详情 -->
|
||||
<div class="goods-detail" data-id="{{$goods.id}}" data-spec-detail-ajax-url="{{:MyUrl('index/goods/specdetail')}}" data-spec-type-ajax-url="{{:MyUrl('index/goods/spectype')}}">
|
||||
<!-- 轮播 -->
|
||||
<div class="scoll">
|
||||
|
||||
@ -177,7 +177,7 @@
|
||||
{{/if}}
|
||||
</div>
|
||||
<span class="more">
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$floor['id']])}}" target="_blank">更多 <i class="am-icon-angle-right"></i></a>
|
||||
<a href="{{:MyUrl('index/search/index', ['cid'=>$floor['id']])}}" target="_blank">更多 <i class="am-icon-angle-right"></i></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -208,7 +208,7 @@
|
||||
<div class="word">
|
||||
{{if !empty($floor['items']) and is_array($floor['items'])}}
|
||||
{{foreach $floor.items as $category_key=>$category}}
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$category['id']])}}" class="outer" target="_blank">{{:mb_substr($category['name'], 0, 4, 'utf-8')}}</a>
|
||||
<a href="{{:MyUrl('index/search/index', ['cid'=>$category['id']])}}" class="outer" target="_blank">{{:mb_substr($category['name'], 0, 4, 'utf-8')}}</a>
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
</div>
|
||||
@ -216,7 +216,7 @@
|
||||
<div class="describe">{{$floor.describe}}</div>
|
||||
</div>
|
||||
{{if !empty($floor['big_images'])}}
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$floor['id']])}}" target="_blank">
|
||||
<a href="{{:MyUrl('index/search/index', ['cid'=>$floor['id']])}}" target="_blank">
|
||||
<img src="{{$floor.big_images}}" />
|
||||
</a>
|
||||
{{/if}}
|
||||
|
||||
40
app/index/view/default/public/breadcrumb_data.html
Normal file
40
app/index/view/default/public/breadcrumb_data.html
Normal file
@ -0,0 +1,40 @@
|
||||
{{if !empty($breadcrumb_data)}}
|
||||
<div class="breadcrumb-data am-hide-sm-only">
|
||||
<div class="am-container">
|
||||
<ol class="am-breadcrumb am-margin-bottom-0">
|
||||
{{foreach $breadcrumb_data as $v}}
|
||||
{{if !empty($v['name'])}}
|
||||
{{switch $v.type}}
|
||||
{{case 0}}
|
||||
<li {{if empty($v['url'])}}class="am-active"{{/if}}>
|
||||
{{if !empty($v['url'])}}<a href="{{$v.url}}">{{/if}}
|
||||
{{if !empty($v['icon'])}}<i class="{{$v.icon}}"></i>{{/if}}
|
||||
{{$v.name}}
|
||||
{{if !empty($v['url'])}}</a>{{/if}}
|
||||
</li>
|
||||
{{/case}}
|
||||
{{case 1}}
|
||||
{{if !empty($v['data']) and is_array($v['data'])}}
|
||||
<li>
|
||||
<a href="javascript:;">
|
||||
<div class="am-dropdown" data-am-dropdown>
|
||||
<span class="am-dropdown-toggle" data-am-dropdown-toggle>{{$v.name}} <i class="am-icon-angle-down"></i></span>
|
||||
<ul class="am-dropdown-content">
|
||||
{{foreach $v.data as $vs}}
|
||||
{{if !empty($vs['name']) and !empty($vs['url'])}}
|
||||
<li><a href="{{$vs.url}}">{{$vs.name}}</a></li>
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/case}}
|
||||
{{/switch}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
@ -26,6 +26,9 @@
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<!-- 面包屑导航 -->
|
||||
{{include file="public/breadcrumb_data" /}}
|
||||
|
||||
<!-- content -->
|
||||
<div class="am-container">
|
||||
<!-- 搜索页面顶部内部结构里面钩子 -->
|
||||
|
||||
@ -3122,5 +3122,66 @@ class GoodsService
|
||||
}
|
||||
return DataReturn('处理成功', 0, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品面包屑导航数据
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2022-07-06
|
||||
* @desc description
|
||||
* @param [array] $goods [商品信息]
|
||||
*/
|
||||
public static function GoodsBreadcrumbData($goods)
|
||||
{
|
||||
// 默认首页
|
||||
$result = [
|
||||
[
|
||||
'type' => 0,
|
||||
'name' => '首页',
|
||||
'url' => SystemService::HomeUrl(),
|
||||
'icon' => 'am-icon-home',
|
||||
],
|
||||
];
|
||||
// 商品分类
|
||||
$cids = Db::name('GoodsCategoryJoin')->where(['goods_id'=>$goods['id']])->column('category_id');
|
||||
if(!empty($cids))
|
||||
{
|
||||
$where = [
|
||||
['id', 'in', $cids],
|
||||
['is_enable', '=', 1],
|
||||
];
|
||||
$category = Db::name('GoodsCategory')->where($where)->field('id,name')->select()->toArray();
|
||||
if(!empty($category))
|
||||
{
|
||||
$category = array_map(function($v)
|
||||
{
|
||||
$v['url'] = MyUrl('index/search/index', ['cid'=>$v['id']]);
|
||||
return $v;
|
||||
}, $category);
|
||||
if(count($category) == 1)
|
||||
{
|
||||
$result[] = [
|
||||
'type' => 0,
|
||||
'name' => $category[0]['name'],
|
||||
'url' => $category[0]['url'],
|
||||
];
|
||||
} else {
|
||||
$result[] = [
|
||||
'type' => 1,
|
||||
'name' => '商品分类',
|
||||
'data' => $category,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 当前商品名称
|
||||
$result[] = [
|
||||
'type' => 0,
|
||||
'name' => $goods['title'],
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -192,7 +192,7 @@ class NavigationService
|
||||
|
||||
// 商品分类
|
||||
case 'goods_category':
|
||||
$v['url'] = MyUrl('index/search/index', ['category_id'=>$v['value']]);
|
||||
$v['url'] = MyUrl('index/search/index', ['cid'=>$v['value']]);
|
||||
break;
|
||||
|
||||
// 页面设计
|
||||
|
||||
@ -798,7 +798,173 @@ class SearchService
|
||||
'category' => empty($category) ? null : $category,
|
||||
'brand' => empty($brand) ? null : $brand,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索面包屑导航
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2022-07-06
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function SearchBreadcrumbData($params = [])
|
||||
{
|
||||
// 默认首页
|
||||
$result = [
|
||||
[
|
||||
'type' => 0,
|
||||
'name' => '首页',
|
||||
'url' => SystemService::HomeUrl(),
|
||||
'icon' => 'am-icon-home',
|
||||
],
|
||||
];
|
||||
// 商品分类
|
||||
$temp_data = [];
|
||||
if(!empty($params['cid']))
|
||||
{
|
||||
// 一级
|
||||
$where = [
|
||||
['id', '=', intval($params['cid'])],
|
||||
['is_enable', '=', 1],
|
||||
];
|
||||
$category = Db::name('GoodsCategory')->where($where)->field('id,pid,name')->find();
|
||||
if(!empty($category))
|
||||
{
|
||||
$where = [
|
||||
['pid', '=', $category['pid']],
|
||||
['is_enable', '=', 1],
|
||||
];
|
||||
$category_list = Db::name('GoodsCategory')->where($where)->field('id,pid,name')->select()->toArray();
|
||||
if(!empty($category_list))
|
||||
{
|
||||
array_unshift($temp_data, [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
'type' => 1,
|
||||
'data' => array_map(function($v)
|
||||
{
|
||||
$v['url'] = MyUrl('index/search/index', ['cid'=>$v['id']]);
|
||||
return $v;
|
||||
}, $category_list),
|
||||
]);
|
||||
|
||||
// 二级
|
||||
$where = [
|
||||
['id', '=', $category['pid']],
|
||||
['is_enable', '=', 1],
|
||||
];
|
||||
$category = Db::name('GoodsCategory')->where($where)->field('id,pid,name')->find();
|
||||
if(!empty($category))
|
||||
{
|
||||
$where = [
|
||||
['pid', '=', $category['pid']],
|
||||
['is_enable', '=', 1],
|
||||
];
|
||||
$category_list = Db::name('GoodsCategory')->where($where)->field('id,pid,name')->select()->toArray();
|
||||
if(!empty($category_list))
|
||||
{
|
||||
array_unshift($temp_data, [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
'type' => 1,
|
||||
'data' => array_map(function($v)
|
||||
{
|
||||
$v['url'] = MyUrl('index/search/index', ['cid'=>$v['id']]);
|
||||
return $v;
|
||||
}, $category_list),
|
||||
]);
|
||||
|
||||
// 三级
|
||||
$where = [
|
||||
['id', '=', $category['pid']],
|
||||
['is_enable', '=', 1],
|
||||
];
|
||||
$category = Db::name('GoodsCategory')->where($where)->field('id,pid,name')->find();
|
||||
if(!empty($category))
|
||||
{
|
||||
$where = [
|
||||
['pid', '=', $category['pid']],
|
||||
['is_enable', '=', 1],
|
||||
];
|
||||
$category_list = Db::name('GoodsCategory')->where($where)->field('id,pid,name')->select()->toArray();
|
||||
if(!empty($category_list))
|
||||
{
|
||||
array_unshift($temp_data, [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
'type' => 1,
|
||||
'data' => array_map(function($v)
|
||||
{
|
||||
$v['url'] = MyUrl('index/search/index', ['cid'=>$v['id']]);
|
||||
return $v;
|
||||
}, $category_list),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 品牌、价格、关键字、属性、规格
|
||||
// 集合名称
|
||||
$temp_name = [];
|
||||
|
||||
// 品牌
|
||||
$bid = empty($params['bid']) ? (empty($params['brand_id']) ? 0 : intval($params['brand_id'])) : intval($params['bid']);
|
||||
if(!empty($bid))
|
||||
{
|
||||
$brand = Db::name('Brand')->where(['id'=>$bid])->field('id,name')->find();
|
||||
if(!empty($brand))
|
||||
{
|
||||
$temp_name[] = $brand['name'];
|
||||
}
|
||||
}
|
||||
|
||||
// 价格区间
|
||||
if(!empty($params['peid']))
|
||||
{
|
||||
$price = Db::name('ScreeningPrice')->where(['id'=>intval($params['peid'])])->field('id,name')->find();
|
||||
if(!empty($price))
|
||||
{
|
||||
$temp_name[] = $price['name'];
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索关键字
|
||||
if(!empty($params['wd']))
|
||||
{
|
||||
$temp_name[] = $params['wd'];
|
||||
}
|
||||
|
||||
// 属性
|
||||
if(!empty($params['psid']))
|
||||
{
|
||||
$temp_name[] = AsciiToStr($params['psid']);
|
||||
}
|
||||
|
||||
// 规格
|
||||
if(!empty($params['scid']))
|
||||
{
|
||||
$temp_name[] = AsciiToStr($params['scid']);
|
||||
}
|
||||
if(!empty($temp_name))
|
||||
{
|
||||
$temp_data[] = [
|
||||
'type' => 0,
|
||||
'name' => implode(' / ', $temp_name).'搜索结果',
|
||||
];
|
||||
}
|
||||
|
||||
// 数据合并
|
||||
if(!empty($temp_data))
|
||||
{
|
||||
$result = array_merge($result, $temp_data);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -120,7 +120,7 @@ input.add,input.min{width:15px}
|
||||
.am-footer {text-align:center; display:block;position: relative;margin: 0px auto; padding: 10px 0px; }
|
||||
|
||||
/*分类*/
|
||||
.goods-category-s {display:block;position: absolute;z-index: 1020;}
|
||||
.goods-category-s {display:block;position: absolute;z-index: 1021;}
|
||||
.goods-category-s .all-goods, .goods-category-title .all-goods {font-size: 16px;}
|
||||
.goods-category-title{background:#d2364c;color:#fff ;height: 40px;line-height: 44px;display:block;position: absolute;width:150px ;text-align: center;top:0px;cursor: pointer;}
|
||||
.goods-category-s .category-content{ position:relative; width: 150px; float: left;background:#fff; top: 45px;}
|
||||
@ -1103,4 +1103,22 @@ legend a.am-fr {
|
||||
.second-nav li.am-active a:hover {
|
||||
background-color: #1cc09f !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
/**
|
||||
* 面包屑导航
|
||||
*/
|
||||
.breadcrumb-data {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
.breadcrumb-data .am-breadcrumb {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.breadcrumb-data .am-breadcrumb li a {
|
||||
text-decoration: none;
|
||||
color: #666;
|
||||
}
|
||||
.breadcrumb-data .am-breadcrumb li a:hover {
|
||||
color: #d2364c;
|
||||
}
|
||||
@ -454,7 +454,7 @@ flex: 1 1 0%;line-height: 16px;cursor: pointer;}
|
||||
.scoll .goods-video-submit-close { top: 10px; }
|
||||
|
||||
/* 基础主体 */
|
||||
.item-inform { margin-bottom: 10px; }
|
||||
.item-inform { margin-top: 10px; margin-bottom: 10px; }
|
||||
}
|
||||
|
||||
@media only screen and (min-width:1025px) {
|
||||
@ -480,7 +480,7 @@ flex: 1 1 0%;line-height: 16px;cursor: pointer;}
|
||||
.theme-signin-left .cart-title{margin-left: -46px;float: left;}
|
||||
|
||||
.scoll{display: none;}
|
||||
.item-inform{max-width:1000px; background:#fff; margin-top: 20px; margin-bottom: 30px; }
|
||||
.item-inform{max-width:1000px; background:#fff; margin-bottom: 30px; }
|
||||
.clearfix-left{display:block;float: left;width:350px;}
|
||||
.clearfix-right{width:calc(100% - 370px);margin-left:10px;}
|
||||
.freight{width:400px;float: left;}
|
||||
@ -529,7 +529,7 @@ flex: 1 1 0%;line-height: 16px;cursor: pointer;}
|
||||
/* 小于1025 */
|
||||
@media only screen and (max-width:1025px) {
|
||||
ul.am-tabs-nav.am-nav.am-nav-tabs { width:100% !important; left: 0px !important; }
|
||||
.goods-detail { padding: 10px 5px; }
|
||||
.goods-detail { padding: 0 5px 10px 5px; }
|
||||
}
|
||||
|
||||
/* 手机模式下 */
|
||||
|
||||
Reference in New Issue
Block a user