底部导航优化

This commit is contained in:
devil_gong 2019-08-01 16:12:43 +08:00
parent 69340a0548
commit a699316a16
3 changed files with 85 additions and 26 deletions

View File

@ -295,6 +295,9 @@ class Common extends Controller
// 顶部右侧导航
$this->assign('common_nav_top_right_list', NavigationService::HomeHavTopRight(['user'=>$this->user]));
// 底部导航
$this->assign('common_bottom_nav_list', NavigationService::BottomNavigation(['user'=>$this->user]));
// 编辑器文件存放地址
$this->assign('editor_path_type', empty($this->user['id']) ? 'public' : 'user_'.$this->user['id']);
}

View File

@ -1,26 +1,15 @@
<div class="mobile-navigation">
<li {{if $controller_name.$action_name eq 'indexindex'}}class="active"{{/if}}>
<a href="{{$Think.__MY_URL__}}" class="am-block">
<img src="{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/{{if $controller_name.$action_name eq 'indexindex'}}nav-icon-home-active.png{{else /}}nav-icon-home.png{{/if}}" class="am-block" alt="首页" />
<p>首页</p>
</a>
</li>
<li {{if $controller_name.$action_name eq 'categoryindex'}}class="active"{{/if}}>
<a href="{{:MyUrl('index/category/index')}}" class="am-block">
<img src="{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/{{if $controller_name.$action_name eq 'categoryindex'}}nav-icon-category-active.png{{else /}}nav-icon-category.png{{/if}}" class="am-block" alt="分类" />
<p>分类</p>
</a>
</li>
<li {{if $controller_name.$action_name eq 'cartindex'}}class="active"{{/if}}>
<a {{if empty($user)}}href="javascript:;" class="login-event am-block"{{else /}} href="{{:MyUrl('index/cart/index')}}" class="am-block"{{/if}}>
<img src="{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/{{if $controller_name.$action_name eq 'cartindex'}}nav-icon-cart-active.png{{else /}}nav-icon-cart.png{{/if}}" class="am-block" alt="购物车" />
<p>购物车</p>
</a>
</li>
<li {{if $controller_name.$action_name eq 'userindex'}}class="active"{{/if}}>
<a {{if empty($user)}}href="javascript:;" class="login-event am-block"{{else /}} href="{{:MyUrl('index/user/index')}}" class="am-block"{{/if}}>
<img src="{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/{{if $controller_name.$action_name eq 'userindex'}}nav-icon-user-active.png{{else /}}nav-icon-user.png{{/if}}" class="am-block" alt="我的" />
<p>我的</p>
</a>
</li>
</div>
{{if !empty($common_bottom_nav_list)}}
<div class="mobile-navigation">
{{foreach $common_bottom_nav_list as $nav}}
<li {{if $controller_name.$action_name eq $nav['only_tag']}}class="active"{{/if}}>
<a {{if isset($nav['is_login']) and $nav['is_login'] eq 1 and empty($user)}}href="javascript:;" class="login-event am-block"{{else /}} href="{{$nav.url}}" class="am-block"{{/if}}>
<img src="{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/{{if $controller_name.$action_name eq $nav['only_tag']}}{{$nav.icon}}-active.png{{else /}}{{$nav.icon}}.png{{/if}}" class="am-block" alt="{{$nav.name}}" />
<p>{{$nav.name}}</p>
</a>
{{if isset($nav['badge']) and $nav['badge'] nheq null}}
<span class="am-badge am-badge-danger am-round common-cart-total hot-icon">{{$nav.badge}}</span>
{{/if}}
</li>
{{/foreach}}
</div>
{{/if}}

View File

@ -829,5 +829,72 @@ class NavigationService
return $data;
}
/**
* 获取网站底部导航
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-15
* @desc description
* @param array $params [description]
*/
public static function BottomNavigation($params = [])
{
$common_cart_total = 0;
if(!empty($params['user']))
{
// 购物车商品总数
$common_cart_total = BuyService::UserCartTotal(['user'=>$params['user']]);
$common_cart_total = ($common_cart_total > 99) ? '99+' : $common_cart_total;
}
// 列表
$data = [
[
'name' => '首页',
'is_login' => 0,
'badge' => null,
'icon' => 'nav-icon-home',
'only_tag' => 'indexindex',
'url' => __MY_URL__,
],
[
'name' => '分类',
'is_login' => 0,
'badge' => null,
'icon' => 'nav-icon-category',
'only_tag' => 'categoryindex',
'url' => MyUrl('index/category/index'),
],
[
'name' => '购物车',
'is_login' => 1,
'badge' => $common_cart_total,
'icon' => 'nav-icon-cart',
'only_tag' => 'cartindex',
'url' => MyUrl('index/cart/index'),
],
[
'name' => '我的',
'is_login' => 1,
'badge' => null,
'icon' => 'nav-icon-user',
'only_tag' => 'userindex',
'url' => MyUrl('index/user/index'),
],
];
// 网站底部导航
$hook_name = 'plugins_service_bottom_navigation_handle';
$ret = Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'params' => &$params,
'data' => &$data,
]);
return $data;
}
}
?>