// 页脚交互功能脚本 document.addEventListener('DOMContentLoaded', function() { // 社交媒体链接交互 const socialLinks = document.querySelectorAll('footer .social-links a'); socialLinks.forEach(link => { link.addEventListener('click', function(e) { const platform = this.getAttribute('data-platform'); if (platform) { e.preventDefault(); handleSocialClick(platform); } }); }); // 快速链接交互 const quickLinks = document.querySelectorAll('footer .quick-links a'); quickLinks.forEach(link => { link.addEventListener('click', function(e) { if (this.getAttribute('href') === '#') { e.preventDefault(); const linkType = this.getAttribute('data-link-type'); handleQuickLink(linkType); } }); }); // 订阅表单提交 const subscribeForm = document.getElementById('subscribe-form'); if (subscribeForm) { subscribeForm.addEventListener('submit', function(e) { e.preventDefault(); const emailInput = this.querySelector('input[type="email"]'); if (emailInput && emailInput.value) { handleSubscribe(emailInput.value); } else { showMessage('请输入有效的邮箱地址', 'error'); } }); } // 处理社交媒体点击 function handleSocialClick(platform) { let url = ''; console.log('社交媒体点击:', platform); switch (platform) { case 'github': url = 'https://github.com/ITtools-collection/tools'; break; case 'twitter': url = 'https://twitter.com/ITtools_collection'; break; case 'wechat': showWeChatQRCode(); return; default: console.log('未知平台:', platform); return; } if (url) { console.log('打开URL:', url); window.open(url, '_blank'); } } // 处理快速链接点击 function handleQuickLink(type) { switch (type) { case 'about': showDialog('关于我们', `

IT工具合集是一个集成各类实用工具的在线平台,旨在帮助用户提高工作效率,解决技术难题。

我们提供多种工具,包括媒体处理、格式转换、开发辅助、网络工具等,所有工具均免费使用。

`); break; case 'terms': showDialog('使用条款', `

欢迎使用IT工具合集。使用本网站即表示您同意以下条款:

我们保留随时修改这些条款的权利。

`); break; case 'privacy': showDialog('隐私政策', `

保护您的隐私是我们的首要任务。本隐私政策说明:

如有任何隐私相关疑问,请联系我们。

`); break; case 'faq': showDialog('常见问题', `

1. 使用这些工具需要付费吗?

不需要,所有工具均免费使用,无需注册。

2. 上传的文件会保存在服务器上吗?

不会,您上传的文件仅在浏览器中处理,不会上传到我们的服务器。

3. 如何反馈问题或建议?

您可以通过"联系我们"页面或反馈表单向我们提供建议。

`); break; case 'contact': showDialog('联系我们', `

如有任何问题、建议或合作意向,请通过以下方式联系我们:

电子邮件:

contact@ittools-collection.com

微信公众号:

IT工具合集

`); break; default: break; } } // 处理订阅 function handleSubscribe(email) { // 这里可以添加实际的订阅逻辑,比如发送到后端API // 当前仅显示成功消息 showMessage('订阅成功!感谢您的关注', 'success'); // 清空输入框 const emailInput = document.querySelector('#subscribe-form input[type="email"]'); if (emailInput) { emailInput.value = ''; } } // 显示微信二维码 function showWeChatQRCode() { showDialog('关注我们的微信', `

扫描二维码关注我们的公众号

`); } // 显示对话框 function showDialog(title, content) { // 检查是否已存在对话框 let dialog = document.getElementById('footer-dialog'); if (dialog) { document.body.removeChild(dialog); } // 创建对话框 dialog = document.createElement('div'); dialog.id = 'footer-dialog'; dialog.className = 'fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50'; dialog.innerHTML = `

${title}

${content}
`; // 添加到页面 document.body.appendChild(dialog); // 添加关闭事件 dialog.querySelectorAll('.dialog-close').forEach(btn => { btn.addEventListener('click', function() { document.body.removeChild(dialog); }); }); // 点击背景关闭 dialog.addEventListener('click', function(e) { if (e.target === dialog) { document.body.removeChild(dialog); } }); } // 显示消息提示 function showMessage(message, type = 'success') { const messageDiv = document.createElement('div'); messageDiv.className = `fixed bottom-4 right-4 p-4 rounded-md shadow-lg z-50 transition-all duration-300 transform translate-y-0 ${ type === 'success' ? 'bg-green-500' : 'bg-red-500' } text-white`; messageDiv.innerHTML = message; document.body.appendChild(messageDiv); // 3秒后移除 setTimeout(() => { messageDiv.style.transform = 'translateY(100%)'; setTimeout(() => { document.body.removeChild(messageDiv); }, 300); }, 3000); } });