Files
homepage/assets/js/main.js

228 lines
13 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* ============================================================
沙香科技官网交互:中英切换 / 滚动淡入 / 导航
中文为 HTML 默认内容(SEO 友好),英文通过本字典替换
============================================================ */
(function () {
'use strict';
/* ---------- 英文字典(key 对应 data-i18n) ---------- */
var EN = {
// 导航
'nav.about': 'About', 'nav.grazing': 'Digital Grazing', 'nav.planting': 'Smart Planting',
'nav.asset': 'Asset Management', 'nav.platform': 'Software Platform',
'nav.custom': 'Custom Development', 'nav.contact': 'Contact Us',
// Hero
'hero.eyebrow': 'Suzhou Shashann Technology · AIoT',
'hero.title1': 'Powering Digital', 'hero.title2': 'Transformation with AIoT',
'hero.sub': 'Artificial intelligence, edge computing, cloud computing and low-power IoT — smart hardware products and digital software platforms that measurably boost efficiency and productivity across industries.',
'hero.cta1': 'Explore Solutions', 'hero.cta2': 'Contact Us',
// 关于
'about.title': 'About Shashann',
'about.p1': 'Suzhou Shashann Technology is an AIoT company dedicated to digital upgrading across industries — combining AI, edge computing, cloud computing and low-power IoT to deliver smart hardware products and digital software service platforms that significantly improve efficiency and productivity while cutting production and management costs.',
'about.p2': 'At the 10th anniversary of the Belt and Road Initiative, our self-developed smart livestock product was named a "China Signature Product" and was featured in episode 6 of the documentary "The Light of Technology". Our portfolio — smart collars, smart ear tags, smart hydroponic grow racks, smart terminals and smart asset tags — is already deployed across smart grazing, smart planting and smart asset management.',
'about.p3': 'Our core team brings deep AIoT expertise and partners with leading universities for continuous innovation, with R&D and production bases in Nanjing, Zhangjiagang and Changzhou, and products sold overseas. Guided by "Customer First, Innovation Driven", we aim to be a trusted, industry-leading AIoT company.',
'about.stat1v': 'China Signature Product', 'about.stat1k': 'Belt & Road 10th Anniversary',
'about.stat2v': 'The Light of Technology', 'about.stat2k': 'Featured in documentary Ep.6',
'about.stat3v': '3 Bases', 'about.stat3k': 'Nanjing · Zhangjiagang · Changzhou',
'about.stat4v': 'Sold Overseas', 'about.stat4k': 'Deployed at scale in many sectors',
// 数字畜牧
'grazing.title': 'Digital Grazing',
'grazing.desc': 'Livestock farming is geographically scattered with long grazing cycles, long dependent on manual inspection and experience. Our collars, ear tags and Bluetooth base stations turn grazing from "by experience" into "by data".',
'grazing.pain1t': 'Low Production Efficiency', 'grazing.pain1d': 'Each herder can only look after a limited number of livestock.',
'grazing.pain2t': 'No Early Warning', 'grazing.pain2d': 'Wide distribution and mobility make status monitoring and traceability difficult.',
'grazing.pain3t': 'Hard Insurance Claims', 'grazing.pain3d': 'Key events like epidemics, deaths and losses lack objective data.',
'grazing.pain4t': 'Ecology Unmeasured', 'grazing.pain4d': 'Grassland capacity and ecological change are hard to quantify and close the loop.',
'grazing.p1n': 'Smart Collar SG03 mini',
'grazing.p2n': 'Smart Collar SG03',
'grazing.p3n': 'Smart Bluetooth Ear Tag ST01',
'grazing.p4n': 'Smart Bluetooth Base Station BG01',
// 智慧种植
'planting.title': 'Smart Planting',
'planting.desc': 'Urban residents increasingly want to grow food at home, and school labor courses and AI education need better carriers. Smart hydroponics is convenient, intelligent and clean — we turn it from an expensive toy into a system that actually grows.',
'planting.pain1t': 'For Users', 'planting.pain1d': 'Beginners fail often; one bad experience kills repurchase.',
'planting.pain2t': 'For Products', 'planting.pain2d': 'Fake intelligence and immature consumables leave no returning revenue.',
'planting.pain3t': 'For the Industry', 'planting.pain3d': 'The category is still seen as an expensive toy with no leading brand.',
'planting.p1n': 'Smart Hydroponic Grow Rack HS01',
'planting.p1note': 'Standalone cabinet design, easy to expand; supports unattended AI mode and manual control.',
// 设备资产
'asset.title': 'Digital Equipment & Asset Management',
'asset.desc': 'Enterprises hold large, widely distributed asset pools that manual ledgers and periodic patrols cannot cover. IoT and AI make full lifecycle management possible — from "reactive repair" to "predictive maintenance".',
'asset.pain1t': 'Invisible Field', 'asset.pain1d': 'Ledgers never match reality; counting assets still means walking around.',
'asset.pain2t': 'No Traceability', 'asset.pain2d': 'Lack of recorded data makes quality issues hard to locate.',
'asset.pain3t': 'Fragmented Systems', 'asset.pain3d': 'Multiple systems, ununified data, weak decision support.',
'asset.pain4t': 'Reactive Maintenance', 'asset.pain4d': 'Repair-after-failure dominates; downtime costs far exceed maintenance.',
'asset.p1n': 'Smart Terminal BB03',
'asset.p1note': 'High-accuracy edge computing that reliably recognizes device/asset state.',
'asset.p2n': 'UWB Smart Tag SL01',
'asset.p2note': 'Works with safety helmets; easy to install.',
'asset.p3n': 'Bluetooth Smart Tag ST02',
// 软件平台
'platform.title': 'Software Platform',
'platform.desc': 'Every hardware line ships with a companion SaaS platform, APP and WeChat mini program — device data flows straight to the cloud, management is not tied to any terminal.',
'platform.s1n': 'Smart Grazing System',
'platform.s1a': 'SaaS platform, APP and WeChat mini program',
'platform.s1b': 'Multi-account ranch management, precision tracking and geofence alarms',
'platform.s1c': 'Livestock vitals monitoring, voice calling and music playback',
'platform.s1d': 'Device management with full lifecycle data and traceability',
'platform.s2n': 'Smart Hydroponics System',
'platform.s2a': 'SaaS platform and APP',
'platform.s2b': 'Multi-account planting management with live status',
'platform.s2c': 'Automatic planting adjustment system',
'platform.s2d': 'AI planting assistant',
'platform.s3n': 'Smart Asset Management System',
'platform.s3a': 'SaaS platform and WeChat mini program',
'platform.s3b': 'Multi-account asset and maintenance management',
'platform.s3c': 'Real-time computation of asset state and location',
'platform.s3d': 'Accurate prediction and maintenance from historical data',
// 定制开发
'custom.title': 'Custom Software Development',
'custom.desc': 'Building on our engineering and simulation expertise, we deliver custom systems for industry clients — from digital twins to multi-agent workflows.',
'custom.s1n': 'Smart Beam Yard System',
'custom.s1a': 'SaaS platform and WeChat mini program',
'custom.s1b': 'Resettlement progress, bridge and production management',
'custom.s1c': 'Material management, multi-sensor data access',
'custom.s1d': 'Digital twin system',
'custom.s2n': 'Intelligent Simulation Platform',
'custom.s2a': 'Browser/server computing platform',
'custom.s2b': 'Structural mechanics simulation',
'custom.s2c': 'Thermal and fluid simulation',
'custom.s2d': 'AI-accelerated simulation',
'custom.s3n': 'Custom AI Agent Systems',
'custom.s3a': 'Multi-agent workflows',
'custom.s3b': 'AI agent optimization',
'custom.s3c': 'Features tailored to customer needs',
// 联系
'contact.motto1': 'Customer First,', 'contact.motto2': 'Innovation Driven',
'contact.sub': 'Scan the QR code, or email us about your digital upgrade needs.',
'contact.company': 'Suzhou Shashann Technology Co., Ltd.',
'contact.loc': 'R&D & Production Bases: Nanjing · Zhangjiagang · Changzhou',
// Footer
'footer.slogan': 'Powering digital transformation with AIoT',
'footer.name': 'Suzhou Shashann Technology Co., Ltd.',
'footer.motto': 'Customer First, Innovation Driven',
// 功能标签(跨产品复用)
'tag.geofence': 'Geofence Alarm', 'tag.find': 'Smart Find', 'tag.vitals': 'Vitals Monitoring',
'tag.wireless': 'Long Battery / Wireless Charging', 'tag.solar': 'Solar Powered', 'tag.voice': 'Voice Calling',
'tag.satellite': 'Satellite Comms', 'tag.herd': 'Smart Herding', 'tag.mesh': 'Mesh Networking',
'tag.lost': 'Loss Alarm', 'tag.led': 'LED Find', 'tag.connect1000': '1000+ Connections',
'tag.hiloc': 'Precision Tracking', 'tag.music': 'Music Playback', 'tag.bind': 'Tag Binding',
'tag.cluster': 'Cluster Alarm',
'tag.sensorx': 'Multi-sensor', 'tag.light': 'Smart Lighting', 'tag.water': 'Auto Water Circulation',
'tag.fert': 'Auto Fertilizing', 'tag.aimode': 'Unattended AI Mode', 'tag.lowpower': 'Ultra-low Power',
'tag.stick': 'Stick & Play', 'tag.rugged': 'Rugged', 'tag.cm': 'Centimeter Positioning',
'tag.fall': 'Fall Detection', 'tag.easy': 'Easy Install', 'tag.buzz': 'Buzzer Alarm'
};
var lang = localStorage.getItem('lang') || 'zh';
/* ---------- 语言切换 ---------- */
var nodes = Array.prototype.slice.call(document.querySelectorAll('[data-i18n]'));
// 首次加载时记录中文原文,供切回使用
nodes.forEach(function (el) { el.setAttribute('data-zh', el.textContent); });
function applyLang(l) {
lang = l;
localStorage.setItem('lang', l);
document.documentElement.lang = l === 'zh' ? 'zh-CN' : 'en';
nodes.forEach(function (el) {
var key = el.getAttribute('data-i18n');
var text = l === 'en' ? EN[key] : el.getAttribute('data-zh');
if (text != null) el.textContent = text;
});
document.getElementById('langToggle').textContent = l === 'zh' ? 'EN' : '中文';
document.title = l === 'zh'
? '苏州沙香科技有限公司 — AIoT 智能硬件与数字化平台'
: 'Suzhou Shashann Technology — AIoT Smart Hardware & Digital Platforms';
}
document.getElementById('langToggle').addEventListener('click', function () {
applyLang(lang === 'zh' ? 'en' : 'zh');
});
applyLang(lang);
/* ---------- 版权当前年份自动跨年(起始年 2023 写死在 HTML) ---------- */
document.getElementById('copyrightYear').textContent = String(new Date().getFullYear());
/* ---------- 导航滚动态 ---------- */
var header = document.getElementById('siteHeader');
function onScroll() { header.classList.toggle('scrolled', window.scrollY > 10); }
window.addEventListener('scroll', onScroll, { passive: true });
onScroll();
/* ---------- 移动端菜单 ---------- */
var menuToggle = document.getElementById('menuToggle');
var nav = document.getElementById('siteNav');
menuToggle.addEventListener('click', function () {
var open = nav.classList.toggle('open');
menuToggle.classList.toggle('open', open);
});
// 点击菜单项后自动收起
nav.addEventListener('click', function (e) {
if (e.target.tagName === 'A') {
nav.classList.remove('open');
menuToggle.classList.remove('open');
}
});
/* ---------- 多图卡滑动指示点 ---------- */
document.querySelectorAll('.slider').forEach(function (slider) {
var slides = slider.querySelector('.slides');
var figures = Array.prototype.slice.call(slides.querySelectorAll('figure'));
if (figures.length < 2) return; // 单图卡不需要指示点
var dots = document.createElement('div');
dots.className = 'dots';
var buttons = figures.map(function (_, i) {
var b = document.createElement('button');
b.type = 'button';
b.setAttribute('aria-label', 'Slide ' + (i + 1));
b.addEventListener('click', function () {
// 滚到第 i 张居中(配合 scroll-snap-type: x mandatory)
var f = figures[i];
slides.scrollTo({
left: f.offsetLeft - (slides.offsetWidth - f.offsetWidth) / 2,
behavior: 'smooth'
});
});
dots.appendChild(b);
return b;
});
slider.appendChild(dots);
// 初始把第一张居中(无动画;scroll-snap 保证落点合法)
slides.scrollLeft =
figures[0].offsetLeft - (slides.offsetWidth - figures[0].offsetWidth) / 2;
// 滚动时高亮离视口中心最近的图
function update() {
var center = slides.scrollLeft + slides.offsetWidth / 2;
var best = 0, bestDist = Infinity;
figures.forEach(function (f, i) {
var d = Math.abs(f.offsetLeft + f.offsetWidth / 2 - center);
if (d < bestDist) { bestDist = d; best = i; }
});
buttons.forEach(function (b, i) { b.classList.toggle('active', i === best); });
}
slides.addEventListener('scroll', function () {
window.requestAnimationFrame(update);
}, { passive: true });
update();
});
/* ---------- 滚动淡入 ---------- */
if ('IntersectionObserver' in window) {
var io = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
io.unobserve(entry.target);
}
});
}, { threshold: 0.12 });
document.querySelectorAll('.reveal').forEach(function (el) { io.observe(el); });
} else {
document.querySelectorAll('.reveal').forEach(function (el) { el.classList.add('visible'); });
}
})();