// 企业文化页面脚本 $(document).ready(function() { // 获取音频元素 const audio = document.getElementById('audioPlayer'); let isPlaying = false; let isRepeat = false; // 格式化时间 function formatTime(seconds) { const mins = Math.floor(seconds / 60); const secs = Math.floor(seconds % 60); return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`; } // 更新进度条 function updateProgress() { if (audio.duration) { const percentage = (audio.currentTime / audio.duration) * 100; $('.progress-filled').css('width', percentage + '%'); $('.current-time').text(formatTime(audio.currentTime)); } } // 音频加载完成后更新总时长 audio.addEventListener('loadedmetadata', function() { $('.total-time').text(formatTime(audio.duration)); }); // 音频播放时更新进度 audio.addEventListener('timeupdate', updateProgress); // 音频播放结束 audio.addEventListener('ended', function() { if (isRepeat) { audio.currentTime = 0; audio.play(); } else { isPlaying = false; $('.btn-play').html('▶'); } }); // 播放/暂停按钮 $('.btn-play').on('click', function() { if (!isPlaying) { // 开始播放 audio.play(); isPlaying = true; $(this).html('⏸'); } else { // 暂停播放 audio.pause(); isPlaying = false; $(this).html('▶'); } }); // 上一首按钮(重新开始) $('.btn-prev').on('click', function() { audio.currentTime = 0; updateProgress(); }); // 下一首按钮 $('.btn-next').on('click', function() { // 可以添加播放下一首的逻辑 console.log('下一首'); }); // 循环播放按钮 $('.btn-repeat').on('click', function() { isRepeat = !isRepeat; audio.loop = isRepeat; $(this).css('color', isRepeat ? 'var(--primary-color)' : '#555'); }); // 音量按钮(切换静音) $('.btn-volume').on('click', function() { audio.muted = !audio.muted; $(this).text(audio.muted ? '🔇' : '🔊'); }); // 点击进度条跳转 $('.progress').on('click', function(e) { if (audio.duration) { const progressWidth = $(this).width(); const clickX = e.offsetX; const percentage = clickX / progressWidth; audio.currentTime = audio.duration * percentage; updateProgress(); } }); // 初始化时间显示 updateProgress(); // 企业内刊下载 $('.download-link').on('click', function(e) { e.preventDefault(); const magazineTitle = $(this).closest('.magazine-item').find('.magazine-title').text(); alert('下载 ' + magazineTitle); // 这里可以添加实际的下载逻辑 }); // 企业内刊卡片hover效果优化 $('.magazine-item').hover( function() { $(this).find('.magazine-cover img').css('transform', 'scale(1.05)'); }, function() { $(this).find('.magazine-cover img').css('transform', 'scale(1)'); } ); // 价值观卡片点击切换激活状态 $('.value-card').on('click', function() { $('.value-card').removeClass('active'); $(this).addClass('active'); }); // 滚动动画 function checkScroll() { $('.section-spacing').each(function() { const elementTop = $(this).offset().top; const windowBottom = $(window).scrollTop() + $(window).height(); if (elementTop < windowBottom - 100) { $(this).css({ 'opacity': '1', 'transform': 'translateY(0)' }); } }); } // 初始化滚动动画 $('.section-spacing').css({ 'opacity': '0', 'transform': 'translateY(30px)', 'transition': 'all 0.6s ease' }); // 监听滚动 $(window).on('scroll', checkScroll); checkScroll(); // 页面加载时检查一次 // 查看更多按钮 /* $('.view-more-btn').on('click', function(e) { e.preventDefault(); // 可以跳转到企业内刊列表页 console.log('查看更多企业内刊'); }); */ });