chore: 重写初始提交(清空历史,整理后全量提交)

This commit is contained in:
ywxapp
2026-08-16 16:54:14 +08:00
commit 6c1a106bc1
1808 changed files with 238144 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
/*
* @Author: YwxApp <ywx@ywxapp.cn>
* @Date: 2026-08-09 16:41:46
* @LastEditors: YwxApp <ywx@ywxapp.cn>
* @LastEditTime: 2026-08-09 22:08:01
* @Description:
* @FilePath: \ywxapp_dev\public\static\frontend\js\firm.js
* @CustomString: Copyright (c) 2026 YwxApp
*/
/**
* YwxApp Frontend 交互脚本(基于 layuiNetCompany 模板适配重构)
*/
layui.define(['jquery', 'carousel'], function (exports) {
var $ = layui.jquery;
var carousel = layui.carousel;
// 顶部通知轮播
if ($('#siteNoticeCarousel').length) {
carousel.render({
elem: '#siteNoticeCarousel',
width: '100%',
height: '40px',
arrow: 'none',
indicator: 'none',
anim: 'updown',
autoplay: true,
interval: 3500
});
}
// 移动端导航切换
var $trigger = $('#navTrigger');
var $menu = $('#navMenu');
if ($trigger.length && $menu.length) {
$trigger.on('click', function () {
$(this).toggleClass('open');
$menu.toggleClass('open');
});
// 点击菜单项后收起(移动端)
$menu.find('a').on('click', function () {
if ($(window).width() <= 768) {
$trigger.removeClass('open');
$menu.removeClass('open');
}
});
}
// 返回顶部
var $goTop = $('#goTop');
$(window).on('scroll', function () {
if ($(this).scrollTop() > 300) {
$goTop.fadeIn();
} else {
$goTop.fadeOut();
}
});
$goTop.on('click', function () {
$('html, body').animate({scrollTop: 0}, 300);
});
exports('firm', {});
});
+99
View File
@@ -0,0 +1,99 @@
document.addEventListener('DOMContentLoaded', function() {
const navToggle = document.getElementById('navToggle');
const navMenu = document.getElementById('navMenu');
const body = document.body;
const goTopBtn = document.getElementById('goTop');
// 汉堡菜单切换
if (navToggle && navMenu) {
navToggle.addEventListener('click', function(e) {
e.stopPropagation();
this.classList.toggle('active');
navMenu.classList.toggle('active');
body.classList.toggle('nav-open');
});
// 点击菜单项自动关闭
navMenu.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
if (window.innerWidth <= 768) {
navToggle.classList.remove('active');
navMenu.classList.remove('active');
body.classList.remove('nav-open');
}
});
});
// 点击外部区域关闭菜单
document.addEventListener('click', function(e) {
if (navMenu.classList.contains('active') &&
!navToggle.contains(e.target) &&
!navMenu.contains(e.target)) {
navToggle.classList.remove('active');
navMenu.classList.remove('active');
body.classList.remove('nav-open');
}
});
}
// 返回顶部按钮
if (goTopBtn) {
window.addEventListener('scroll', () => {
goTopBtn.style.display = (window.scrollY > 300) ? 'block' : 'none';
});
goTopBtn.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
}
// 导航栏滚动阴影
const header = document.querySelector('.main-header');
if (header) {
window.addEventListener('scroll', () => {
header.classList.toggle('scrolled', window.scrollY > 10);
});
}
// 表单验证增强(移动端友好)
const phoneInputs = document.querySelectorAll('input[type="tel"]');
phoneInputs.forEach(input => {
input.addEventListener('input', function() {
this.value = this.value.replace(/[^\d]/g, '');
if (this.value.length > 11) {
this.value = this.value.slice(0, 11);
}
});
});
// 图片懒加载(原生支持)
if ('loading' in HTMLImageElement.prototype) {
const images = document.querySelectorAll('img[loading="lazy"]');
images.forEach(img => {
img.setAttribute('src', img.dataset.src || img.getAttribute('src'));
});
} else {
// 降级处理:立即加载
document.querySelectorAll('img[loading="lazy"]').forEach(img => {
img.removeAttribute('loading');
});
}
// 防止iOS Safari橡皮筋效果(可选)
if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
let startY = 0;
document.body.addEventListener('touchstart', function(e) {
startY = e.touches[0].clientY;
});
document.body.addEventListener('touchmove', function(e) {
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
if ((scrollTop === 0 && e.touches[0].clientY > startY) ||
(scrollTop === document.body.scrollHeight - window.innerHeight && e.touches[0].clientY < startY)) {
e.preventDefault();
}
});
}
});