// 自定义:点击"请我喝咖啡"按钮、微信图标、公告弹出二维码 document.addEventListener('DOMContentLoaded', function() { function showWechatPopup(title, imgSrc) { // 如果已存在弹窗则移除 var existing = document.querySelector('.coffee-popup-overlay'); if (existing) existing.remove(); var existingStyle = document.getElementById('coffee-popup-style'); if (existingStyle) existingStyle.remove(); var popup = document.createElement('div'); popup.className = 'coffee-popup-overlay'; popup.innerHTML = '
×
' + title + '
二维码
商务合作或加群请微信联系我
'; document.body.appendChild(popup); var style = document.createElement('style'); style.id = 'coffee-popup-style'; style.textContent = ` .coffee-popup-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 99999; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.3s ease; } .coffee-popup-content { background: white; border-radius: 16px; padding: 30px; text-align: center; max-width: 320px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: slideUp 0.3s ease; position: relative; } .coffee-popup-close { position: absolute; top: 10px; right: 15px; font-size: 28px; color: #999; cursor: pointer; line-height: 1; } .coffee-popup-close:hover { color: #333; } .coffee-popup-title { font-size: 20px; color: #ff6b81; margin-bottom: 20px; font-weight: 600; } .coffee-qrcode { width: 220px; height: 220px; object-fit: contain; border-radius: 8px; border: 1px solid #f0f0f0; } .coffee-popup-tip { margin-top: 15px; color: #888; font-size: 14px; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } } `; document.head.appendChild(style); popup.querySelector('.coffee-popup-close').addEventListener('click', function() { popup.remove(); var s = document.getElementById('coffee-popup-style'); if (s) s.remove(); }); popup.addEventListener('click', function(e) { if (e.target === popup) { popup.remove(); var s = document.getElementById('coffee-popup-style'); if (s) s.remove(); } }); } // 请我喝咖啡按钮 var coffeeBtn = document.getElementById('card-info-btn'); if (coffeeBtn) { coffeeBtn.addEventListener('click', function(e) { e.preventDefault(); showWechatPopup('请我喝杯咖啡', '/images/wechatpay.png'); }); } // 微信图标点击 var wechatIcon = document.querySelector('.social-icon i.fas.fa-weixin, .social-icon i.fab.fa-weixin'); if (wechatIcon) { var wechatLink = wechatIcon.closest('a'); if (wechatLink) { wechatLink.addEventListener('click', function(e) { e.preventDefault(); showWechatPopup('添加我的微信', '/images/wechat.jpg'); }); } } // 公告点击弹出微信 var announcement = document.querySelector('.card-announcement .announcement_content'); if (announcement) { announcement.style.cursor = 'pointer'; announcement.addEventListener('click', function() { showWechatPopup('添加我的微信', '/images/wechat.jpg'); }); } // 公告按钮样式 var announcementBtn = document.querySelector('.announcement-btn'); if (announcementBtn) { var btnStyle = document.createElement('style'); btnStyle.id = 'announcement-btn-style'; btnStyle.textContent = ` .announcement-btn { display: inline-block; padding: 8px 16px; background: linear-gradient(145deg, #ff6b81, #ff8e53); color: white !important; border-radius: 20px; font-size: 14px; text-decoration: none !important; box-shadow: 0 4px 12px rgba(255,107,129,0.3); transition: all 0.3s; } .announcement-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(255,107,129,0.4); background: linear-gradient(145deg, #ff8e53, #ff6b81); } `; document.head.appendChild(btnStyle); } });