205 lines
7.9 KiB
HTML
205 lines
7.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
<title>枢机信用储备银行 - 分享钱包</title>
|
|
<style>
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
margin: 0;
|
|
padding: 0;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
transition: background-color 0.5s, color 0.5s;
|
|
padding: 20px;
|
|
box-sizing: border-box;
|
|
}
|
|
.wallet-container {
|
|
text-align: center;
|
|
width: 100%;
|
|
max-width: 500px;
|
|
padding: 30px 24px;
|
|
border-radius: 15px;
|
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
|
}
|
|
h1 {
|
|
margin: 0 0 8px;
|
|
font-size: 22px;
|
|
font-weight: 600;
|
|
}
|
|
.subtitle {
|
|
font-size: 13px;
|
|
opacity: 0.7;
|
|
margin-bottom: 20px;
|
|
}
|
|
.balance-card {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 14px 16px;
|
|
border-radius: 10px;
|
|
background-color: rgba(255, 255, 255, 0.08);
|
|
margin-bottom: 8px;
|
|
}
|
|
.balance-info {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 2px;
|
|
text-align: left;
|
|
}
|
|
.balance-type {
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
}
|
|
.balance-symbol {
|
|
font-size: 12px;
|
|
opacity: 0.6;
|
|
}
|
|
.balance-amount {
|
|
font-size: 20px;
|
|
font-weight: bold;
|
|
font-family: 'Courier New', monospace;
|
|
letter-spacing: 1px;
|
|
}
|
|
.expire-info {
|
|
margin-top: 18px;
|
|
font-size: 12px;
|
|
opacity: 0.6;
|
|
}
|
|
.error-box {
|
|
padding: 16px;
|
|
border-radius: 8px;
|
|
background-color: rgba(239, 68, 68, 0.1);
|
|
color: #dc2626;
|
|
font-size: 14px;
|
|
margin: 20px 0;
|
|
}
|
|
.empty-text {
|
|
opacity: 0.6;
|
|
padding: 20px;
|
|
font-size: 14px;
|
|
}
|
|
/* 主题样式 */
|
|
.default-theme { background-color: #f5f5f5; color: #333; }
|
|
.default-theme .wallet-container { background-color: white; }
|
|
.green-theme { background-color: #e8f5e9; color: #2e7d32; }
|
|
.green-theme .wallet-container { background-color: #ffffff; }
|
|
.blue-theme { background-color: #e3f2fd; color: #1565c0; }
|
|
.blue-theme .wallet-container { background-color: #ffffff; }
|
|
.gold-theme { background-color: #212121; color: #ffd700; }
|
|
.gold-theme .wallet-container { background-color: #333333; }
|
|
.corporate-theme { background-color: #0d47a1; color: white; }
|
|
.corporate-theme .wallet-container { background-color: #1565c0; }
|
|
</style>
|
|
</head>
|
|
<body class="default-theme">
|
|
<div class="wallet-container">
|
|
<h1>枢机信用储备银行</h1>
|
|
<div class="subtitle">分享钱包余额</div>
|
|
<div id="balances-list">
|
|
<div class="empty-text">数据加载中...</div>
|
|
</div>
|
|
<div id="expire-info" class="expire-info" style="display:none;"></div>
|
|
</div>
|
|
<script>
|
|
// 格式化数字显示(保留三位小数,添加千分位)
|
|
function FormatAmount(n) {
|
|
if (n === null || n === undefined || isNaN(n)) return '0.000';
|
|
return Number(n).toLocaleString(undefined, {
|
|
minimumFractionDigits: 3,
|
|
maximumFractionDigits: 3
|
|
});
|
|
}
|
|
|
|
// 根据 GC 数量设置主题
|
|
function SetThemeByGC(amount) {
|
|
const body = document.body;
|
|
body.className = '';
|
|
if (amount === 0) {
|
|
body.classList.add('default-theme');
|
|
} else if (amount > 0 && amount <= 9999) {
|
|
body.classList.add('green-theme');
|
|
} else if (amount > 9999 && amount <= 999999) {
|
|
body.classList.add('blue-theme');
|
|
} else if (amount > 999999 && amount <= 9999999) {
|
|
body.classList.add('gold-theme');
|
|
} else if (amount > 9999999) {
|
|
body.classList.add('corporate-theme');
|
|
} else {
|
|
body.classList.add('default-theme');
|
|
}
|
|
}
|
|
|
|
// 解析 token 参数
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const token = urlParams.get('token');
|
|
|
|
const listEl = document.getElementById('balances-list');
|
|
const expireEl = document.getElementById('expire-info');
|
|
|
|
if (!token) {
|
|
listEl.innerHTML = '<div class="error-box">缺少分享码参数,请通过有效的二维码链接访问。</div>';
|
|
} else {
|
|
fetch(`/API/Wallet/SharedBalance?token=${encodeURIComponent(token)}`)
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
if (data.status !== 0) {
|
|
listEl.innerHTML = `<div class="error-box">${data.msg || '查询失败'}</div>`;
|
|
return;
|
|
}
|
|
const balances = data.Balances || [];
|
|
if (!balances.length) {
|
|
listEl.innerHTML = '<div class="empty-text">暂无资产</div>';
|
|
} else {
|
|
listEl.innerHTML = balances.map(b => `
|
|
<div class="balance-card">
|
|
<div class="balance-info">
|
|
<div class="balance-type">${b.Type}</div>
|
|
<div class="balance-symbol">${b.Symbol || ''}</div>
|
|
</div>
|
|
<div class="balance-amount">${FormatAmount(b.Balance)}</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
// 显示剩余有效期
|
|
const ttl = data.ExpiresIn || 0;
|
|
if (ttl > 0) {
|
|
const h = Math.floor(ttl / 3600);
|
|
const m = Math.floor((ttl % 3600) / 60);
|
|
const s = ttl % 60;
|
|
expireEl.textContent = `分享码剩余有效:${h}时${m}分${s}秒`;
|
|
expireEl.style.display = 'block';
|
|
// 倒计时
|
|
let remain = ttl;
|
|
const timer = setInterval(() => {
|
|
remain = Math.max(0, remain - 1);
|
|
if (remain <= 0) {
|
|
clearInterval(timer);
|
|
expireEl.textContent = '分享码已过期';
|
|
listEl.innerHTML = '<div class="error-box">分享码已过期,请向钱包主人索取新的二维码。</div>';
|
|
return;
|
|
}
|
|
const hh = Math.floor(remain / 3600);
|
|
const mm = Math.floor((remain % 3600) / 60);
|
|
const ss = remain % 60;
|
|
expireEl.textContent = `分享码剩余有效:${hh}时${mm}分${ss}秒`;
|
|
}, 1000);
|
|
}
|
|
|
|
// 根据主币种(GC)设置主题
|
|
const gc = balances.find(x => x.Type === 'GC');
|
|
SetThemeByGC(gc ? gc.Balance : 0);
|
|
})
|
|
.catch(err => {
|
|
console.error('查询失败:', err);
|
|
listEl.innerHTML = '<div class="error-box">网络错误,查询失败</div>';
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|