<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>微信授权跳转</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .container {
      background: rgba(255, 255, 255, 0.95);
      border-radius: 20px;
      box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
      padding: 40px 20px;
      text-align: center;
      max-width: 90%;
      width: 100%;
      backdrop-filter: blur(10px);
      animation: fadeIn 0.5s ease-out;
    }

    @keyframes fadeIn {
      from {
        opacity: 0;
        transform: translateY(-20px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .logo {
      width: 80px;
      height: 80px;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      border-radius: 50%;
      margin: 0 auto 20px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: white;
      font-size: 30px;
      font-weight: bold;
    }

    h3 {
      color: #333;
      margin-bottom: 20px;
      font-size: 22px;
      font-weight: 500;
    }

    .progress-container {
      width: 100%;
      height: 6px;
      background-color: #f0f0f0;
      border-radius: 3px;
      margin: 30px 0;
      overflow: hidden;
    }

    .progress-bar {
      height: 100%;
      background: linear-gradient(90deg, #667eea, #764ba2);
      width: 0%;
      border-radius: 3px;
      animation: progress 1s ease-in-out forwards;
    }

    @keyframes progress {
      to {
        width: 100%;
      }
    }

    .url-display {
      background: #f8f9fa;
      border-radius: 10px;
      padding: 15px;
      margin: 20px 0;
      word-break: break-all;
      font-size: 12px;
      color: #666;
      border: 1px solid #eee;
      max-height: 100px;
      overflow-y: auto;
    }

    .countdown {
      color: #667eea;
      font-weight: bold;
      font-size: 16px;
      margin: 15px 0;
    }

    .manual-link {
      display: inline-block;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      color: white;
      text-decoration: none;
      padding: 12px 30px;
      border-radius: 25px;
      font-weight: 500;
      transition: all 0.3s ease;
      box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
      width: 80%;
      max-width: 200px;
    }

    .manual-link:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    }

    .manual-link:active {
      transform: translateY(0);
    }

    .loading {
      display: inline-block;
      width: 20px;
      height: 20px;
      border: 3px solid rgba(102, 126, 234, 0.3);
      border-radius: 50%;
      border-top-color: #667eea;
      animation: spin 1s ease-in-out infinite;
      margin-right: 10px;
      vertical-align: middle;
    }

    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    .tips {
      color: #999;
      font-size: 12px;
      margin-top: 20px;
      line-height: 1.5;
    }

    @media (max-width: 480px) {
      .container {
        padding: 30px 15px;
      }
      
      h3 {
        font-size: 18px;
      }
      
      .manual-link {
        padding: 10px 20px;
        font-size: 14px;
      }
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="logo">WX</div>
    <h3>微信授权跳转中...</h3>
    
    <div class="progress-container">
      <div class="progress-bar" id="progressBar"></div>
    </div>
    
    <div class="countdown">
      <span class="loading"></span>
      页面即将跳转...
    </div>
    
    <p>如果未自动跳转，请点击下方按钮</p>
    <a href="{{{ url }}}" class="manual-link" id="manualLink">立即跳转</a>
    
    <div class="tips">
      <p>跳转后请在微信中完成授权操作</p>
      <p>授权完成后将自动返回应用</p>
    </div>
  </div>

  <script>
    // 确保URL正确解码
    function decodeHtmlEntities(text) {
      var textArea = document.createElement('textarea');
      textArea.innerHTML = text;
      return textArea.value;
    }
    
    // 获取并处理URL
    var rawUrl = "{{{ url }}}";
    var decodedUrl = decodeHtmlEntities(rawUrl);
    var finalUrl = decodedUrl || rawUrl;
    
    // 设置手动链接
    document.getElementById('manualLink').href = finalUrl;
    
    // 更新进度条动画
    var progressBar = document.getElementById('progressBar');
    progressBar.style.animation = 'progress 1s ease-in-out forwards';
    
    // 1秒后跳转到微信授权页面
    setTimeout(() => {
      if (finalUrl && (finalUrl.startsWith('http://') || finalUrl.startsWith('https://'))) {
        window.location.href = finalUrl;
      } else {
        alert('跳转链接无效，请检查后重试');
      }
    }, 1000);
  </script>
</body>
</html>