初版:教务抢课系统 jwxt(从线上实例导出)
This commit is contained in:
@@ -0,0 +1,577 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN" class="scroll-smooth">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
||||
<title>支付成功 - {{ brand_name }}</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
dark: {
|
||||
bg: '#0a0a0a',
|
||||
card: '#171717',
|
||||
border: '#262626'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;800;900&family=Noto+Sans+SC:wght@300;400;500;700;900&display=swap"
|
||||
rel="stylesheet">
|
||||
<style>
|
||||
* {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', 'Noto Sans SC', sans-serif;
|
||||
transition: background-color 0.3s ease, color 0.3s ease;
|
||||
}
|
||||
|
||||
.glass {
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.dark .glass {
|
||||
background: rgba(23, 23, 23, 0.85);
|
||||
border: 1px solid rgba(38, 38, 38, 0.9);
|
||||
}
|
||||
|
||||
.glass-dark {
|
||||
background: rgba(17, 17, 17, 0.85);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.dark .glass-dark {
|
||||
background: rgba(10, 10, 10, 0.9);
|
||||
border: 1px solid rgba(38, 38, 38, 0.5);
|
||||
}
|
||||
|
||||
.layer-4 {
|
||||
box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.dark .layer-4 {
|
||||
box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.7);
|
||||
}
|
||||
|
||||
.bg-grid {
|
||||
background-size: 40px 40px;
|
||||
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
|
||||
linear-gradient(to bottom, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
|
||||
}
|
||||
|
||||
.dark .bg-grid {
|
||||
background-image: linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
|
||||
linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
|
||||
}
|
||||
|
||||
/* 成功动画 */
|
||||
@keyframes successPop {
|
||||
0% {
|
||||
transform: scale(0);
|
||||
opacity: 0;
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.success-icon {
|
||||
animation: successPop 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
|
||||
}
|
||||
|
||||
/* 注册码卡片样式 */
|
||||
.ticket-card {
|
||||
background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
|
||||
border: 2px solid #86efac;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.dark .ticket-card {
|
||||
background: linear-gradient(135deg, #14532d 0%, #166534 100%);
|
||||
border-color: #22c55e;
|
||||
}
|
||||
|
||||
.ticket-card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 10px 30px -5px rgba(34, 197, 94, 0.3);
|
||||
}
|
||||
|
||||
.ticket-code {
|
||||
font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
/* 复制按钮 */
|
||||
.copy-btn {
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.copy-btn:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.copy-btn:active {
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
/* Toast 通知 */
|
||||
@media (min-width: 769px) {
|
||||
.toast-container {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
z-index: 9999;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.toast {
|
||||
background: #2c3e50;
|
||||
color: white;
|
||||
padding: 14px 22px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 10px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
transform: translateX(100%);
|
||||
opacity: 0;
|
||||
transition: all 0.3s ease;
|
||||
pointer-events: all;
|
||||
min-width: 250px;
|
||||
max-width: 350px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.toast.show {
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.toast-container {
|
||||
position: fixed;
|
||||
bottom: max(20px, env(safe-area-inset-bottom));
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
z-index: 9999;
|
||||
pointer-events: none;
|
||||
width: 90%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.toast {
|
||||
background: #2c3e50;
|
||||
color: white;
|
||||
padding: 12px 20px;
|
||||
border-radius: 24px;
|
||||
margin-bottom: 8px;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
|
||||
transform: translateY(100px);
|
||||
opacity: 0;
|
||||
transition: all 0.3s ease;
|
||||
pointer-events: all;
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.toast.show {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.toast.success {
|
||||
background: #27ae60;
|
||||
}
|
||||
|
||||
.toast.error {
|
||||
background: #e74c3c;
|
||||
}
|
||||
|
||||
.dark .toast.success {
|
||||
background: #4caf50;
|
||||
}
|
||||
|
||||
.dark .toast.error {
|
||||
background: #ff6b6b;
|
||||
}
|
||||
|
||||
/* 步骤指示器 */
|
||||
.step-item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.step-item::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: -50%;
|
||||
width: 100%;
|
||||
height: 2px;
|
||||
background: #e5e5e5;
|
||||
transform: translateY(-50%);
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.dark .step-item::after {
|
||||
background: #404040;
|
||||
}
|
||||
|
||||
.step-item:last-child::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.step-number {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
background: #111;
|
||||
color: white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.dark .step-number {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
/* 脉冲动画 */
|
||||
@keyframes pulse-ring {
|
||||
0% {
|
||||
transform: scale(0.8);
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
transform: scale(1.5);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.pulse-ring {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
background: rgba(34, 197, 94, 0.4);
|
||||
animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
||||
}
|
||||
|
||||
/* 安全区域适配 */
|
||||
.safe-area-inset-bottom {
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="bg-neutral-50 text-neutral-900 dark:bg-dark-bg dark:text-neutral-100 min-h-screen">
|
||||
<!-- Toast 通知容器 -->
|
||||
<div class="toast-container" id="toastContainer"></div>
|
||||
|
||||
<!-- 导航 -->
|
||||
<nav class="fixed w-full z-50 glass border-b border-black/5 dark:border-white/10 transition-colors duration-300"
|
||||
id="navbar">
|
||||
<div class="max-w-6xl mx-auto px-4 md:px-6 h-16 flex justify-between items-center">
|
||||
<a href="/buy" class="flex items-center gap-2 md:gap-3 group cursor-pointer">
|
||||
<div
|
||||
class="w-8 h-8 bg-black dark:bg-white rounded-lg flex items-center justify-center text-white dark:text-black font-bold text-sm group-hover:rotate-12 transition-transform shrink-0">
|
||||
S</div>
|
||||
<div class="flex items-center gap-1.5 md:gap-2 min-w-0">
|
||||
<span class="font-bold tracking-tight text-sm md:text-base truncate">{{ brand_name }}</span>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div class="flex items-center gap-2 md:gap-6">
|
||||
<button onclick="toggleTheme()"
|
||||
class="p-2 rounded-full hover:bg-neutral-200 dark:hover:bg-neutral-800 transition-colors shrink-0"
|
||||
aria-label="切换主题">
|
||||
<svg id="sun-icon" class="w-5 h-5 hidden dark:block text-neutral-300" fill="none"
|
||||
stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z">
|
||||
</path>
|
||||
</svg>
|
||||
<svg id="moon-icon" class="w-5 h-5 block dark:hidden text-neutral-600" fill="none"
|
||||
stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z">
|
||||
</path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 主内容区 -->
|
||||
<main class="pt-24 md:pt-32 pb-16 md:pb-24 px-4 md:px-6 bg-grid min-h-screen">
|
||||
<div class="max-w-3xl mx-auto">
|
||||
<!-- 成功提示 -->
|
||||
<div class="text-center mb-8 md:mb-12">
|
||||
<div class="relative inline-flex items-center justify-center mb-6">
|
||||
<div class="pulse-ring"></div>
|
||||
<div class="success-icon w-20 h-20 md:w-24 md:h-24 bg-green-500 rounded-full flex items-center justify-center layer-4">
|
||||
<svg class="w-10 h-10 md:w-12 md:h-12 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M5 13l4 4L19 7"></path>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="text-2xl md:text-4xl font-bold mb-2 text-neutral-900 dark:text-white">支付成功!</h1>
|
||||
<p class="text-neutral-500 dark:text-neutral-400">您的注册码已生成,请妥善保管</p>
|
||||
</div>
|
||||
|
||||
<!-- 注册码卡片 -->
|
||||
<div class="glass rounded-2xl md:rounded-3xl p-6 md:p-8 layer-4 mb-8">
|
||||
<div class="flex items-center gap-3 mb-6">
|
||||
<div class="w-10 h-10 bg-green-100 dark:bg-green-900/30 rounded-xl flex items-center justify-center">
|
||||
<svg class="w-5 h-5 text-green-600 dark:text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-lg font-bold text-neutral-900 dark:text-white">您的注册码</h2>
|
||||
<p class="text-sm text-neutral-500 dark:text-neutral-400">已自动复制到剪贴板</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 注册码列表 -->
|
||||
<div id="ticketList" class="space-y-3 mb-6">
|
||||
{% for code in ticket_codes %}
|
||||
<div class="ticket-card rounded-xl p-4 md:p-5 flex items-center justify-between gap-4">
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="text-xs text-green-700 dark:text-green-300 mb-1 font-medium">注册码 {{ loop.index }}</div>
|
||||
<div class="ticket-code text-lg md:text-xl font-bold text-green-800 dark:text-green-200 truncate" id="ticket-{{ loop.index }}">{{ code }}</div>
|
||||
</div>
|
||||
<button onclick="copyTicket('{{ code }}', this)" class="copy-btn flex-shrink-0 p-2.5 bg-white dark:bg-neutral-800 rounded-lg shadow-sm hover:shadow-md transition-all" title="复制">
|
||||
<svg class="w-5 h-5 text-neutral-600 dark:text-neutral-400 copy-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
|
||||
</svg>
|
||||
<svg class="w-5 h-5 text-green-600 check-icon hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- 复制全部按钮 -->
|
||||
{% if ticket_codes|length > 1 %}
|
||||
<button onclick="copyAllTickets()" class="w-full py-3 bg-green-500 hover:bg-green-600 text-white font-semibold rounded-xl transition-colors flex items-center justify-center gap-2">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path>
|
||||
</svg>
|
||||
复制全部注册码
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- 使用步骤 -->
|
||||
<div class="glass rounded-2xl md:rounded-3xl p-6 md:p-8 layer-4 mb-8">
|
||||
<h2 class="text-lg font-bold text-neutral-900 dark:text-white mb-6 flex items-center gap-2">
|
||||
<svg class="w-5 h-5 text-neutral-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||
</svg>
|
||||
使用步骤
|
||||
</h2>
|
||||
|
||||
<div class="grid grid-cols-3 gap-4 mb-8">
|
||||
<div class="step-item text-center">
|
||||
<div class="step-number mx-auto mb-3">1</div>
|
||||
<div class="text-sm font-medium text-neutral-700 dark:text-neutral-300">访问登录页</div>
|
||||
<div class="text-xs text-neutral-400 mt-1">点击按钮前往</div>
|
||||
</div>
|
||||
<div class="step-item text-center">
|
||||
<div class="step-number mx-auto mb-3">2</div>
|
||||
<div class="text-sm font-medium text-neutral-700 dark:text-neutral-300">注册账号</div>
|
||||
<div class="text-xs text-neutral-400 mt-1">使用注册码</div>
|
||||
</div>
|
||||
<div class="step-item text-center">
|
||||
<div class="step-number mx-auto mb-3">3</div>
|
||||
<div class="text-sm font-medium text-neutral-700 dark:text-neutral-300">开始使用</div>
|
||||
<div class="text-xs text-neutral-400 mt-1">下载软件</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 登录地址 -->
|
||||
<div class="bg-neutral-50 dark:bg-neutral-800/50 rounded-xl p-4 mb-4">
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="text-xs text-neutral-500 dark:text-neutral-400 mb-1">登录地址</div>
|
||||
<div class="text-sm md:text-base font-medium text-neutral-900 dark:text-white truncate" id="loginUrl">{{ login_url or 'https://jwxt.bansonic.top' }}</div>
|
||||
</div>
|
||||
<a href="{{ login_url or 'https://jwxt.bansonic.top' }}" target="_blank" class="flex-shrink-0 px-4 py-2 bg-black dark:bg-white text-white dark:text-black text-sm font-semibold rounded-lg hover:shadow-lg transition-all flex items-center gap-2">
|
||||
前往登录
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 重要提示 -->
|
||||
<div class="bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-xl p-4">
|
||||
<div class="flex items-start gap-3">
|
||||
<svg class="w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
|
||||
</svg>
|
||||
<div class="text-sm text-amber-800 dark:text-amber-200">
|
||||
<p class="font-semibold mb-1">重要提示:</p>
|
||||
<ul class="space-y-1 text-amber-700 dark:text-amber-300">
|
||||
<li>• 每个注册码只能使用一次,请妥善保管</li>
|
||||
<li>• 注册码已发送至您的邮箱,请注意查收</li>
|
||||
<li>• 如遇问题,请联系客服获取帮助</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 返回按钮 -->
|
||||
<div class="text-center">
|
||||
<a href="/buy" class="inline-flex items-center gap-2 px-6 py-3 bg-neutral-200 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300 font-semibold rounded-xl hover:bg-neutral-300 dark:hover:bg-neutral-700 transition-colors">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
|
||||
</svg>
|
||||
返回购买页面
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
// 主题切换
|
||||
function initTheme() {
|
||||
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
||||
document.documentElement.classList.add('dark');
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
if (document.documentElement.classList.contains('dark')) {
|
||||
document.documentElement.classList.remove('dark');
|
||||
localStorage.theme = 'light';
|
||||
} else {
|
||||
document.documentElement.classList.add('dark');
|
||||
localStorage.theme = 'dark';
|
||||
}
|
||||
}
|
||||
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
|
||||
if (!localStorage.theme) {
|
||||
if (e.matches) document.documentElement.classList.add('dark');
|
||||
else document.documentElement.classList.remove('dark');
|
||||
}
|
||||
});
|
||||
|
||||
initTheme();
|
||||
|
||||
// Toast 通知
|
||||
function showToast(message, type = 'success', duration = 3000) {
|
||||
const container = document.getElementById('toastContainer');
|
||||
const toast = document.createElement('div');
|
||||
toast.className = `toast ${type}`;
|
||||
toast.innerHTML = `<span>${message}</span>`;
|
||||
|
||||
container.appendChild(toast);
|
||||
setTimeout(() => toast.classList.add('show'), 10);
|
||||
setTimeout(() => {
|
||||
toast.classList.remove('show');
|
||||
setTimeout(() => toast.remove(), 400);
|
||||
}, duration);
|
||||
}
|
||||
|
||||
// 复制单个注册码
|
||||
async function copyTicket(code, btn) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(code);
|
||||
|
||||
// 切换图标
|
||||
const copyIcon = btn.querySelector('.copy-icon');
|
||||
const checkIcon = btn.querySelector('.check-icon');
|
||||
|
||||
copyIcon.classList.add('hidden');
|
||||
checkIcon.classList.remove('hidden');
|
||||
|
||||
showToast('注册码已复制到剪贴板', 'success');
|
||||
|
||||
// 2秒后恢复图标
|
||||
setTimeout(() => {
|
||||
copyIcon.classList.remove('hidden');
|
||||
checkIcon.classList.add('hidden');
|
||||
}, 2000);
|
||||
|
||||
} catch (err) {
|
||||
// 降级方案
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = code;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
|
||||
showToast('注册码已复制到剪贴板', 'success');
|
||||
}
|
||||
}
|
||||
|
||||
// 复制全部注册码
|
||||
async function copyAllTickets() {
|
||||
const ticketElements = document.querySelectorAll('[id^="ticket-"]');
|
||||
const codes = Array.from(ticketElements).map(el => el.textContent.trim()).join('\n');
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(codes);
|
||||
showToast('全部注册码已复制到剪贴板', 'success');
|
||||
} catch (err) {
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = codes;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
|
||||
showToast('全部注册码已复制到剪贴板', 'success');
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载完成后自动复制第一个注册码
|
||||
window.addEventListener('load', () => {
|
||||
const firstTicket = document.querySelector('.ticket-code');
|
||||
if (firstTicket) {
|
||||
const code = firstTicket.textContent.trim();
|
||||
|
||||
// 尝试自动复制
|
||||
navigator.clipboard.writeText(code).then(() => {
|
||||
showToast('注册码已自动复制到剪贴板', 'success', 4000);
|
||||
}).catch(() => {
|
||||
// 静默失败,用户可手动复制
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user