window.env = 'product'; window.tenant={"bossProductInstance":"NEW2024022811514060793","cdnFlag":"0","cusId":"1414666","domainStatus":10,"flag":1,"foreign":true,"language":"zh_CN","domain":"www.haihofoods.com","makeDomain":"2402285024.p.make.dcloud.portal1.portal.thefastmake.com","mobileMakeDomain":"2402285024.m.make.dcloud.portal1.portal.thefastmake.com","mobileProductDomain":"2402285024.m.oper.dcloud.portal1.portal.fastoper.com","mobilePublishTime":1765874462000,"mobileStatus":8,"ningkerDomain":"FOREIGN_TRADE","pcPublishTime":1765874462000,"productDomain":"2402285024.p.oper.dcloud.portal1.portal.fastoper.com","siteType":"oper","status":6,"tenantId":355435,"unittype":"portal-saas","viewType":"p","code":"2402285024","productGroupId":"PG2024022811514093430","productVersion":"20240101"}; window.pageObj={"instanceId":"new2024022811514060793","pageId":"ca42b3fa-2fc5-4217-a099-272a787889b1","name":"产品中心","filename":"product","pageAddress":null,"appId":"143150160001","pageMotherSetIdList":["footer","head"],"pageMotherSetList":[{"instanceId":"new2024022811514060793","motherSetId":"footer","motherSetName":"默认底部","motherViewType":null,"motherOperStatus":null,"motherSetImageUrl":"/productimg/mother/p/footer.png","motherSetDel":1,"motherSetLocation":1,"pageIds":null,"createTime":1655459795000,"updateTime":1655459795000,"version":0},{"instanceId":"new2024022811514060793","motherSetId":"head","motherSetName":"默认头部","motherViewType":null,"motherOperStatus":null,"motherSetImageUrl":"/productimg/mother/p/head.png","motherSetDel":1,"motherSetLocation":0,"pageIds":null,"createTime":1655459795000,"updateTime":1655459795000,"version":0}],"children":null,"batchCacheTPageList":null,"pageType":"2","contentType":"category","viewType":null,"imageUrl":null,"previewImg":null,"showOrder":3,"parentId":"0","bindId":null,"operStatus":"BUSINESS","del":0,"pageTypeName":null,"isHomePage":0,"isLoginPage":0,"isRegisterPage":null,"isDeafault":0,"isLoginCheck":null,"isSpecialPage":0,"isErrorPage":0,"isPermissionPage":null,"isShopPage":0,"isNavigation":null,"isFlowpage":0,"createTime":1734487384000,"updateTime":1734487384000,"_detailId":"1312342018770440192","renderInfo":{"host":"2402285024.p.oper.dcloud.portal1.portal.fastoper.com","realhost":"2402285024.p.oper.dcloud.portal1.portal.fastoper.com"}}; /*__INLINE_SPLIT__*/ setTimeout(function(){$(".loadingBox").addClass("loadingOut");},3000); /*__INLINE_SPLIT__*/ $(function () { var urlName = window.location.pathname; $('.e_container-1 .p_list .p_loopitem .s_title a').each(function () { var urlHref = $(this).attr('href'); if (urlName.indexOf(urlHref) >= 0) { $(this).addClass('on'); $(this).parent().parent("div").addClass('active'); } }); if ($(window).width() < 769) { if ($('.e_container-1 .p_list .p_loopitem.active').length > 0) { var left = $('.e_container-1 .p_list .p_loopitem.active').offset().left; console.log(left) console.log($(window).width() / 2) if (left > ($(window).width() / 2)) { $(".e_container-1 .p_list").scrollLeft(left / 2); } } } }); $(function () { $('.e_bottomNav-47 .p_level1Box .p_level1Item').find('.p_level2Box').parents('.p_level1Item').addClass('open'); }); $(() => { $("saf-loopitem.backTop").click(function() { $("body, html").stop().animate({ "scrollTop": 0 }); }); }); $("img").attr("alt","闽鑫食品"); $("img").attr("title","闽鑫食品"); /*__INLINE_SPLIT__*/ /** * 产品中心动态脚本 * 动态加载产品分类、列表、详情、咨询表单 */ (async function() { // 等待 DOM 加载完成 function waitForElement(selector, timeout = 5000) { return new Promise((resolve, reject) => { const start = Date.now() const check = () => { const el = document.querySelector(selector) if (el) { resolve(el) } else if (Date.now() - start > timeout) { reject(new Error(`Timeout waiting for ${selector}`)) } else { setTimeout(check, 100) } } check() }) } // 解析 URL 参数 function getUrlParams() { const params = {} const searchParams = new URLSearchParams(window.location.search) for (const [key, value] of searchParams) { params[key] = value } return params } // 获取产品分类和列表 async function initProductPage() { try { // 使用App.vue暴露的API const api = window.__haihoProductApi if (!api) { throw new Error('产品API未初始化') } const { fetchProductCategoryPublic, fetchProductPublic, injectProductCategories, injectProductList } = api // 注入分类导航 await injectProductCategories() // 获取筛选参数 const params = getUrlParams() const categoryId = params.categoryId ? parseInt(params.categoryId) : null const keyword = params.keyword || null // 注入产品列表 await injectProductList(categoryId, keyword) // 绑定搜索事件 bindSearchEvent() } catch (e) { console.warn('产品数据加载失败,使用静态内容', e) } } // 绑定搜索事件 function bindSearchEvent() { const searchInput = document.querySelector('.search-input') const searchBtn = document.querySelector('.search-btn') if (searchBtn && searchInput) { searchBtn.addEventListener('click', () => { const keyword = searchInput.value.trim() const params = new URLSearchParams(window.location.search) if (keyword) { params.set('keyword', keyword) } else { params.delete('keyword') } params.delete('categoryId') window.location.search = params.toString() }) searchInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') { searchBtn.click() } }) } // 分类标签点击事件 document.querySelectorAll('.e_container-1 .p_list .p_loopitem').forEach(item => { item.addEventListener('click', () => { const link = item.querySelector('a') if (link && link.href) { document.querySelectorAll('.e_container-1 .p_list .p_loopitem').forEach(i => i.classList.remove('active')) item.classList.add('active') } }) }) } // 初始化 $(async function() { // 等待页面主要元素加载 try { await waitForElement('.e_container-1 .p_list') await waitForElement('.e_loop-20 .p_list') await initProductPage() } catch (e) { console.warn('产品页初始化跳过', e) } }) })()