成色配置如下图:



qrContainer.innerHTML = '
⚠️ 二维码加载失败
请复制微信号添加
';
qrContainer.innerHTML = '';
qrContainer.appendChild(img);
} else {
qrContainer.innerHTML = '
📷 二维码待上传
请复制微信号
';
}
}
loadQR();
let toast = null;
function showMsg(msg, duration=2000) {
if(!toast) { toast = document.createElement('div'); toast.className = 'custom-toast'; document.body.appendChild(toast); }
toast.innerText = msg;
toast.classList.add('show');
setTimeout(() => toast.classList.remove('show'), duration);
}
function copyWechat() {
const val = WECHAT_ID;
if(navigator.clipboard?.writeText) {
navigator.clipboard.writeText(val).then(() => showMsg('✅ 微信号已复制')).catch(() => fallbackCopy(val));
} else fallbackCopy(val);
}
function fallbackCopy(t){
const ta = document.createElement('textarea');
ta.value = t;
document.body.appendChild(ta);
ta.select();
document.execCommand('copy');
document.body.removeChild(ta);
showMsg('✅ 微信号已复制');
}
function openWechat() {
if(/mobile|android|iphone|ipad/i.test(navigator.userAgent)) {
location.href = "weixin://";
setTimeout(() => showMsg('若未跳转,请手动搜索微信号添加', 3000), 300);
} else {
showMsg('请使用手机微信扫码或复制微信号添加');
}
}
function openModal() { modal.classList.add('active'); document.body.style.overflow = 'hidden'; }
function closeModal() { modal.classList.remove('active'); document.body.style.overflow = ''; }
openBtn.addEventListener('click', openModal);
closeBtn.addEventListener('click', closeModal);
modal.addEventListener('click', function(e) { if(e.target === modal) closeModal(); });
copyBtn.addEventListener('click', copyWechat);
openWechatBtn.addEventListener('click', openWechat);
document.addEventListener('keydown', function(e) { if(e.key === 'Escape' && modal.classList.contains('active')) closeModal(); });
})();