update: 2026-03-28 20:59
This commit is contained in:
71
InfoGenie-frontend/public/60sapi/周期资讯/当日货币汇率.html
Normal file
71
InfoGenie-frontend/public/60sapi/周期资讯/当日货币汇率.html
Normal file
@@ -0,0 +1,71 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>当日货币汇率</title>
|
||||
<style>
|
||||
*{margin:0;padding:0;box-sizing:border-box}
|
||||
body{font-family:'KaiTi','楷体',serif;background:#f9fafb;color:#1f2937;line-height:1.6;min-height:100vh}
|
||||
.header{background:linear-gradient(135deg,#065f46,#059669);color:#fff;padding:16px;display:flex;align-items:center;gap:12px;position:sticky;top:0;z-index:10}
|
||||
.header h1{flex:1;font-size:16px;font-weight:700}.btn{width:36px;height:36px;border:none;border-radius:10px;background:rgba(255,255,255,.15);color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:18px}.btn:hover{background:rgba(255,255,255,.25)}
|
||||
.body{max-width:720px;margin:0 auto;padding:20px 16px 40px}
|
||||
.hero{background:linear-gradient(135deg,#065f46,#059669);border-radius:16px;padding:20px;margin-bottom:16px;color:#fff;text-align:center}
|
||||
.hero h2{font-size:22px;margin-bottom:4px}.hero p{font-size:12px;opacity:.8}
|
||||
.search{width:100%;padding:12px 16px;border:2px solid #e5e7eb;border-radius:12px;font-size:14px;font-family:inherit;margin-bottom:12px;transition:border-color .2s}
|
||||
.search:focus{border-color:#4ade80;outline:none}
|
||||
.table{border-radius:12px;overflow:hidden;border:1px solid #e5e7eb}
|
||||
.row{display:flex;align-items:center;padding:12px 16px;border-bottom:1px solid #f3f4f6}
|
||||
.row:last-child{border-bottom:none}.row:nth-child(even){background:#f9fafb}.row:hover{background:#f0fdf4}
|
||||
.currency{flex:1;font-size:14px;font-weight:600}.rate{font-size:14px;color:#059669;font-weight:500;font-variant-numeric:tabular-nums}
|
||||
.loader{display:flex;flex-direction:column;align-items:center;padding:60px 0;color:#9ca3af;gap:10px;font-size:13px}
|
||||
.spinner{width:24px;height:24px;border:3px solid #e5e7eb;border-top-color:#059669;border-radius:50%;animation:spin 1s linear infinite}
|
||||
@keyframes spin{to{transform:rotate(360deg)}}
|
||||
.err{text-align:center;padding:40px 16px;color:#ef4444;font-size:14px}
|
||||
.hint{text-align:center;margin-top:12px;color:#9ca3af;font-size:12px}
|
||||
</style>
|
||||
<script src="/60sapi/ig-embed.js"></script>
|
||||
<script src="/60sapi/sixty-runtime.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<button class="btn" onclick="history.back()">←</button>
|
||||
<h1>💱 当日货币汇率</h1>
|
||||
<button class="btn" onclick="loadData()">↻</button>
|
||||
</div>
|
||||
<div class="body" id="content">
|
||||
<div class="loader"><div class="spinner"></div><span>加载中...</span></div>
|
||||
</div>
|
||||
<script>
|
||||
let allRates=[];let baseCode='CNY';
|
||||
const common=['USD','EUR','GBP','JPY','KRW','HKD','TWD','SGD','AUD','CAD','CHF','RUB','THB','MYR','INR','VND'];
|
||||
function renderTable(keyword){
|
||||
let list=keyword?allRates.filter(r=>r.currency.toLowerCase().includes(keyword.toLowerCase())):
|
||||
[...allRates.filter(r=>common.includes(r.currency)),...allRates.filter(r=>!common.includes(r.currency))];
|
||||
let html='<div class="table">';
|
||||
list.slice(0,80).forEach((r,i)=>{
|
||||
html+=`<div class="row"><div class="currency">${r.currency}</div><div class="rate">1 ${baseCode} = ${Number(r.rate).toFixed(4)} ${r.currency}</div></div>`;
|
||||
});
|
||||
html+='</div>';
|
||||
if(list.length>80)html+=`<div class="hint">共 ${list.length} 种货币,搜索查看更多</div>`;
|
||||
return html;
|
||||
}
|
||||
async function loadData(){
|
||||
const el=document.getElementById('content');
|
||||
el.innerHTML='<div class="loader"><div class="spinner"></div><span>加载中...</span></div>';
|
||||
try{
|
||||
const res=await fetch(window.__SIXTY_API_BASE__+'/v2/exchange-rate?encoding=json',{headers:{Accept:'application/json'}});
|
||||
const json=await res.json();
|
||||
const d=json.data||json;
|
||||
if(!d||!d.rates)throw new Error('暂无汇率数据');
|
||||
allRates=d.rates;baseCode=d.base_code||'CNY';
|
||||
let html=`<div class="hero"><h2>💱 ${baseCode} 汇率</h2><p>更新时间:${d.updated||'未知'}</p></div>`;
|
||||
html+=`<input class="search" placeholder="搜索货币代码,如 USD、EUR..." oninput="filterRates(this.value)">`;
|
||||
html+=`<div id="table-wrap">${renderTable('')}</div>`;
|
||||
el.innerHTML=html;
|
||||
}catch(e){el.innerHTML=`<div class="err">加载失败:${e.message}</div>`}
|
||||
}
|
||||
function filterRates(v){document.getElementById('table-wrap').innerHTML=renderTable(v)}
|
||||
loadData();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user