分类优化

This commit is contained in:
devil 2019-12-26 17:34:04 +08:00
parent ef0e6ab2d6
commit 1928fc7015
2 changed files with 54 additions and 33 deletions

View File

@ -21,11 +21,12 @@
{{if !empty($goods_category_list)}}
<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}}">{{$v.name}}</li>
<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>
{{/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['items'])}}
{{foreach $v.items as $vs}}
<div class="category-item am-padding-sm">
<div class="title">
@ -58,10 +59,19 @@
{{/if}}
</div>
{{/foreach}}
{{else /}}
<div class="table-no">
<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>
</p>
</div>
{{/if}}
</div>
{{/foreach}}
{{else /}}
<div class="table-no"><i class="am-icon-warning"></i> 没有相关数据</div>
<div class="table-no"><i class="am-icon-warning"></i> 没有分类数据</div>
{{/if}}
</div>

View File

@ -1,11 +1,22 @@
$(function()
{
// 分类显/隐
$('.category-list ul.category-nav li').on('mouseover', function(){
// 一级分类显/隐操作
$('.category-list ul.category-nav li').on('mouseover', function()
{
var index = $(this).index();
$('.category-list ul.category-nav li').removeClass('active');
$(this).addClass('active');
$('.category-content').addClass('none');
$('.category-content-'+index).removeClass('none');
});
// 一级分类双击进入商品搜索页
$('.category-list ul.category-nav li').on('dblclick', function()
{
var url = $(this).data('url') || null;
if(url != null)
{
window.location.href = url;
}
});
});