<?php
ob_start();
require_once __DIR__ . '/../../config.php';
$site_name = getSiteConfig('site_name') ?? '麟泓授权';
$site_logo = getSiteConfig('site_logo') ?? '/assets/uploads/logo.png';
?>
<?php include 'header.php'; ?>
<?php
// 获取更新日志
$changelog = $db->fetchAll("SELECT * FROM changelog ORDER BY id DESC LIMIT 3");?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>FAQ - <?php echo htmlspecialchars($site_name); ?></title>
    <link rel="stylesheet" href="/assets/css/style.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
            min-height: 100vh;
        }
        
        .help-container {
            display: flex;
            max-width: 1400px;
            margin: 0 auto;
            padding: 24px;
            gap: 24px;
        }
        
        /* ========== 左侧目录树 ========== */
        .help-sidebar {
            width: 280px;
            flex-shrink: 0;
            background: white;
            border-radius: 24px;
            padding: 24px 0;
            box-shadow: 0 4px 20px rgba(0,0,0,0.05);
            border: 1px solid rgba(0,0,0,0.04);
            position: sticky;
            top: 24px;
            height: fit-content;
            max-height: calc(100vh - 48px);
            overflow-y: auto;
        }
        
        .sidebar-header {
            padding: 0 20px 20px;
            border-bottom: 1px solid #f0f0f0;
            margin-bottom: 16px;
        }
        
        .sidebar-header h3 {
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 18px;
            font-weight: 700;
            color: #1a1a1a;
        }
        
        .tree-menu {
            padding: 0 12px;
        }
        
        .tree-item {
            list-style: none;
        }
        
        .tree-link {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 16px;
            color: #64748b;
            text-decoration: none;
            border-radius: 12px;
            transition: all 0.2s;
            font-size: 14px;
            font-weight: 500;
        }
        
        .tree-link:hover {
            background: #f8fafc;
            color: #07C160;
        }
        
        .tree-link.active {
            background: linear-gradient(135deg, #07C16010, #07C16005);
            color: #07C160;
            border-left: 3px solid #07C160;
        }
        
        .tree-link .icon {
            width: 22px;
            height: 22px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .tree-children {
            padding-left: 28px;
            margin-top: 4px;
        }
        
        .tree-child-link {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 16px;
            color: #94a3b8;
            text-decoration: none;
            border-radius: 8px;
            font-size: 13px;
            transition: all 0.2s;
        }
        
        .tree-child-link:hover {
            color: #07C160;
            background: #f8fafc;
        }
        
        .tree-divider {
            height: 1px;
            background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
            margin: 16px 20px;
        }
        
        .tree-badge {
            margin-left: auto;
            background: #07C160;
            color: white;
            padding: 2px 8px;
            border-radius: 20px;
            font-size: 10px;
            font-weight: 600;
        }
        
        .tree-badge.coming {
            background: #f59e0b;
        }
        
        /* ========== 右侧内容区 ========== */
        .help-content {
            flex: 1;
            min-width: 0;
        }
        
        .content-card {
            background: white;
            border-radius: 24px;
            padding: 32px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.05);
            border: 1px solid rgba(0,0,0,0.04);
            margin-bottom: 24px;
        }
        
        .page-header {
            display: flex;
            align-items: center;
            gap: 16px;
            margin-bottom: 28px;
            padding-bottom: 24px;
            border-bottom: 1px solid #f0f0f0;
        }
        
        .page-icon {
            width: 56px;
            height: 56px;
            background: linear-gradient(135deg, #07C160, #05a050);
            border-radius: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 8px 20px rgba(7, 193, 96, 0.2);
        }
        
        .page-title h1 {
            font-size: 28px;
            font-weight: 700;
            color: #1a1a1a;
            margin-bottom: 6px;
        }
        
        .page-title p {
            color: #94a3b8;
            font-size: 14px;
        }
        
        /* 步骤卡片 */
        .step-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 20px;
            margin: 28px 0;
        }
        
        .step-card {
            text-align: center;
            padding: 24px 16px;
            background: #fafbfc;
            border-radius: 20px;
            transition: all 0.3s;
        }
        
        .step-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 12px 24px rgba(0,0,0,0.06);
        }
        
        .step-number {
            width: 40px;
            height: 40px;
            background: linear-gradient(135deg, #07C160, #05a050);
            color: white;
            border-radius: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 18px;
            margin: 0 auto 16px;
            box-shadow: 0 4px 12px rgba(7, 193, 96, 0.3);
        }
        
        .step-icon {
            width: 64px;
            height: 64px;
            margin: 0 auto 16px;
            background: white;
            border-radius: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 12px rgba(0,0,0,0.04);
        }
        
        .step-title {
            font-weight: 700;
            font-size: 16px;
            margin-bottom: 8px;
            color: #1a1a1a;
        }
        
        .step-desc {
            font-size: 13px;
            color: #94a3b8;
            line-height: 1.5;
        }
        
        /* 验证码展示 */
        .code-showcase {
            background: linear-gradient(135deg, #f8f8f8 0%, #ffffff 100%);
            border-radius: 24px;
            padding: 28px;
            text-align: center;
            margin: 28px 0;
            border: 1px solid #f0f0f0;
        }
        
        .code-label {
            color: #94a3b8;
            font-size: 13px;
            letter-spacing: 2px;
            margin-bottom: 12px;
        }
        
        .code-value {
            font-size: 64px;
            font-weight: 800;
            letter-spacing: 16px;
            color: #07C160;
            font-family: 'Courier New', monospace;
            text-shadow: 0 4px 8px rgba(7, 193, 96, 0.1);
        }
        
        /* FAQ */
        .faq-list {
            margin-top: 20px;
        }
        
        .faq-item {
            border-bottom: 1px solid #f0f0f0;
        }
        
        .faq-question {
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 18px 0;
            cursor: pointer;
            font-weight: 600;
            color: #1a1a1a;
        }
        
        .faq-question .icon {
            transition: transform 0.3s;
        }
        
        .faq-answer {
            padding: 0 0 18px 36px;
            color: #64748b;
            font-size: 14px;
            line-height: 1.7;
            display: none;
        }
        
        .faq-item.active .faq-answer {
            display: block;
        }
        
        .faq-item.active .faq-question .icon {
            transform: rotate(90deg);
        }
        
        /* 联系卡片 */
        .contact-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 16px;
            margin-top: 20px;
        }
        
        .contact-card {
            display: flex;
            align-items: center;
            gap: 16px;
            padding: 20px;
            background: #fafbfc;
            border-radius: 20px;
            text-decoration: none;
            transition: all 0.2s;
        }
        
        .contact-card:hover {
            background: white;
            box-shadow: 0 8px 20px rgba(0,0,0,0.06);
        }
        
        .contact-icon {
            width: 48px;
            height: 48px;
            background: white;
            border-radius: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 12px rgba(0,0,0,0.04);
        }
        
        .contact-info h4 {
            font-size: 15px;
            font-weight: 600;
            color: #1a1a1a;
            margin-bottom: 4px;
        }
        
        .contact-info p {
            font-size: 13px;
            color: #94a3b8;
        }
        
        /* 响应式 */
        @media (max-width: 900px) {
            .help-container {
                flex-direction: column;
            }
            
            .help-sidebar {
                width: 100%;
                position: relative;
                top: 0;
                max-height: none;
            }
            
            .step-grid {
                grid-template-columns: 1fr;
            }
            
            .contact-grid {
                grid-template-columns: 1fr;
            }
        }
        /* 更新日志时间轴 */
.timeline {
    position: relative;
    padding-left: 20px;
}

.timeline-item {
    position: relative;
    padding-bottom: 32px;
    padding-left: 24px;
    border-left: 2px solid #e2e8f0;
}

.timeline-item:last-child {
    border-left-color: transparent;
}

.timeline-item.latest {
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    margin: -16px -16px 0 -16px;
    padding: 24px 24px 32px 48px;
    border-radius: 16px;
    border-left: 3px solid #06b6d4;
}

.latest-badge {
    position: absolute;
    top: 8px;
    right: 16px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.timeline-badge {
    position: absolute;
    left: -16px;
    top: 0;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 12px;
    box-shadow: 0 4px 8px rgba(6, 182, 212, 0.2);
}

.timeline-item.latest .timeline-badge {
    left: -18px;
    width: 36px;
    height: 36px;
    font-size: 14px;
}

.timeline-content {
    padding-top: 4px;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.timeline-version {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 16px;
    color: #06b6d4;
}

.featured-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fef3c7;
    color: #92400e;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 8px;
}

.timeline-date {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #94a3b8;
}

.timeline-body {
    margin-top: 12px;
}

.timeline-line {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 0;
    color: #64748b;
    font-size: 14px;
    line-height: 1.6;
}

.timeline-line img {
    flex-shrink: 0;
    margin-top: 2px;
}

@media (max-width: 768px) {
    .timeline-item {
        padding-left: 16px;
    }
    
    .timeline-item.latest {
        padding: 20px 16px 24px 36px;
    }
    
    .latest-badge {
        position: relative;
        top: 0;
        right: 0;
        display: inline-flex;
        margin-bottom: 12px;
    }
}
@media (max-width: 768px) {
    .contact-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 1024px) {
    .contact-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .contact-grid {
        grid-template-columns: 1fr;
    }
}
    </style>
</head>
<body>
    <div class="help-container">
        <!-- 左侧目录树 -->
        <aside class="help-sidebar">
            <div class="sidebar-header">
                <h3>
                    <img src="https://api.iconify.design/mdi:help-circle.svg?color=%2307C160" width="24" height="24" alt="">
                    帮助中心
                </h3>
            </div>
            
            <ul class="tree-menu">
                <!-- 微信登录 -->
                <li class="tree-item">
                    <a href="#wechat-login" class="tree-link active">
                        <span class="icon">
                            <img src="https://api.iconify.design/mdi:wechat.svg?color=%2307C160" width="20" height="20" alt="">
                        </span>
                        <span>微信登录</span>
                    </a>
                    <ul class="tree-children">
                        <li><a href="#step1" class="tree-child-link">获取验证码</a></li>
                        <li><a href="#step2" class="tree-child-link">关注公众号</a></li>
                        <li><a href="#step3" class="tree-child-link">发送验证码</a></li>
                    </ul>
                </li>
                
                <!-- 微信绑定 -->
                <li class="tree-item">
                    <a href="#wechat-bind" class="tree-link">
                        <span class="icon">
                            <img src="https://api.iconify.design/mdi:link.svg?color=%23667eea" width="20" height="20" alt="">
                        </span>
                        <span>微信绑定</span>
                    </a>
                </li>
                <!-- 微信配置 -->
<li class="tree-item">
    <a href="#wechat-config" class="tree-link">
        <span class="icon">
            <img src="https://api.iconify.design/mdi:cog.svg?color=%231e293b" width="20" height="20" alt="">
        </span>
        <span>微信配置</span>
    </a>
</li>
                <div class="tree-divider"></div>
                
                <!-- 常见问题 -->
                <li class="tree-item">
                    <a href="#faq" class="tree-link">
                        <span class="icon">
                            <img src="https://api.iconify.design/mdi:frequently-asked-questions.svg?color=%23f59e0b" width="20" height="20" alt="">
                        </span>
                        <span>常见问题</span>
                    </a>
                </li>
                
                <!-- 联系客服 -->
                <li class="tree-item">
                    <a href="#contact" class="tree-link">
                        <span class="icon">
                            <img src="https://api.iconify.design/mdi:headset.svg?color=%2310b981" width="20" height="20" alt="">
                        </span>
                        <span>联系客服</span>
                    </a>
                </li>
                <li class="tree-item">
    <a href="#changelog" class="tree-link">
        <span class="icon">
            <img src="https://api.iconify.design/mdi:newspaper.svg?color=%2306b6d4" width="20" height="20" alt="">
        </span>
        <span>更新日志</span>
        <span class="tree-badge">NEW</span>
    </a>
</li>
                <!-- 开发文档 -->
<li class="tree-item">
    <a href="#dev-docs" class="tree-link">
        <span class="icon">
            <img src="https://api.iconify.design/mdi:code-braces.svg?color=%231e293b" width="20" height="20" alt="">
        </span>
        <span>开发文档</span>
        <span class="tree-badge">API</span>
    </a>
</li>
                <div class="tree-divider"></div>
                
                <!-- 预留扩展 -->
                <li class="tree-item">
                    <a href="#" class="tree-link">
                        <span class="icon">
                            <img src="https://api.iconify.design/mdi:book-open.svg?color=%238b5cf6" width="20" height="20" alt="">
                        </span>
                        <span>使用手册</span>
                        <span class="tree-badge coming">即将上线</span>
                    </a>
                </li>
                
                <li class="tree-item">
                    <a href="#" class="tree-link">
                        <span class="icon">
                            <img src="https://api.iconify.design/mdi:video.svg?color=%23ef4444" width="20" height="20" alt="">
                        </span>
                        <span>视频教程</span>
                        <span class="tree-badge coming">即将上线</span>
                    </a>
                </li>
                
                
            </ul>
        </aside>
        
        <!-- 右侧内容区 -->
        <main class="help-content">
            <!-- 微信登录 -->
            <div id="wechat-login" class="content-card">
                <div class="page-header">
                    <div class="page-icon">
                        <img src="https://api.iconify.design/mdi:wechat.svg?color=white" width="28" height="28" alt="">
                    </div>
                    <div class="page-title">
                        <h1>微信登录</h1>
                        <p>使用微信快速登录平台，无需记忆密码</p>
                    </div>
                </div>
                
                <div class="step-grid">
                    <div class="step-card" id="step1">
                        <div class="step-number">1</div>
                        <div class="step-icon">
                            <img src="https://api.iconify.design/mdi:qrcode.svg?color=%2307C160" width="32" height="32" alt="">
                        </div>
                        <div class="step-title">获取验证码</div>
                        <div class="step-desc">在登录页点击微信图标，获取6位验证码</div>
                    </div>
                    <div class="step-card" id="step2">
                        <div class="step-number">2</div>
                        <div class="step-icon">
                            <img src="https://api.iconify.design/mdi:account-plus.svg?color=%2307C160" width="32" height="32" alt="">
                        </div>
                        <div class="step-title">关注公众号</div>
                        <div class="step-desc">扫描二维码关注我们的微信公众号</div>
                    </div>
                    <div class="step-card" id="step3">
                        <div class="step-number">3</div>
                        <div class="step-icon">
                            <img src="https://api.iconify.design/mdi:send.svg?color=%2307C160" width="32" height="32" alt="">
                        </div>
                        <div class="step-title">发送验证码</div>
                        <div class="step-desc">将验证码发送给公众号，平台自动登录</div>
                    </div>
                </div>
                
                <div class="code-showcase">
                    <div class="code-label">验证码示例</div>
                    <div class="code-value">123456</div>
                    <p style="color: #94a3b8; font-size: 13px; margin-top: 12px;">
                        <img src="https://api.iconify.design/mdi:clock-outline.svg?color=%2394a3b8" width="14" height="14" style="vertical-align: middle; margin-right: 4px;">
                        验证码有效期 5 分钟
                    </p>
                </div>
            </div>
            
            <!-- 微信绑定 -->
            <div id="wechat-bind" class="content-card">
                <div class="page-header">
                    <div class="page-icon" style="background: linear-gradient(135deg, #667eea, #5a67d8);">
                        <img src="https://api.iconify.design/mdi:link.svg?color=white" width="28" height="28" alt="">
                    </div>
                    <div class="page-title">
                        <h1>微信绑定</h1>
                        <p>已有账号？绑定微信后可使用微信快速登录</p>
                    </div>
                </div>
                
                <p style="color: #64748b; line-height: 1.8; margin-bottom: 24px;">
                    登录平台后，进入「用户中心」→「微信绑定」，点击「立即绑定」，按照提示操作即可完成绑定。
                    一个微信账号只能绑定一个平台账号。
                </p>
                
                <div style="background: #f0fdf4; border-radius: 16px; padding: 20px; border: 1px solid #d1fae5;">
                    <p style="display: flex; gap: 12px; color: #065f46;">
                        <img src="https://api.iconify.design/mdi:check-circle.svg?color=%2310b981" width="20" height="20" alt="">
                        <span>绑定后，下次登录可直接使用微信验证码登录，无需输入密码。</span>
                    </p>
                </div>
            </div>
            <!-- 微信配置教程 -->
<div id="wechat-config" class="content-card">
    <div class="page-header">
        <div class="page-icon" style="background: linear-gradient(135deg, #1e293b, #0f172a);">
            <img src="https://api.iconify.design/mdi:cog.svg?color=white" width="28" height="28" alt="">
        </div>
        <div class="page-title">
            <h1>微信开发者配置</h1>
            <p>微信公众号服务器配置教程 · URL · Token · 消息加解密</p>
        </div>
    </div>
    
    <!-- 步骤1：获取配置信息 -->
    <div style="margin-bottom: 32px;">
        <div style="display: flex; align-items: center; gap: 12px; margin-bottom: 16px;">
            <div style="width: 32px; height: 32px; background: #667eea; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700;">1</div>
            <h3 style="font-size: 18px; color: #1a1a1a;">获取公众号配置信息</h3>
        </div>
        
        <div style="background: #f8fafc; border-radius: 16px; padding: 20px; margin-left: 44px;">
            <p style="color: #64748b; margin-bottom: 16px;">登录微信公众平台，进入「设置与开发」→「基本配置」，获取以下信息：</p>
            <div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;">
                <div style="background: white; border-radius: 12px; padding: 16px; border: 1px solid #e2e8f0;">
                    <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
                        <img src="https://api.iconify.design/mdi:identifier.svg?color=%23667eea" width="18" height="18" alt="">
                        <span style="font-weight: 600;">AppID</span>
                    </div>
                    <code style="background: #f1f5f9; padding: 4px 10px; border-radius: 6px; font-size: 13px;">wxXXXXXXXXXXXXXXXX</code>
                    <p style="font-size: 12px; color: #94a3b8; margin-top: 8px;">应用唯一标识</p>
                </div>
                <div style="background: white; border-radius: 12px; padding: 16px; border: 1px solid #e2e8f0;">
                    <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
                        <img src="https://api.iconify.design/mdi:key.svg?color=%23f59e0b" width="18" height="18" alt="">
                        <span style="font-weight: 600;">AppSecret</span>
                    </div>
                    <code style="background: #f1f5f9; padding: 4px 10px; border-radius: 6px; font-size: 13px;">••••••••••••••••••••••••••••••••</code>
                    <p style="font-size: 12px; color: #94a3b8; margin-top: 8px;">应用密钥，需妥善保管</p>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 步骤2：配置服务器 -->
    <div style="margin-bottom: 32px;">
        <div style="display: flex; align-items: center; gap: 12px; margin-bottom: 16px;">
            <div style="width: 32px; height: 32px; background: #10b981; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700;">2</div>
            <h3 style="font-size: 18px; color: #1a1a1a;">配置服务器信息</h3>
        </div>
        
        <div style="margin-left: 44px;">
            <p style="color: #64748b; margin-bottom: 16px;">在「基本配置」页面，点击「服务器配置」→「修改配置」，填写以下信息：</p>
            
            <div style="background: white; border-radius: 16px; padding: 24px; border: 1px solid #e2e8f0; margin-bottom: 20px;">
                <table style="width: 100%; border-collapse: collapse;">
                    <tr style="border-bottom: 1px solid #f0f0f0;">
                        <td style="padding: 14px 0; font-weight: 600; width: 140px; color: #1e293b;">
                            <img src="https://api.iconify.design/mdi:web.svg?color=%23667eea" width="16" height="16" style="vertical-align: middle; margin-right: 6px;">
                            URL
                        </td>
                        <td style="padding: 14px 0; color: #1e293b;">
                            <code style="background: #f1f5f9; padding: 6px 14px; border-radius: 8px; font-size: 14px;">https://你的域名/api/wechat-server.php</code>
                        </td>
                    </tr>
                    <tr style="border-bottom: 1px solid #f0f0f0;">
                        <td style="padding: 14px 0; font-weight: 600; color: #1e293b;">
                            <img src="https://api.iconify.design/mdi:shield-key.svg?color=%23f59e0b" width="16" height="16" style="vertical-align: middle; margin-right: 6px;">
                            Token
                        </td>
                        <td style="padding: 14px 0; color: #1e293b;">
                            <code style="background: #f1f5f9; padding: 6px 14px; border-radius: 8px; font-size: 14px;">ghy200808260090</code>
                            <span style="margin-left: 12px; color: #94a3b8; font-size: 13px;">（或自定义，需与服务器一致）</span>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding: 14px 0; font-weight: 600; color: #1e293b;">
                            <img src="https://api.iconify.design/mdi:lock.svg?color=%238b5cf6" width="16" height="16" style="vertical-align: middle; margin-right: 6px;">
                            EncodingAESKey
                        </td>
                        <td style="padding: 14px 0; color: #1e293b;">
                            <span style="color: #94a3b8;">点击「随机生成」按钮自动生成</span>
                        </td>
                    </tr>
                </table>
            </div>
            
            <div style="background: #fef3c7; border-radius: 12px; padding: 16px; border: 1px solid #fbbf24;">
                <p style="display: flex; gap: 12px; color: #92400e;">
                    <img src="https://api.iconify.design/mdi:information.svg?color=%23d97706" width="20" height="20" alt="">
                    <span><strong>重要提示：</strong>消息加解密方式请选择「<strong>明文模式</strong>」，否则消息无法正常接收。</span>
                </p>
            </div>
        </div>
    </div>
    
    <!-- 步骤3：配置服务器文件 -->
    <div style="margin-bottom: 32px;">
        <div style="display: flex; align-items: center; gap: 12px; margin-bottom: 16px;">
            <div style="width: 32px; height: 32px; background: #f59e0b; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700;">3</div>
            <h3 style="font-size: 18px; color: #1a1a1a;">修改服务器配置文件</h3>
        </div>
        
        <div style="margin-left: 44px;">
            <p style="color: #64748b; margin-bottom: 16px;">编辑服务器上的配置文件 <code>/includes/wechat-config.php</code>，填入你的 AppID 和 AppSecret：</p>
            
            <div style="background: #1e293b; border-radius: 16px; padding: 20px; margin-bottom: 16px;">
                <pre style="color: #e2e8f0; font-family: 'Monaco', 'Menlo', monospace; font-size: 13px; line-height: 1.8; margin: 0;"><span style="color: #fbbf24;">&lt;?php</span>
<span style="color: #94a3b8;">// 微信公众号配置</span>
<span style="color: #fbbf24;">define</span>(<span style="color: #10b981;">'WECHAT_APPID'</span>, <span style="color: #10b981;">'wxXXXXXXXXXXXXXXXX'</span>);
<span style="color: #fbbf24;">define</span>(<span style="color: #10b981;">'WECHAT_APPSECRET'</span>, <span style="color: #10b981;">'你的AppSecret'</span>);
<span style="color: #fbbf24;">define</span>(<span style="color: #10b981;">'WECHAT_TOKEN'</span>, <span style="color: #10b981;">'ghy200808260090'</span>);</pre>
            </div>
            
            <p style="color: #64748b; font-size: 13px;">
                <img src="https://api.iconify.design/mdi:check-circle.svg?color=%2310b981" width="14" height="14" style="vertical-align: middle; margin-right: 4px;">
                Token 必须与微信后台填写的完全一致
            </p>
        </div>
    </div>
    
    <!-- 步骤4：提交验证 -->
    <div style="margin-bottom: 32px;">
        <div style="display: flex; align-items: center; gap: 12px; margin-bottom: 16px;">
            <div style="width: 32px; height: 32px; background: #ef4444; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700;">4</div>
            <h3 style="font-size: 18px; color: #1a1a1a;">提交验证</h3>
        </div>
        
        <div style="margin-left: 44px;">
            <p style="color: #64748b; margin-bottom: 16px;">填写完成后点击「提交」按钮，微信服务器会验证你的服务器配置。</p>
            
            <div style="background: #d1fae5; border-radius: 12px; padding: 16px; border: 1px solid #10b981;">
                <p style="display: flex; gap: 12px; color: #065f46;">
                    <img src="https://api.iconify.design/mdi:check-circle.svg?color=%2310b981" width="20" height="20" alt="">
                    <span>验证成功后，状态显示「已启用」，即可正常接收用户消息。</span>
                </p>
            </div>
        </div>
    </div>
    
    <!-- 步骤5：测试 -->
    <div style="margin-bottom: 32px;">
        <div style="display: flex; align-items: center; gap: 12px; margin-bottom: 16px;">
            <div style="width: 32px; height: 32px; background: #8b5cf6; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700;">5</div>
            <h3 style="font-size: 18px; color: #1a1a1a;">测试功能</h3>
        </div>
        
        <div style="margin-left: 44px;">
            <p style="color: #64748b; margin-bottom: 16px;">配置完成后，进行以下测试：</p>
            
            <div style="display: flex; flex-direction: column; gap: 12px;">
                <div style="display: flex; align-items: center; gap: 12px;">
                    <img src="https://api.iconify.design/mdi:check-circle-outline.svg?color=%23667eea" width="18" height="18" alt="">
                    <span>用微信关注公众号，应收到「欢迎关注」的自动回复</span>
                </div>
                <div style="display: flex; align-items: center; gap: 12px;">
                    <img src="https://api.iconify.design/mdi:check-circle-outline.svg?color=%23667eea" width="18" height="18" alt="">
                    <span>在平台点击微信登录，获取验证码</span>
                </div>
                <div style="display: flex; align-items: center; gap: 12px;">
                    <img src="https://api.iconify.design/mdi:check-circle-outline.svg?color=%23667eea" width="18" height="18" alt="">
                    <span>将验证码发送给公众号，应收到「验证成功」的回复</span>
                </div>
                <div style="display: flex; align-items: center; gap: 12px;">
                    <img src="https://api.iconify.design/mdi:check-circle-outline.svg?color=%23667eea" width="18" height="18" alt="">
                    <span>平台自动登录或绑定成功</span>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 常见配置问题 -->
    <div style="background: #f8fafc; border-radius: 16px; padding: 24px;">
        <h4 style="display: flex; align-items: center; gap: 8px; font-size: 16px; margin-bottom: 20px; color: #1e293b;">
            <img src="https://api.iconify.design/mdi:help-circle.svg?color=%23f59e0b" width="20" height="20" alt="">
            常见配置问题
        </h4>
        
        <div style="display: flex; flex-direction: column; gap: 16px;">
            <div>
                <p style="font-weight: 600; color: #1e293b; margin-bottom: 6px;">Q: 提交配置时提示「Token验证失败」？</p>
                <p style="color: #64748b; font-size: 14px;">A: 检查 Token 是否与服务器配置文件中的一致，确保服务器 URL 可从外网访问。</p>
            </div>
            <div>
                <p style="font-weight: 600; color: #1e293b; margin-bottom: 6px;">Q: 用户发送消息收不到回复？</p>
                <p style="color: #64748b; font-size: 14px;">A: 检查消息加解密方式是否为「明文模式」，检查服务器 PHP 错误日志。</p>
            </div>
            <div>
                <p style="font-weight: 600; color: #1e293b; margin-bottom: 6px;">Q: 提示「openid missing」或数据库写入失败？</p>
                <p style="color: #64748b; font-size: 14px;">A: 检查数据库表是否已创建，检查 config.php 中的数据库配置是否正确。</p>
            </div>
        </div>
    </div>
</div>
            <!-- 常见问题 -->
            <div id="faq" class="content-card">
                <div class="page-header">
                    <div class="page-icon" style="background: linear-gradient(135deg, #f59e0b, #d97706);">
                        <img src="https://api.iconify.design/mdi:frequently-asked-questions.svg?color=white" width="28" height="28" alt="">
                    </div>
                    <div class="page-title">
                        <h1>常见问题</h1>
                        <p>关于微信登录的常见问题解答</p>
                    </div>
                </div>
                
                <div class="faq-list">
                    <div class="faq-item">
                        <div class="faq-question" onclick="this.parentElement.classList.toggle('active')">
                            <span class="icon">
                                <img src="https://api.iconify.design/mdi:chevron-right.svg?color=%23667eea" width="18" height="18" alt="">
                            </span>
                            <span>发送验证码后没有反应？</span>
                        </div>
                        <div class="faq-answer">
                            验证码有效期为 5 分钟，请确认验证码是否正确，或在平台刷新后重新获取。
                        </div>
                    </div>
                    <div class="faq-item">
                        <div class="faq-question" onclick="this.parentElement.classList.toggle('active')">
                            <span class="icon">
                                <img src="https://api.iconify.design/mdi:chevron-right.svg?color=%23667eea" width="18" height="18" alt="">
                            </span>
                            <span>提示「验证码错误或已过期」？</span>
                        </div>
                        <div class="faq-answer">
                            请关闭弹窗，重新点击登录/绑定获取新的验证码。
                        </div>
                    </div>
                    <div class="faq-item">
                        <div class="faq-question" onclick="this.parentElement.classList.toggle('active')">
                            <span class="icon">
                                <img src="https://api.iconify.design/mdi:chevron-right.svg?color=%23667eea" width="18" height="18" alt="">
                            </span>
                            <span>一个微信可以绑定多个账号吗？</span>
                        </div>
                        <div class="faq-answer">
                            不可以，一个微信只能绑定一个平台账号。
                        </div>
                    </div>
                    <div class="faq-item">
                        <div class="faq-question" onclick="this.parentElement.classList.toggle('active')">
                            <span class="icon">
                                <img src="https://api.iconify.design/mdi:chevron-right.svg?color=%23667eea" width="18" height="18" alt="">
                            </span>
                            <span>换微信号了怎么办？</span>
                        </div>
                        <div class="faq-answer">
                            登录平台后，进入「用户中心」→「微信绑定」，先解绑旧微信，再用新微信重新绑定即可。
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 联系客服 -->
            <div id="contact" class="content-card">
                <div class="page-header">
                    <div class="page-icon" style="background: linear-gradient(135deg, #10b981, #059669);">
                        <img src="https://api.iconify.design/mdi:headset.svg?color=white" width="28" height="28" alt="">
                    </div>
                    <div class="page-title">
                        <h1>联系客服</h1>
                        <p>如有其他问题，请通过以下方式联系我们</p>
                    </div>
                </div>
                
                <div class="contact-grid">
    <!-- 微信公众号 -->
    <a href="javascript:;" onclick="showWechatQrcode()" class="contact-card">
        <div class="contact-icon">
            <img src="https://api.iconify.design/mdi:wechat.svg?color=%2307C160" width="24" height="24" alt="">
        </div>
        <div class="contact-info">
            <h4>微信公众号</h4>
            <p>直接发送问题，客服在线回复</p>
        </div>
    </a>
    
    <!-- 客服邮箱 -->
    <a href="mailto:admin@lhwks.cn" class="contact-card">
        <div class="contact-icon">
            <img src="https://api.iconify.design/mdi:email.svg?color=%23667eea" width="24" height="24" alt="">
        </div>
        <div class="contact-info">
            <h4>客服邮箱</h4>
            <p>admin@lhwks.cn</p>
        </div>
    </a>
    
    <!-- 抖音 -->
    <a href="https://v.douyin.com/hrGNwTrnzuU/" target="_blank" class="contact-card">
        <div class="contact-icon">
<img src="https://api.iconify.design/simple-icons:tiktok.svg?color=%23000000" width="24" height="24" alt="">        </div>
        <div class="contact-info">
            <h4>抖音</h4>
            <p>关注抖音号，获取视频教程</p>
        </div>
    </a>
     <!-- QQ 加好友 -->
    <a href="https://qm.qq.com/q/F3NdwHMTHa" target="_blank" class="contact-card">
        <div class="contact-icon">
            <img src="https://api.iconify.design/mdi:qqchat.svg?color=%2312B7F5" width="24" height="24" alt="">
        </div>
        <div class="contact-info">
            <h4>QQ 客服</h4>
            <p>点击添加好友，在线咨询</p>
        </div>
    </a>
</div>
            <!-- 更新日志 -->
<div id="changelog" class="content-card">
    <div class="page-header">
        <div class="page-icon" style="background: linear-gradient(135deg, #06b6d4, #0891b2);">
            <img src="https://api.iconify.design/mdi:newspaper.svg?color=white" width="28" height="28" alt="">
        </div>
        <div class="page-title">
            <h1>更新日志</h1>
            <p>系统版本更新记录 · 新功能 · 优化 · 修复</p>
        </div>
    </div>
    
    <?php if (empty($changelog)): ?>
        <div style="text-align: center; padding: 40px; color: #94a3b8;">
            <img src="https://api.iconify.design/mdi:note-off.svg?color=%2394a3b8" width="48" height="48" alt="">
            <p style="margin-top: 16px;">暂无更新日志</p>
        </div>
    <?php else: ?>
        <div class="timeline">
            <?php foreach ($changelog as $index => $log): ?>
                <div class="timeline-item <?php echo $index === 0 ? 'latest' : ''; ?>">
                    <?php if ($index === 0): ?>
                        <div class="latest-badge">
                            <img src="https://api.iconify.design/mdi:star.svg?color=white" width="12" height="12" alt="">
                            最新
                        </div>
                    <?php endif; ?>
                    
                    
                    
                    <div class="timeline-content">
                        <div class="timeline-header">
                            <span class="timeline-version">
                                <img src="https://api.iconify.design/mdi:tag.svg?color=%2306b6d4" width="16" height="16" alt="">
                                v<?php echo htmlspecialchars($log['version']); ?>
                                <?php if (!empty($log['is_featured'])): ?>
                                    <span class="featured-tag">
                                        <img src="https://api.iconify.design/mdi:star.svg?color=%23f59e0b" width="12" height="12" alt="">
                                        重要更新
                                    </span>
                                <?php endif; ?>
                            </span>
                            <span class="timeline-date">
                                <img src="https://api.iconify.design/mdi:calendar.svg?color=%2394a3b8" width="14" height="14" alt="">
                                <?php echo htmlspecialchars($log['release_date'] ?? $log['created_at'] ?? ''); ?>
                            </span>
                        </div>
                        
                        <?php if (!empty($log['content'])): ?>
                            <div class="timeline-body">
                                <?php 
$content = $log['content'];
$lines = explode("\n", $content);
foreach ($lines as $line):
    $line = trim($line);
    if (empty($line)) continue;
    
    $icon = 'circle-small';
    $color = '#64748b';
    if (strpos($line, '新增') === 0 || strpos($line, '✨') === 0) {
        $icon = 'plus-circle';
        $color = '#10b981';
    } elseif (strpos($line, '修复') === 0 || strpos($line, '🐛') === 0) {
        $icon = 'bug';
        $color = '#ef4444';
    } elseif (strpos($line, '优化') === 0 || strpos($line, '🎨') === 0) {
        $icon = 'palette';
        $color = '#f59e0b';
    } elseif (strpos($line, '移除') === 0) {
        $icon = 'minus-circle';
        $color = '#dc2626';
    } elseif (strpos($line, '安全') === 0 || strpos($line, '🔒') === 0) {
        $icon = 'shield';
        $color = '#8b5cf6';
    }
?>
    <div class="timeline-line">
        <img src="https://api.iconify.design/mdi:<?php echo $icon; ?>.svg?color=<?php echo ltrim($color, '#'); ?>" width="16" height="16" alt="">
        <span style="color: <?php echo $color; ?>;"><?php echo htmlspecialchars($line); ?></span>
    </div>
<?php endforeach; ?>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>
</div>
            <!-- 开发文档 -->
<div id="dev-docs" class="content-card">
    <div class="page-header">
        <div class="page-icon" style="background: linear-gradient(135deg, #1e293b, #0f172a);">
            <img src="https://api.iconify.design/mdi:code-braces.svg?color=white" width="28" height="28" alt="">
        </div>
        <div class="page-title">
            <h1>开发文档</h1>
            <p>微信登录功能技术文档 · API 接口 · 数据库结构</p>
        </div>
    </div>
    
    <!-- 架构说明 -->
    <h3 style="display: flex; align-items: center; gap: 10px; font-size: 18px; margin: 28px 0 16px; color: #1a1a1a;">
        <img src="https://api.iconify.design/mdi:architecture.svg?color=%23667eea" width="22" height="22" alt="">
        架构说明
    </h3>
    
    <div style="background: #f8fafc; border-radius: 16px; padding: 24px; margin-bottom: 24px;">
        <div style="display: flex; align-items: center; justify-content: space-around; flex-wrap: wrap; gap: 20px;">
            <div style="text-align: center;">
                <div style="width: 60px; height: 60px; background: #667eea; border-radius: 16px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;">
                    <img src="https://api.iconify.design/mdi:monitor.svg?color=white" width="30" height="30" alt="">
                </div>
                <span style="font-weight: 600;">平台前端</span>
                <p style="font-size: 12px; color: #94a3b8; margin-top: 4px;">生成验证码</p>
            </div>
            <div style="color: #94a3b8; font-size: 24px;">→</div>
            <div style="text-align: center;">
                <div style="width: 60px; height: 60px; background: #10b981; border-radius: 16px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;">
                    <img src="https://api.iconify.design/mdi:api.svg?color=white" width="30" height="30" alt="">
                </div>
                <span style="font-weight: 600;">API 服务</span>
                <p style="font-size: 12px; color: #94a3b8; margin-top: 4px;">轮询验证</p>
            </div>
            <div style="color: #94a3b8; font-size: 24px;">→</div>
            <div style="text-align: center;">
                <div style="width: 60px; height: 60px; background: #07C160; border-radius: 16px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;">
                    <img src="https://api.iconify.design/mdi:wechat.svg?color=white" width="30" height="30" alt="">
                </div>
                <span style="font-weight: 600;">微信服务器</span>
                <p style="font-size: 12px; color: #94a3b8; margin-top: 4px;">消息推送</p>
            </div>
            <div style="color: #94a3b8; font-size: 24px;">→</div>
            <div style="text-align: center;">
                <div style="width: 60px; height: 60px; background: #f59e0b; border-radius: 16px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;">
                    <img src="https://api.iconify.design/mdi:database.svg?color=white" width="30" height="30" alt="">
                </div>
                <span style="font-weight: 600;">数据库</span>
                <p style="font-size: 12px; color: #94a3b8; margin-top: 4px;">状态存储</p>
            </div>
        </div>
    </div>
    
    <!-- API 接口列表 -->
    <h3 style="display: flex; align-items: center; gap: 10px; font-size: 18px; margin: 28px 0 16px; color: #1a1a1a;">
        <img src="https://api.iconify.design/mdi:api.svg?color=%2310b981" width="22" height="22" alt="">
        API 接口列表
    </h3>
    
    <div style="overflow-x: auto;">
        <table style="width: 100%; border-collapse: collapse; font-size: 14px;">
            <thead>
                <tr style="background: #f8fafc; border-bottom: 2px solid #e2e8f0;">
                    <th style="padding: 14px 16px; text-align: left; font-weight: 600; color: #1e293b;">接口</th>
                    <th style="padding: 14px 16px; text-align: left; font-weight: 600; color: #1e293b;">方法</th>
                    <th style="padding: 14px 16px; text-align: left; font-weight: 600; color: #1e293b;">说明</th>
                </tr>
            </thead>
            <tbody>
                <tr style="border-bottom: 1px solid #f0f0f0;">
                    <td style="padding: 14px 16px;"><code style="background: #f1f5f9; padding: 4px 10px; border-radius: 6px; font-size: 13px;">/api/wechat-qrcode.php</code></td>
                    <td style="padding: 14px 16px;"><span style="background: #10b981; color: white; padding: 2px 10px; border-radius: 20px; font-size: 12px;">GET</span></td>
                    <td style="padding: 14px 16px;">生成登录验证码和 token</td>
                </tr>
                <tr style="border-bottom: 1px solid #f0f0f0;">
                    <td style="padding: 14px 16px;"><code style="background: #f1f5f9; padding: 4px 10px; border-radius: 6px; font-size: 13px;">/api/wechat-check.php</code></td>
                    <td style="padding: 14px 16px;"><span style="background: #10b981; color: white; padding: 2px 10px; border-radius: 20px; font-size: 12px;">GET</span></td>
                    <td style="padding: 14px 16px;">轮询检查登录状态</td>
                </tr>
                <tr style="border-bottom: 1px solid #f0f0f0;">
                    <td style="padding: 14px 16px;"><code style="background: #f1f5f9; padding: 4px 10px; border-radius: 6px; font-size: 13px;">/api/wechat-server.php</code></td>
                    <td style="padding: 14px 16px;"><span style="background: #f59e0b; color: white; padding: 2px 10px; border-radius: 20px; font-size: 12px;">POST</span></td>
                    <td style="padding: 14px 16px;">微信服务器回调，处理用户消息</td>
                </tr>
                <tr style="border-bottom: 1px solid #f0f0f0;">
                    <td style="padding: 14px 16px;"><code style="background: #f1f5f9; padding: 4px 10px; border-radius: 6px; font-size: 13px;">/api/wechat-bind-generate.php</code></td>
                    <td style="padding: 14px 16px;"><span style="background: #10b981; color: white; padding: 2px 10px; border-radius: 20px; font-size: 12px;">GET</span></td>
                    <td style="padding: 14px 16px;">生成绑定验证码和 token</td>
                </tr>
                <tr>
                    <td style="padding: 14px 16px;"><code style="background: #f1f5f9; padding: 4px 10px; border-radius: 6px; font-size: 13px;">/api/wechat-bind-check.php</code></td>
                    <td style="padding: 14px 16px;"><span style="background: #10b981; color: white; padding: 2px 10px; border-radius: 20px; font-size: 12px;">GET</span></td>
                    <td style="padding: 14px 16px;">轮询检查绑定状态</td>
                </tr>
            </tbody>
        </table>
    </div>
    
    <!-- 数据库结构 -->
    <h3 style="display: flex; align-items: center; gap: 10px; font-size: 18px; margin: 28px 0 16px; color: #1a1a1a;">
        <img src="https://api.iconify.design/mdi:database.svg?color=%23f59e0b" width="22" height="22" alt="">
        数据库结构
    </h3>
    
    <div style="margin-bottom: 20px;">
        <h4 style="font-size: 15px; margin-bottom: 12px; color: #1e293b;">wechat_login_tokens（登录验证码表）</h4>
        <div style="background: #1e293b; border-radius: 16px; padding: 20px; overflow-x: auto;">
            <pre style="color: #e2e8f0; font-family: 'Monaco', 'Menlo', monospace; font-size: 13px; line-height: 1.8; margin: 0;">CREATE TABLE `wechat_login_tokens` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `token` varchar(32) NOT NULL COMMENT '登录token',
  `openid` varchar(64) DEFAULT NULL COMMENT '用户openid',
  `code` varchar(10) NOT NULL COMMENT '6位验证码',
  `status` tinyint(1) DEFAULT 0 COMMENT '0待验证 1已验证 2已登录',
  `expire_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `token` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;</pre>
        </div>
    </div>
    
    <div>
        <h4 style="font-size: 15px; margin-bottom: 12px; color: #1e293b;">wechat_bind_tokens（绑定验证码表）</h4>
        <div style="background: #1e293b; border-radius: 16px; padding: 20px; overflow-x: auto;">
            <pre style="color: #e2e8f0; font-family: 'Monaco', 'Menlo', monospace; font-size: 13px; line-height: 1.8; margin: 0;">CREATE TABLE `wechat_bind_tokens` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `token` varchar(32) NOT NULL COMMENT '绑定token',
  `openid` varchar(64) DEFAULT NULL COMMENT '用户openid',
  `code` varchar(10) NOT NULL COMMENT '6位验证码',
  `status` tinyint(1) DEFAULT 0 COMMENT '0待验证 1已验证 2已完成',
  `expire_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `token` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;</pre>
        </div>
    </div>
    
    <!-- 业务流程 -->
    <h3 style="display: flex; align-items: center; gap: 10px; font-size: 18px; margin: 28px 0 16px; color: #1a1a1a;">
        <img src="https://api.iconify.design/mdi:workflow.svg?color=%238b5cf6" width="22" height="22" alt="">
        业务流程
    </h3>
    
    <div style="background: #f8fafc; border-radius: 16px; padding: 24px;">
        <div style="display: flex; flex-direction: column; gap: 16px;">
            <div style="display: flex; align-items: flex-start; gap: 16px;">
                <div style="width: 28px; height: 28px; background: #667eea; color: white; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;">1</div>
                <div style="flex: 1;">
                    <strong style="color: #1e293b;">平台生成验证码</strong>
                    <p style="color: #64748b; font-size: 14px; margin-top: 4px;">调用 /api/wechat-qrcode.php 生成 6 位验证码和 token，存入 wechat_login_tokens 表</p>
                </div>
            </div>
            <div style="display: flex; align-items: flex-start; gap: 16px;">
                <div style="width: 28px; height: 28px; background: #07C160; color: white; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;">2</div>
                <div style="flex: 1;">
                    <strong style="color: #1e293b;">用户发送验证码</strong>
                    <p style="color: #64748b; font-size: 14px; margin-top: 4px;">用户关注公众号后，将验证码发送给公众号</p>
                </div>
            </div>
            <div style="display: flex; align-items: flex-start; gap: 16px;">
                <div style="width: 28px; height: 28px; background: #f59e0b; color: white; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;">3</div>
                <div style="flex: 1;">
                    <strong style="color: #1e293b;">微信服务器回调</strong>
                    <p style="color: #64748b; font-size: 14px; margin-top: 4px;">微信服务器 POST 到 /api/wechat-server.php，更新 wechat_login_tokens 表中对应记录的 openid 和 status</p>
                </div>
            </div>
            <div style="display: flex; align-items: flex-start; gap: 16px;">
                <div style="width: 28px; height: 28px; background: #10b981; color: white; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;">4</div>
                <div style="flex: 1;">
                    <strong style="color: #1e293b;">平台轮询检测</strong>
                    <p style="color: #64748b; font-size: 14px; margin-top: 4px;">前端每 2 秒调用 /api/wechat-check.php 检查状态，检测到 status=1 时自动创建/绑定用户并登录</p>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 返回示例 -->
    <h3 style="display: flex; align-items: center; gap: 10px; font-size: 18px; margin: 28px 0 16px; color: #1a1a1a;">
        <img src="https://api.iconify.design/mdi:code-json.svg?color=%23f59e0b" width="22" height="22" alt="">
        接口返回示例
    </h3>
    
    <div style="margin-bottom: 20px;">
        <h4 style="font-size: 15px; margin-bottom: 12px; color: #1e293b;">生成验证码响应</h4>
        <div style="background: #1e293b; border-radius: 16px; padding: 20px;">
            <pre style="color: #e2e8f0; font-family: 'Monaco', 'Menlo', monospace; font-size: 13px; line-height: 1.8; margin: 0;">{
  "code": 0,
  "token": "abc123def456...",
  "verify_code": "123456"
}</pre>
        </div>
    </div>
    
    <div>
        <h4 style="font-size: 15px; margin-bottom: 12px; color: #1e293b;">状态轮询响应</h4>
        <div style="background: #1e293b; border-radius: 16px; padding: 20px;">
            <pre style="color: #e2e8f0; font-family: 'Monaco', 'Menlo', monospace; font-size: 13px; line-height: 1.8; margin: 0;">// 等待中
{ "status": "waiting" }

// 已验证
{ "status": "verified", "redirect": "/admin.php" }

// 成功
{ "status": "success", "redirect": "/admin.php" }

// 过期
{ "status": "expired" }</pre>
        </div>
    </div>
</div>
        </main>
    </div>
    <!-- 微信公众号二维码弹窗 -->
<div id="wechatQrcodeModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 9999; align-items: center; justify-content: center;" onclick="closeWechatQrcode()">
    <div style="background: white; border-radius: 24px; padding: 32px; text-align: center; max-width: 320px; box-shadow: 0 20px 40px rgba(0,0,0,0.2);" onclick="event.stopPropagation()">
        <h3 style="margin-bottom: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; color: #1a1a1a;">
            <img src="https://api.iconify.design/mdi:wechat.svg?color=%2307C160" width="28" height="28" alt="">
            微信公众号
        </h3>
        <p style="color: #64748b; font-size: 14px; margin-bottom: 20px;">
            扫码关注公众号，获取最新资讯
        </p>
        <img src="/assets/uploads/wechat.jpg" style="width: 220px; height: 220px; border-radius: 16px; margin-bottom: 20px;" alt="公众号二维码">
        <p style="color: #94a3b8; font-size: 12px; margin-bottom: 16px;">
            微信扫一扫，关注我们
        </p>
        <button onclick="closeWechatQrcode()" style="padding: 10px 40px; background: #07C160; color: white; border: none; border-radius: 30px; font-size: 15px; font-weight: 500; cursor: pointer;">
            关闭
        </button>
    </div>
</div>

<script>
function showWechatQrcode() {
    document.getElementById('wechatQrcodeModal').style.display = 'flex';
    document.body.style.overflow = 'hidden';
}

function closeWechatQrcode() {
    document.getElementById('wechatQrcodeModal').style.display = 'none';
    document.body.style.overflow = '';
}

// ESC 关闭
document.addEventListener('keydown', function(e) {
    if (e.key === 'Escape') {
        closeWechatQrcode();
    }
});
</script>
            <?php include 'footer.php'; ?>

    <script>
        // 平滑滚动
        document.querySelectorAll('.tree-link[href^="#"]').forEach(link => {
            link.addEventListener('click', function(e) {
                e.preventDefault();
                const target = document.querySelector(this.getAttribute('href'));
                if (target) {
                    target.scrollIntoView({ behavior: 'smooth', block: 'start' });
                }
            });
        });
        
        // 高亮当前目录
        const sections = document.querySelectorAll('[id]');
        const navLinks = document.querySelectorAll('.tree-link[href^="#"]');
        
        window.addEventListener('scroll', () => {
            let current = '';
            sections.forEach(section => {
                const sectionTop = section.offsetTop;
                if (scrollY >= sectionTop - 100) {
                    current = section.getAttribute('id');
                }
            });
            
            navLinks.forEach(link => {
                link.classList.remove('active');
                if (link.getAttribute('href') === '#' + current) {
                    link.classList.add('active');
                }
            });
        });
    </script>
</body>
</html>