2020-11-25 02:32:42 +00:00
|
|
|
{php}
|
2022-01-14 03:43:21 +00:00
|
|
|
//dump($menus);
|
2020-11-25 02:32:42 +00:00
|
|
|
function getMenus($menus, $level = 1, $currentFirstId, $categoryId) {
|
|
|
|
$menuHtml = '';
|
2020-11-25 04:39:58 +00:00
|
|
|
$levelList = ['nav-first','nav-second','nav-third'];
|
|
|
|
$navClass = $levelList[$level - 1] ?? '';
|
2020-11-25 02:32:42 +00:00
|
|
|
if (count($menus) > 0) {
|
2020-11-25 04:39:58 +00:00
|
|
|
$menuHtml .= '';
|
|
|
|
if($level > 1) {
|
|
|
|
$menuHtml .= '<div class="'.$navClass.'" >';
|
|
|
|
}
|
2020-11-25 12:15:51 +00:00
|
|
|
|
|
|
|
|
2020-11-25 02:32:42 +00:00
|
|
|
foreach ($menus as $menu) {
|
|
|
|
$activeClass = '';
|
2020-11-25 04:39:58 +00:00
|
|
|
if ($currentFirstId == $menu['id'] || $categoryId == $menu['id'] || ($currentFirstId == 0 && $menu['is_index'])) {
|
|
|
|
$activeClass = ' active';
|
|
|
|
}
|
2020-11-25 12:15:51 +00:00
|
|
|
$aHref = getUri($menu);
|
|
|
|
$aHref = empty($aHref) ? 'javascript:;' : $aHref;
|
2020-12-09 01:21:58 +00:00
|
|
|
$spanClass = '';
|
|
|
|
$hasChild = false;
|
|
|
|
if (isset($menu['children']) && count($menu['children']) > 0) {
|
|
|
|
$hasChild = true;
|
|
|
|
$spanClass = 'class="cur"';
|
|
|
|
}
|
2020-11-25 04:39:58 +00:00
|
|
|
if($level == 1) {
|
|
|
|
$menuHtml .= '<li class="'.$activeClass.'" >';
|
2020-12-09 01:21:58 +00:00
|
|
|
$menuHtml .= '<span '.$spanClass.'><a href="'.$aHref.'" target="'.$menu['style'].'">'.$menu['title'].'</a></span>';
|
|
|
|
if ($hasChild) {
|
2020-11-25 04:39:58 +00:00
|
|
|
$menuHtml .= getMenus($menu['children'], $level + 1, $currentFirstId, $categoryId);
|
|
|
|
}
|
|
|
|
$menuHtml .= '</li>';
|
|
|
|
} else {
|
2022-01-14 03:43:21 +00:00
|
|
|
if($menu['template_list']=='products'){
|
|
|
|
$menuHtml .= '<a href="'.$aHref.'#product" target="'.$menu['style'].'" class="'.$activeClass.'">';
|
|
|
|
}else if($menu['template_list']=='news'){
|
|
|
|
$menuHtml .= '<a href="'.$aHref.'#news" target="'.$menu['style'].'" class="'.$activeClass.'">';
|
|
|
|
}else
|
|
|
|
{
|
2020-11-25 04:39:58 +00:00
|
|
|
$menuHtml .= '<a href="'.$aHref.'" target="'.$menu['style'].'" class="'.$activeClass.'">';
|
2022-01-14 03:43:21 +00:00
|
|
|
}
|
2020-12-09 01:21:58 +00:00
|
|
|
$menuHtml .= '<span '.$spanClass.'>'.$menu['title'].'</span>';
|
|
|
|
if ($hasChild) {
|
2020-11-25 04:39:58 +00:00
|
|
|
$menuHtml .= getMenus($menu['children'], $level + 1, $currentFirstId, $categoryId);
|
|
|
|
}
|
|
|
|
$menuHtml .= '</a>';
|
2020-11-25 02:32:42 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-25 04:39:58 +00:00
|
|
|
if($level > 1) {
|
|
|
|
$menuHtml .= '</div>';
|
|
|
|
}
|
2020-11-25 02:32:42 +00:00
|
|
|
}
|
|
|
|
return $menuHtml;
|
|
|
|
}
|
|
|
|
{/php}
|
|
|
|
|
2020-11-25 04:39:58 +00:00
|
|
|
<div class="head-box w-100">
|
|
|
|
<div class="w-1500">
|
|
|
|
<div class="center-block w-100 between-center">
|
|
|
|
<div class="logo center-center">
|
|
|
|
<a href="{:url('/')}"><img src="__IMG__/logo.png"></a>
|
|
|
|
</div>
|
|
|
|
<div class="nav">
|
|
|
|
<ul>
|
|
|
|
{:getMenus($menus, 1, $currentFirstId, $categoryId)}
|
|
|
|
</ul>
|
|
|
|
</div>
|
2020-12-01 01:16:27 +00:00
|
|
|
<!-- <div class="language">
|
2020-11-25 04:39:58 +00:00
|
|
|
<a href="" class="active">中文</a> / <a href="">English</a>
|
2020-12-01 01:16:27 +00:00
|
|
|
</div> -->
|
2020-11-25 04:39:58 +00:00
|
|
|
<div class="nav_btn">
|
2020-11-25 01:07:06 +00:00
|
|
|
<i class="bar-top"></i>
|
|
|
|
<i class="bar-cen"></i>
|
|
|
|
<i class="bar-bom"></i>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|