refactor: 修改顷部导航链接
This commit is contained in:
@@ -27,26 +27,26 @@
|
|||||||
{volist name="header_categorys" id="vo"}
|
{volist name="header_categorys" id="vo"}
|
||||||
{if condition="$key == 0"}
|
{if condition="$key == 0"}
|
||||||
<div class="navItem_cyright" style="display: block;">
|
<div class="navItem_cyright" style="display: block;">
|
||||||
{else/}
|
{else/}
|
||||||
<div class="navItem_cyright" style="display: none;">
|
<div class="navItem_cyright" style="display: none;">
|
||||||
{/if}
|
{/if}
|
||||||
{volist name="vo.children" id="vc"}
|
{volist name="vo.children" id="vc"}
|
||||||
<dl class="nav_cyrightit">
|
<dl class="nav_cyrightit">
|
||||||
<dt>
|
<dt>
|
||||||
<a href="{:url('product_index', ['id' => $vc.id])}">{$vc.name}</a>
|
<a href="{:url('product_category', ['id' => $vc.id])}">{$vc.name}</a>
|
||||||
</dt>
|
</dt>
|
||||||
{volist name="vc.children" id="vcc"}
|
{volist name="vc.children" id="vcc"}
|
||||||
<dd>
|
<dd>
|
||||||
<a href="{:url('product_index', ['id' => $vcc.id])}">{$vcc.name}</a>
|
<a href="{:url('product_category', ['id' => $vcc.id])}">{$vcc.name}</a>
|
||||||
</dd>
|
</dd>
|
||||||
{/volist}
|
{/volist}
|
||||||
<dl>
|
<dl>
|
||||||
|
{/volist}
|
||||||
|
</div>
|
||||||
{/volist}
|
{/volist}
|
||||||
</div>
|
|
||||||
{/volist}
|
|
||||||
</ol>
|
</ol>
|
||||||
{/if}
|
{/if}
|
||||||
{volist name="header_navigation" id="vo"}
|
{volist name="header_navigation" id="vo"}
|
||||||
<li class="navItem">
|
<li class="navItem">
|
||||||
<a href="{$vo.link}" target="{$vo.blank==1?'_blank':'_self'}">{$vo.name}</a>
|
<a href="{$vo.link}" target="{$vo.blank==1?'_blank':'_self'}">{$vo.name}</a>
|
||||||
{if condition="!empty($vo.children)"}
|
{if condition="!empty($vo.children)"}
|
||||||
@@ -106,7 +106,8 @@
|
|||||||
<div class="popmain">
|
<div class="popmain">
|
||||||
{volist name="header_hot_products" id="vo"}
|
{volist name="header_hot_products" id="vo"}
|
||||||
<div class="popitem">
|
<div class="popitem">
|
||||||
<a href="{:url('product_detail', ['id' => $vo.id])}"><img src="{$vo.cover_image}" class="popimg" /></a>
|
<a href="{:url('product_detail', ['id' => $vo.id])}"><img src="{$vo.cover_image}"
|
||||||
|
class="popimg" /></a>
|
||||||
<div class="productName">{$vo.name}</div>
|
<div class="productName">{$vo.name}</div>
|
||||||
</div>
|
</div>
|
||||||
{/volist}
|
{/volist}
|
||||||
@@ -116,85 +117,85 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
// 搜索历史记录处理
|
// 搜索历史记录处理
|
||||||
function history(keywords) {
|
function history(keywords) {
|
||||||
var history = localStorage.getItem('header_search_keywords');
|
var history = localStorage.getItem('header_search_keywords');
|
||||||
if (!history) {
|
if (!history) {
|
||||||
history = [];
|
history = [];
|
||||||
} else {
|
} else {
|
||||||
history = JSON.parse(history);
|
history = JSON.parse(history);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录搜索关键词
|
// 记录搜索关键词
|
||||||
if (keywords) {
|
if (keywords) {
|
||||||
if (history.includes(keywords)) {
|
if (history.includes(keywords)) {
|
||||||
history.splice(history.indexOf(keywords), 1);
|
history.splice(history.indexOf(keywords), 1);
|
||||||
|
}
|
||||||
|
history.unshift(keywords);
|
||||||
|
if (history.length > 3) {
|
||||||
|
history.pop();
|
||||||
|
}
|
||||||
|
localStorage.setItem('header_search_keywords', JSON.stringify(history));
|
||||||
|
return history;
|
||||||
}
|
}
|
||||||
history.unshift(keywords);
|
|
||||||
if (history.length > 3) {
|
// 回显搜索历史记录
|
||||||
history.pop();
|
history.forEach(function (item) {
|
||||||
}
|
$('.searchhistory ul').append('<li><a href="{:url(\'product/search\')}?keywords=' + item + '">' + item + '</a></li>');
|
||||||
localStorage.setItem('header_search_keywords', JSON.stringify(history));
|
});
|
||||||
|
|
||||||
return history;
|
return history;
|
||||||
}
|
}
|
||||||
|
// 封装一个函数用于处理鼠标悬停显示和隐藏内容
|
||||||
// 回显搜索历史记录
|
function handleHover($element, $content) {
|
||||||
history.forEach(function(item) {
|
$element.mouseenter(function () {
|
||||||
$('.searchhistory ul').append('<li><a href="{:url(\'product/search\')}?keywords=' + item + '">' + item + '</a></li>');
|
$content.stop(true, true).slideDown(400);
|
||||||
});
|
}).mouseleave(function () {
|
||||||
|
$content.stop(true, true).slideUp(400);
|
||||||
return history;
|
});
|
||||||
}
|
|
||||||
// 封装一个函数用于处理鼠标悬停显示和隐藏内容
|
|
||||||
function handleHover($element, $content) {
|
|
||||||
$element.mouseenter(function() {
|
|
||||||
$content.stop(true, true).slideDown(400);
|
|
||||||
}).mouseleave(function() {
|
|
||||||
$content.stop(true, true).slideUp(400);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// 处理第一个导航项
|
|
||||||
handleHover($('.navItem').eq(0), $('.navItem').eq(0).find('.navItemConten'));
|
|
||||||
// 鼠标移入navItem_cyleft里面的li标签添加类,移除其他li的类
|
|
||||||
$('.navItem_cyleft li').mouseenter(function() {
|
|
||||||
$(this).addClass('it_active').siblings().removeClass('it_active');
|
|
||||||
$('.navItem_cyright').hide();
|
|
||||||
$('.navItem_cyright').eq($(this).index()).show();
|
|
||||||
});
|
|
||||||
// 处理第5 - 8个导航项
|
|
||||||
for (let i = 4; i < 8; i++) {
|
|
||||||
handleHover($('.navItem').eq(i), $('.navItem').eq(i).find('.navItemConten1'));
|
|
||||||
}
|
|
||||||
// 点击搜索
|
|
||||||
$('#openModalBtn').click(function() {
|
|
||||||
$('#scmodal').toggle();
|
|
||||||
});
|
|
||||||
$('.close-btn').click(function() {
|
|
||||||
$('#scmodal').hide();
|
|
||||||
});
|
|
||||||
// 搜索历史记录回显
|
|
||||||
history();
|
|
||||||
// 执行搜索
|
|
||||||
$('#serrchinput').keydown(function(event) {
|
|
||||||
if (event.originalEvent.keyCode == 13) {
|
|
||||||
var keywords = $(this).val();
|
|
||||||
if (keywords == '') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 记录搜索关键词
|
|
||||||
history(keywords);
|
|
||||||
|
|
||||||
// 跳转到搜索页面
|
|
||||||
window.location.href = "{:url('product/search')}" + '?keywords=' + keywords;
|
|
||||||
}
|
}
|
||||||
|
// 处理第一个导航项
|
||||||
|
handleHover($('.navItem').eq(0), $('.navItem').eq(0).find('.navItemConten'));
|
||||||
|
// 鼠标移入navItem_cyleft里面的li标签添加类,移除其他li的类
|
||||||
|
$('.navItem_cyleft li').mouseenter(function () {
|
||||||
|
$(this).addClass('it_active').siblings().removeClass('it_active');
|
||||||
|
$('.navItem_cyright').hide();
|
||||||
|
$('.navItem_cyright').eq($(this).index()).show();
|
||||||
|
});
|
||||||
|
// 处理第5 - 8个导航项
|
||||||
|
for (let i = 4; i < 8; i++) {
|
||||||
|
handleHover($('.navItem').eq(i), $('.navItem').eq(i).find('.navItemConten1'));
|
||||||
|
}
|
||||||
|
// 点击搜索
|
||||||
|
$('#openModalBtn').click(function () {
|
||||||
|
$('#scmodal').toggle();
|
||||||
|
});
|
||||||
|
$('.close-btn').click(function () {
|
||||||
|
$('#scmodal').hide();
|
||||||
|
});
|
||||||
|
// 搜索历史记录回显
|
||||||
|
history();
|
||||||
|
// 执行搜索
|
||||||
|
$('#serrchinput').keydown(function (event) {
|
||||||
|
if (event.originalEvent.keyCode == 13) {
|
||||||
|
var keywords = $(this).val();
|
||||||
|
if (keywords == '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 记录搜索关键词
|
||||||
|
history(keywords);
|
||||||
|
|
||||||
|
// 跳转到搜索页面
|
||||||
|
window.location.href = "{:url('product/search')}" + '?keywords=' + keywords;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 点击选择国家
|
||||||
|
$('#countrycheck').click(function () {
|
||||||
|
$('#top-country').toggle();
|
||||||
|
});
|
||||||
|
$('.closecountrybt').click(function () {
|
||||||
|
$('#top-country').hide();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
// 点击选择国家
|
|
||||||
$('#countrycheck').click(function() {
|
|
||||||
$('#top-country').toggle();
|
|
||||||
});
|
|
||||||
$('.closecountrybt').click(function() {
|
|
||||||
$('#top-country').hide();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user