diff --git a/application/index/controller/Common.php b/application/index/controller/Common.php index e0c412696..5d9e69180 100755 --- a/application/index/controller/Common.php +++ b/application/index/controller/Common.php @@ -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']); } diff --git a/application/index/view/default/public/nav.html b/application/index/view/default/public/nav.html index f2838d8e9..df25425b9 100755 --- a/application/index/view/default/public/nav.html +++ b/application/index/view/default/public/nav.html @@ -1,26 +1,15 @@ -
-
  • - - 首页 -

    首页

    -
    -
  • -
  • - - 分类 -

    分类

    -
    -
  • -
  • - -
  • -
  • - -
  • -
    \ No newline at end of file +{{if !empty($common_bottom_nav_list)}} +
    + {{foreach $common_bottom_nav_list as $nav}} +
  • + + {{if isset($nav['badge']) and $nav['badge'] nheq null}} + {{$nav.badge}} + {{/if}} +
  • + {{/foreach}} +
    +{{/if}} \ No newline at end of file diff --git a/application/service/NavigationService.php b/application/service/NavigationService.php index 154abd09a..8c419d95f 100755 --- a/application/service/NavigationService.php +++ b/application/service/NavigationService.php @@ -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; + } } ?> \ No newline at end of file