<!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;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        }
        /* 1. 全屏遮罩层 (Overlay) */
        body, html {
            height: 100%;
            width: 100%;
        }
        .overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.45);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }
        /* 2. 弹窗卡片 */
        .modal {
            background-color: #ffffff;
            width: 420px;
            padding: 30px 40px;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            text-align: center;
        }
        /* 3. 标题样式 */
        .modal-title {
            font-size: 18px;
            color: #333;
            margin-bottom: 40px;
            font-weight: 500;
        }
        /* 4. 加载内容区域 */
        .loading-content {
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 50px;
            color: #333;
            font-size: 14px;
        }
        /* CSS 加载动画圆圈 */
        .spinner {
            width: 24px;
            height: 24px;
            border: 3px solid #e5e5e5;
            border-top: 3px solid #666;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-right: 12px;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        /* 5. 底部按钮区域 - 核心修改部分 */
        .modal-footer {
            display: flex;
            justify-content: space-between;
        }
        
        /* 通用按钮样式 */
        .btn {
            flex: 1; /* 平分宽度 */
            height: 40px;
            line-height: 40px; /* 修正line-height使其垂直居中，减去边框宽度可选，这里保持40也可 */
            border-radius: 4px;
            font-size: 14px;
            cursor: pointer;
            outline: none;
            transition: all 0.2s;
            /* 确保所有按钮都有默认边框位置，防止抖动 */
            border: 1px solid transparent; 
        }
        
		  /* "取消支付" 按钮 */
		.btn-cancel {
			background-color: #fff;
			border: 1px solid #d9d9d9;
			color: #333;
			
			/* 【核心修改】强制给右边增加 20px 的距离 */
			margin-right: 20px; 
		}

		/* 移除之前可能存在的 margin-left 干扰 */
		.btn-cancel:hover {
			border-color: #999;
			color: #000;
			margin-left: 0; /* 确保悬停时不会有左边距 */
		}
        
        /* "支付完成" 按钮 */
        .btn-confirm {
            background-color: #f7c78e;
            color: #fff;
        }
        .btn-confirm:hover {
            background-color: #f0bd7d;
        }
    </style>
</head>
<body>
    <!-- 遮罩层 -->
    <div class="overlay" id="myModal">
        <div class="modal">
            <div class="modal-title" id="title">支付中</div>
            <div class="loading-content">
                <div class="spinner"></div>
                <span id="content">支付中，完成支付之前请勿关闭页面</span>
            </div>
            <div class="modal-footer">
                <button class="btn btn-cancel" onclick="PayClose()" id="close">关闭</button>
                <button class="btn btn-confirm" onclick="PayCheck()" id="over">支付完成</button>
            </div>
        </div>
    </div>
<script>
    var modal = document.getElementById("myModal");
    // 如果需要默认显示，保持 flex；通常默认是 hidden 等待触发
     modal.style.display = "flex"; 

    function PayClose() {
      // 检查 u3d_func 是否存在，防止在浏览器直接运行时报错
      if(typeof u3d_func !== 'undefined') {
          u3d_func('PayClose', {});
      } else {
          console.log("调用 PayClose");
          // 测试用：关闭弹窗
          // modal.style.display = "none";
      }
    }

    function PayCheck() {
      if(typeof u3d_func !== 'undefined') {
          u3d_func('PayCheck', {});
      } else {
          console.log("调用 PayCheck");
      }
    }

    function unityToJsLoadErr(str) {
        modal.style.display = "none";
    }

    function getQueryParam(name) {
        const urlParams = new URLSearchParams(window.location.search);
        return urlParams.get(name);
    }
	
		   // 页面加载完成后执行
    document.addEventListener('DOMContentLoaded', function() {
      // 显示弹窗
      modal.style.display = "flex";
      
      // 获取URL参数
      const paying = getQueryParam('paying');
      const close = getQueryParam('close');
	  const payover = getQueryParam('payover');
      const payingdesc = getQueryParam('payingdesc');
      // 设置显示内容
	  const titleText = document.getElementById('title');
      const contentText = document.getElementById('content');
      const closebtn = document.getElementById('close');
	  const overbtn = document.getElementById('over');
      if (paying) {
        titleText.textContent = paying;
      }
	  if (payingdesc) {
        contentText.textContent = payingdesc;
      }
	  if (payover) {
        overbtn.textContent = payover;
      }
	  if (close) {
        closebtn.textContent = close;
      }
    });
</script>
</body>
</html>