增加中间大导航选中效果
parent
5ef7f6b46b
commit
bed4c987af
|
|
@ -27,43 +27,44 @@
|
|||
|
||||
<div class="am-collapse am-topbar-collapse" id="doc-topbar-collapse">
|
||||
{{if empty($user)}}
|
||||
<!-- 未登录 -->
|
||||
<!-- 未登录操作栏 -->
|
||||
<div class="navigation-button am-show-sm-only">
|
||||
{{if MyC('home_user_login_state') eq 1}}
|
||||
<a href="{{:MyUrl('index/user/logininfo')}}" class="am-btn am-btn-primary am-topbar-btn am-btn-sm">登录</a>
|
||||
{{/if}}
|
||||
{{if in_array('sms', MyC('home_user_reg_state')) or in_array('email', MyC('home_user_reg_state')) or in_array('username', MyC('home_user_reg_state'))}}
|
||||
<a href="{{:MyUrl('index/user/regInfo')}}" class="am-btn am-btn-success am-topbar-btn am-btn-sm">注册</a>
|
||||
<a href="{{:MyUrl('index/user/reginfo')}}" class="am-btn am-btn-success am-topbar-btn am-btn-sm">注册</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<!-- 主导航 -->
|
||||
<ul class="am-nav am-nav-pills am-topbar-nav">
|
||||
<li><a href="{{$Think.__MY_URL__}}">首页</a></li>
|
||||
{{if !empty($nav_header)}}
|
||||
{{if !empty($nav_header)}}
|
||||
<ul class="am-nav am-nav-pills am-topbar-nav">
|
||||
{{foreach $nav_header as $nav}}
|
||||
{{if empty($nav['items'])}}
|
||||
<li>
|
||||
<a href="{{$nav.url}}" {{if $nav['is_new_window_open'] eq 1}}target="_blank"{{/if}} title="{{$nav.name}}">{{$nav.name}}</a>
|
||||
<a href="{{$nav.url}}" {{if $nav['is_new_window_open'] eq 1}}target="_blank"{{/if}} title="{{$nav.name}}" {{if isset($nav['active']) and $nav['active'] eq 1}}class="active"{{/if}}>{{$nav.name}}</a>
|
||||
</li>
|
||||
{{else /}}
|
||||
<li class="am-dropdown" data-am-dropdown>
|
||||
<a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
|
||||
{{$nav.name}} <span class="am-icon-angle-down"></span>
|
||||
</a>
|
||||
<ul class="am-dropdown-content">
|
||||
{{foreach $nav.items as $navs}}
|
||||
<li>
|
||||
<a href="{{$navs.url}}" title="{{$navs.name}}">{{$navs.name}}</a>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
<a class="am-dropdown-toggle {{if isset($nav['active']) and $nav['active'] eq 1}}active{{/if}}" data-am-dropdown-toggle href="javascript:;">
|
||||
{{$nav.name}} <span class="am-icon-caret-down"></span>
|
||||
</a>
|
||||
<ul class="am-dropdown-content">
|
||||
{{foreach $nav.items as $navs}}
|
||||
<li>
|
||||
<a href="{{$navs.url}}" title="{{$navs.name}}" {{if isset($navs['active']) and $navs['active'] eq 1}}class="active"{{/if}}>{{$navs.name}}</a>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
</ul>
|
||||
</ul>
|
||||
{{/if}}
|
||||
|
||||
<!-- 右侧快捷导航 -->
|
||||
<div class="am-topbar-right am-hide-sm-only">
|
||||
<div class="navigation-user {{if empty($user)}}login-event{{/if}}">
|
||||
<a href="{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/user/index')}}{{/if}}">
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class NavigationService
|
|||
// 缓存没数据则从数据库重新读取,顶部菜单
|
||||
if(empty($header))
|
||||
{
|
||||
// 获取导航数据
|
||||
$header = self::NavDataDealWith(Db::name('Navigation')->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>0))->order('sort')->select());
|
||||
if(!empty($header))
|
||||
{
|
||||
|
|
@ -55,6 +56,7 @@ class NavigationService
|
|||
$v['items'] = self::NavDataDealWith(Db::name('Navigation')->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>$v['id']))->order('sort')->select());
|
||||
}
|
||||
}
|
||||
|
||||
// 大导航钩子
|
||||
$hook_name = 'plugins_service_navigation_header_handle';
|
||||
Hook::listen($hook_name, [
|
||||
|
|
@ -91,7 +93,46 @@ class NavigationService
|
|||
cache(config('shopxo.cache_common_home_nav_footer_key'), $footer);
|
||||
}
|
||||
|
||||
//print_r($header);
|
||||
// 中间大导航添加首页导航
|
||||
array_unshift($header, [
|
||||
'id' => 0,
|
||||
'pid' => 0,
|
||||
'name' => '首页',
|
||||
'url' => __MY_URL__,
|
||||
'data_type' => 'system',
|
||||
'is_show' => 1,
|
||||
'is_new_window_open' => 0,
|
||||
'items' => [],
|
||||
]);
|
||||
|
||||
// 选中处理
|
||||
if(!empty($header))
|
||||
{
|
||||
foreach($header as &$v)
|
||||
{
|
||||
$v['active'] = ($v['url'] == __MY_VIEW_URL__) ? 1 : 0;
|
||||
if($v['active'] == 0 && !empty($v['items']))
|
||||
{
|
||||
$status = false;
|
||||
foreach($v['items'] as &$vs)
|
||||
{
|
||||
if($vs['url'] == __MY_VIEW_URL__)
|
||||
{
|
||||
$vs['active'] = 1;
|
||||
$status = true;
|
||||
} else {
|
||||
$vs['active'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 当子元素被选中则父级也选中
|
||||
if($status)
|
||||
{
|
||||
$v['active'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'header' => $header,
|
||||
|
|
|
|||
|
|
@ -662,10 +662,20 @@ ul.am-dropdown-content > .am-active > a:focus,
|
|||
font-weight: 600;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.shop-navigation .am-nav > li > a:hover, .shop-navigation .am-nav > li > a:focus {
|
||||
.shop-navigation .am-nav > li > a:after {
|
||||
bottom: -3px;
|
||||
}
|
||||
.shop-navigation .am-nav > li > a:hover,
|
||||
.shop-navigation .am-nav > li > a:focus,
|
||||
.shop-navigation .am-nav > li > a.active {
|
||||
background-color: transparent;
|
||||
color: #d2354c;
|
||||
}
|
||||
.shop-navigation .am-nav > li ul.am-dropdown-content > li > a.active {
|
||||
text-decoration: none;
|
||||
color: #d2354c;
|
||||
background-color: #fff5f6;
|
||||
}
|
||||
.shop-navigation .wap-logo {
|
||||
max-width: 100px;
|
||||
max-height: 45px;
|
||||
|
|
@ -683,9 +693,13 @@ ul.am-dropdown-content > .am-active > a:focus,
|
|||
.shop-navigation .am-topbar-nav > li > a {
|
||||
line-height: 40px;
|
||||
}
|
||||
.shop-navigation .am-topbar-nav > li > a:hover:after {
|
||||
.shop-navigation .am-topbar-nav > li > a:hover:after,
|
||||
.shop-navigation .am-topbar-nav > li > a.active:after {
|
||||
border-bottom-color: #d2354c;
|
||||
}
|
||||
.shop-navigation .am-topbar-nav > li > a.active:after {
|
||||
opacity: 1;
|
||||
}
|
||||
.shop-navigation .am-topbar-collapse {
|
||||
margin-left: 150px;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue