refactor: 修改顷部导航链接

This commit is contained in:
jsasg
2025-04-25 18:47:28 +08:00
parent bdf91b1565
commit 28a2ebeb77

View File

@@ -33,11 +33,11 @@
{volist name="vo.children" id="vc"}
<dl class="nav_cyrightit">
<dt>
<a href="{:url('product_index', ['id' => $vc.id])}">{$vc.name}</a>
<a href="{:url('product_category', ['id' => $vc.id])}">{$vc.name}</a>
</dt>
{volist name="vc.children" id="vcc"}
<dd>
<a href="{:url('product_index', ['id' => $vcc.id])}">{$vcc.name}</a>
<a href="{:url('product_category', ['id' => $vcc.id])}">{$vcc.name}</a>
</dd>
{/volist}
<dl>
@@ -106,7 +106,8 @@
<div class="popmain">
{volist name="header_hot_products" id="vo"}
<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>
{/volist}
@@ -116,7 +117,7 @@
</div>
</header>
<script>
$(document).ready(function() {
$(document).ready(function () {
// 搜索历史记录处理
function history(keywords) {
var history = localStorage.getItem('header_search_keywords');
@@ -140,7 +141,7 @@ $(document).ready(function() {
}
// 回显搜索历史记录
history.forEach(function(item) {
history.forEach(function (item) {
$('.searchhistory ul').append('<li><a href="{:url(\'product/search\')}?keywords=' + item + '">' + item + '</a></li>');
});
@@ -148,16 +149,16 @@ $(document).ready(function() {
}
// 封装一个函数用于处理鼠标悬停显示和隐藏内容
function handleHover($element, $content) {
$element.mouseenter(function() {
$element.mouseenter(function () {
$content.stop(true, true).slideDown(400);
}).mouseleave(function() {
}).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() {
$('.navItem_cyleft li').mouseenter(function () {
$(this).addClass('it_active').siblings().removeClass('it_active');
$('.navItem_cyright').hide();
$('.navItem_cyright').eq($(this).index()).show();
@@ -167,16 +168,16 @@ $(document).ready(function() {
handleHover($('.navItem').eq(i), $('.navItem').eq(i).find('.navItemConten1'));
}
// 点击搜索
$('#openModalBtn').click(function() {
$('#openModalBtn').click(function () {
$('#scmodal').toggle();
});
$('.close-btn').click(function() {
$('.close-btn').click(function () {
$('#scmodal').hide();
});
// 搜索历史记录回显
history();
// 执行搜索
$('#serrchinput').keydown(function(event) {
$('#serrchinput').keydown(function (event) {
if (event.originalEvent.keyCode == 13) {
var keywords = $(this).val();
if (keywords == '') {
@@ -190,11 +191,11 @@ $(document).ready(function() {
}
});
// 点击选择国家
$('#countrycheck').click(function() {
$('#countrycheck').click(function () {
$('#top-country').toggle();
});
$('.closecountrybt').click(function() {
$('.closecountrybt').click(function () {
$('#top-country').hide();
});
});
});
</script>