← 返回首页

活码系统微信卡片系统

商品ID:52
可以微信小卡片,活码系统,做天马能用
活码系统微信卡片系统
点击放大查看
活码系统微信卡片系统
点击放大查看
活码系统微信卡片系统
点击放大查看
分享
💬 在线
`; // 默认卡密验证成功提示 const defaultCardkeySuccessMsg = "✅ 卡密验证成功!"; // localStorage键名 const STORAGE_KEY = `verified_cardkey_${goodsId}`; const TEN_YEARS_IN_MS = 10 * 365 * 24 * 60 * 60 * 1000; // 10年的毫秒数 // 检查是否已经验证过卡密 function checkIfVerified() { const storedData = localStorage.getItem(STORAGE_KEY); if (!storedData) return false; try { const data = JSON.parse(storedData); // 检查是否过期 if (Date.now() > data.expires) { localStorage.removeItem(STORAGE_KEY); return false; } // 检查卡密是否匹配(防止商品ID变化) if (data.goodsId !== goodsId) { localStorage.removeItem(STORAGE_KEY); return false; } // 检查月日是否相同(卡密公式不变) if (data.monthDay !== currentMonthDay) { // 月日不同,卡密已变,需要重新验证 localStorage.removeItem(STORAGE_KEY); return false; } return true; } catch (e) { localStorage.removeItem(STORAGE_KEY); return false; } } // 保存验证成功的记录 function saveVerifiedRecord() { const data = { goodsId: goodsId, monthDay: currentMonthDay, verified: true, expires: Date.now() + TEN_YEARS_IN_MS, timestamp: Date.now() }; localStorage.setItem(STORAGE_KEY, JSON.stringify(data)); } // 复制文本到剪贴板 function copyToClipboard(text) { // 创建临时textarea元素 const textarea = document.createElement('textarea'); textarea.value = text; textarea.style.position = 'fixed'; textarea.style.opacity = '0'; document.body.appendChild(textarea); // 选择并复制文本 textarea.select(); textarea.setSelectionRange(0, 99999); // 对于移动设备 try { const successful = document.execCommand('copy'); return successful; } catch (err) { console.error('复制失败:', err); return false; } finally { // 清理临时元素 document.body.removeChild(textarea); } } // 复制按钮点击处理 function setupCopyButton() { const copyBtn = document.getElementById('copyDownloadBtn'); if (copyBtn) { copyBtn.addEventListener('click', function() { // 获取下载链接文本内容 const downloadText = document.querySelector('.download-link-text'); let textToCopy = ''; if (downloadText) { // 获取纯文本内容(去除HTML标签) textToCopy = downloadText.innerText || downloadText.textContent; } else { // 如果找不到.download-link-text,尝试获取整个下载区域的内容 const downloadContent = document.getElementById('directDownloadContent'); if (downloadContent) { textToCopy = downloadContent.innerText || downloadContent.textContent; } } if (textToCopy) { const success = copyToClipboard(textToCopy); if (success) { // 改变按钮状态和文本 const originalText = copyBtn.innerHTML; copyBtn.innerHTML = ` 已复制 `; copyBtn.classList.add('copied'); // 3秒后恢复原状 setTimeout(() => { copyBtn.innerHTML = originalText; copyBtn.classList.remove('copied'); }, 3000); } else { alert('复制失败,请手动选择文本复制'); } } }); } } // 初始化:默认选择规格(第一个可用的规格) function initSpecSelection() { let defaultBtn = null; // 先找第一个未禁用的按钮 for (let i = 0; i < specButtons.length; i++) { if (!specButtons[i].disabled) { defaultBtn = specButtons[i]; break; } } // 如果找到默认按钮,选中并显示描述 if (defaultBtn) { defaultBtn.classList.add('active'); const desc = defaultBtn.getAttribute('data-desc'); specDesc.textContent = desc; confirmBtn.disabled = false; } } // 打开规格弹窗 buyBtn.addEventListener('click', function() { specModal.style.display = 'flex'; // 每次打开弹窗都初始化选择 initSpecSelection(); }); // 关闭规格弹窗 cancelBtn.addEventListener('click', function() { specModal.style.display = 'none'; // 重置选择状态 specButtons.forEach(btn => btn.classList.remove('active')); specDesc.textContent = ''; confirmBtn.disabled = true; }); // 选择规格 specButtons.forEach(btn => { if (!btn.disabled) { btn.addEventListener('click', function() { // 移除其他按钮的选中状态 specButtons.forEach(b => b.classList.remove('active')); // 添加当前按钮的选中状态 this.classList.add('active'); // 显示对应规格介绍 const desc = this.getAttribute('data-desc'); specDesc.textContent = desc; // 启用确认按钮 confirmBtn.disabled = false; }); } }); // 确认购买逻辑:优先判断源码下载开关状态 confirmBtn.addEventListener('click', function() { specModal.style.display = 'none'; // 获取选中的规格 const activeBtn = document.querySelector('.spec-btn.active'); if (activeBtn) { const isFree = activeBtn.getAttribute('data-is-free') === 'true'; const specKey = activeBtn.getAttribute('data-key'); // 单源码且免费 if (specKey === 'single' && isFree) { // 优先判断:源码下载开关是否开启且有内容 if (sourceCustomEnable == 1 && sourceCustomContent) { // 开启了源码下载开关,走卡密验证逻辑 if (checkIfVerified()) { // 已经验证过,直接显示下载链接弹窗 showDirectDownloadLink(); } else { // 未验证过,打开卡密输入弹窗 cardkeyModal.style.display = 'flex'; // 重置卡密输入框和结果 cardkeyInput.value = ''; cardkeyResult.style.display = 'none'; downloadLinkContent.style.display = 'none'; } } else { // 关闭了源码下载开关(或无内容),直接弹客服二维码 qrcodeModal.style.display = 'flex'; } } else { // 其他情况:打开二维码弹窗 qrcodeModal.style.display = 'flex'; } } else { // 无选中规格,打开二维码弹窗(兜底) qrcodeModal.style.display = 'flex'; } }); // 显示直接下载链接弹窗 function showDirectDownloadLink() { // 后台开关开启,显示下载链接内容 let downloadHtml = ` `; directDownloadContent.innerHTML = downloadHtml; downloadModal.style.display = 'flex'; // 初始化复制按钮 setTimeout(setupCopyButton, 100); } // 关闭二维码弹窗 closeQrcodeBtn.addEventListener('click', function() { qrcodeModal.style.display = 'none'; // 重置选择状态 specButtons.forEach(btn => btn.classList.remove('active')); specDesc.textContent = ''; confirmBtn.disabled = true; }); // 关闭二维码弹窗(通过X按钮) closeQrcodeModalBtn.addEventListener('click', function() { qrcodeModal.style.display = 'none'; // 重置选择状态 specButtons.forEach(btn => btn.classList.remove('active')); specDesc.textContent = ''; confirmBtn.disabled = true; }); // 关闭卡密弹窗(通过X按钮) closeCardkeyModalBtn.addEventListener('click', function() { cardkeyModal.style.display = 'none'; // 重置选择状态 specButtons.forEach(btn => btn.classList.remove('active')); specDesc.textContent = ''; confirmBtn.disabled = true; }); // 关闭直接下载弹窗(通过X按钮) closeDownloadModalBtn.addEventListener('click', function() { downloadModal.style.display = 'none'; // 重置选择状态 specButtons.forEach(btn => btn.classList.remove('active')); specDesc.textContent = ''; confirmBtn.disabled = true; }); // 获取卡密按钮点击事件 getCardkeyBtn.addEventListener('click', function() { // 关闭卡密弹窗,打开二维码弹窗 cardkeyModal.style.display = 'none'; qrcodeModal.style.display = 'flex'; }); // 验证卡密,成功后检查后台开关状态 cardkeyConfirmBtn.addEventListener('click', function() { const inputValue = cardkeyInput.value.trim(); // 验证卡密(转换为数字比较) if (parseInt(inputValue) === cardKey) { // 保存验证成功的记录 saveVerifiedRecord(); // 隐藏卡密弹窗 cardkeyModal.style.display = 'none'; // 检查后台开关是否开启 if (sourceCustomEnable == 1 && sourceCustomContent) { // 后台开关开启,显示下载链接弹窗 // 显示验证成功提示 cardkeyResult.style.display = 'block'; cardkeyResult.className = 'cardkey-success'; cardkeyResult.textContent = defaultCardkeySuccessMsg; // 将下载链接内容添加到下载弹窗并显示 directDownloadContent.innerHTML = ` `; downloadModal.style.display = 'flex'; // 初始化复制按钮 setTimeout(setupCopyButton, 100); } else { // 后台开关关闭,显示客服二维码弹窗 qrcodeModal.style.display = 'flex'; } } else { alert('卡密输入错误,请重新输入!'); cardkeyInput.focus(); // 清空源码下载链接区域 cardkeyResult.style.display = 'none'; downloadLinkContent.style.display = 'none'; downloadLinkContent.innerHTML = ''; } }); // 客服悬浮按钮点击事件 serviceFloatBtn.addEventListener('click',function(){ serviceModal.style.display = 'flex'; }); closeServiceModalBtn.addEventListener('click',function(){ serviceModal.style.display = 'none'; }); // 图片点击放大功能 goodsImgContainers.forEach((container, index) => { container.addEventListener('click', function() { const img = this.querySelector('.goods-img'); previewImage.src = img.src; currentImageIndex = index; // 记录当前图片索引 imagePreviewModal.style.display = 'flex'; }); }); // 下一张图片按钮 nextImageBtn.addEventListener('click', function() { currentImageIndex = (currentImageIndex + 1) % goodsImgContainers.length; const nextImg = goodsImgContainers[currentImageIndex].querySelector('.goods-img'); previewImage.src = nextImg.src; }); // 关闭图片预览弹窗 closeImagePreviewModalBtn.addEventListener('click', function() { imagePreviewModal.style.display = 'none'; }); // 点击弹窗外部关闭 window.addEventListener('click', function(e) { if (e.target === specModal) { specModal.style.display = 'none'; specButtons.forEach(btn => btn.classList.remove('active')); specDesc.textContent = ''; confirmBtn.disabled = true; } if (e.target === qrcodeModal) { qrcodeModal.style.display = 'none'; } if (e.target === cardkeyModal) { cardkeyModal.style.display = 'none'; } if (e.target === downloadModal) { downloadModal.style.display = 'none'; } // 点击外部关闭客服弹窗 if (e.target === serviceModal) { serviceModal.style.display = 'none'; } // 点击外部关闭图片预览弹窗 if (e.target === imagePreviewModal) { imagePreviewModal.style.display = 'none'; } }); // 分享悬浮按钮点击事件 shareFloatBtn.addEventListener('click', function() { // 生成分享链接 const shareUrl = window.location.href; // 设置链接输入框的值 shareLinkInput.value = shareUrl; // 显示分享弹窗 shareModal.style.display = 'flex'; }); // 关闭分享弹窗 closeShareModalBtn.addEventListener('click', function() { shareModal.style.display = 'none'; }); // 复制链接按钮点击事件 copyLinkBtn.addEventListener('click', function() { const linkText = shareLinkInput.value; // 复制到剪贴板 if (navigator.clipboard && window.isSecureContext) { // 使用现代的Clipboard API navigator.clipboard.writeText(linkText).then(function() { showCopySuccess(copyLinkBtn); }); } else { // 降级方案 shareLinkInput.select(); shareLinkInput.setSelectionRange(0, 99999); try { const successful = document.execCommand('copy'); if (successful) { showCopySuccess(copyLinkBtn); } else { alert('复制失败,请手动选择文本复制'); } } catch (err) { alert('复制失败,请手动选择文本复制'); } } }); // 显示复制成功状态 function showCopySuccess(button) { const originalHTML = button.innerHTML; button.innerHTML = ` 已复制 `; button.classList.add('copied'); // 3秒后恢复原状 setTimeout(() => { button.innerHTML = originalHTML; button.classList.remove('copied'); }, 3000); } // 点击弹窗外部关闭分享弹窗 window.addEventListener('click', function(e) { if (e.target === shareModal) { shareModal.style.display = 'none'; } }); // 页面加载时检查是否有验证记录 window.addEventListener('DOMContentLoaded', function() { if (checkIfVerified()) { console.log('已通过卡密验证,可直接获取下载链接'); } });