ring. Fast, sensitive, and workflow-integrated detection for biosecurity.",
bgImage: "url('/template/xinyu2024/img/zhuzhi.png')"
},
{
eyebrow: "Total Workflow Integration",
title: "From Sample Prep to Final Result",
desc: "PurifyX™ sample preparation + FlowQuant™ screening + VetQuant™ molecular confirmation — fully integrated ecosystem for food safety & animal health testing.",
bgImage: "url('/template/xinyu2024/img/feed.png')"
}
];
let currentIndex = 0;
let autoInterval;
const track = document.getElementById('slideTrack');
const dotsContainer = document.getElementById('sliderDots');
const prevBtn = document.getElementById('prevSlide');
const nextBtn = document.getElementById('nextSlide');
function buildSlides() {
track.innerHTML = '';
slidesData.forEach((slide) => {
const slideDiv = document.createElement('div');
slideDiv.className = 'slide';
// 只设置背景图片,无任何混合模式,保证右侧区域图片细节完全清晰
slideDiv.style.backgroundImage = slide.bgImage;
slideDiv.style.backgroundSize = 'cover';
slideDiv.style.backgroundPosition = 'center 30%';
slideDiv.style.backgroundRepeat = 'no-repeat';
slideDiv.innerHTML = `
${slide.eyebrow}
${slide.title}
${slide.desc}
Food Safety
Animal Health
Integrated Workflow
`;
track.appendChild(slideDiv);
});
}
function updateDots() {
dotsContainer.innerHTML = '';
slidesData.forEach((_, i) => {
const dot = document.createElement('button');
dot.classList.add('dot');
if (i === currentIndex) dot.classList.add('active');
dot.addEventListener('click', () => goToSlide(i));
dotsContainer.appendChild(dot);
});
}
function goToSlide(index) {
if (index < 0) index = slidesData.length - 1;
if (index >= slidesData.length) index = 0;
currentIndex = index;
const offset = -currentIndex * 100;
track.style.transform = `translateX(${offset}%)`;
document.querySelectorAll('.dot').forEach((dot, i) => {
if (i === currentIndex) dot.classList.add('active');
else dot.classList.remove('active');
});
resetAutoPlay();
}
function nextSlide() { goToSlide(currentIndex + 1); }
function prevSlide() { goToSlide(currentIndex - 1); }
function resetAutoPlay() {
if (autoInterval) clearInterval(autoInterval);
autoInterval = setInterval(() => { nextSlide(); }, 6000);
}
function startAutoPlay() { resetAutoPlay(); }
function pauseAutoPlay() { if (autoInterval) clearInterval(autoInterval); }
const sliderContainer = document.querySelector('.hero-slider');
if (sliderContainer) {
sliderContainer.addEventListener('mouseenter', pauseAutoPlay);
sliderContainer.addEventListener('mouseleave', startAutoPlay);
}
if (prevBtn) prevBtn.addEventListener('click', prevSlide);
if (nextBtn) nextBtn.addEventListener('click', nextSlide);
if (track && dotsContainer) {
buildSlides();
updateDots();
goToSlide(0);
startAutoPlay();
}
// 新闻选项卡等交互
const tabs = document.querySelectorAll('.news-tab');
const panels = document.querySelectorAll('.news-panel');
if (tabs.length && panels.length) {
tabs.forEach(tab => {
tab.addEventListener('click', (e) => {
e.preventDefault();
const target = tab.getAttribute('data-tab');
tabs.forEach(btn => btn.classList.remove('active'));
panels.forEach(panel => panel.classList.remove('active'));
tab.classList.add('active');
const activePanel = document.getElementById(target);
if (activePanel) activePanel.classList.add('active');
});
});
}
const video = document.getElementById('mainVideo');
const thumbnail = document.getElementById('videoThumbnail');
window.toggleVideo = function() {
const video = document.getElementById('mainVideo');
const thumbnail = document.getElementById('videoThumbnail');
if (video) {
// 点击后才把 data-src 赋给 src,此时才真正加载 YouTube
if (!video.src) {
video.src = video.dataset.src + '&autoplay=1';
}
video.classList.add('playing');
if (thumbnail) thumbnail.classList.add('hidden');
const overlay = video.parentElement.querySelector('.featured-video-overlay');
if (overlay) overlay.style.display = 'none';
}
};
const industryItems = document.querySelectorAll('.industry-item');
industryItems.forEach(item => {
item.addEventListener('click', function(e) {
const link = this.getAttribute('data-link');
if (link && link !== '#') {
window.location.href = link;
}
});
const pointLinks = item.querySelectorAll('.industry-point-link');
pointLinks.forEach(link => {
link.addEventListener('click', function(e) {
e.stopPropagation();
});
});
});
});