周五定时更新

This commit is contained in:
2025-10-31 14:09:58 +08:00
parent a60603acd0
commit a2fc94b402
28 changed files with 830 additions and 265 deletions

View File

@@ -13,7 +13,7 @@
<div v-for="(row, idx) in rechargeRows" :key="getRowKey(row, idx)" class="record-item" :class="statusClass(row.status)" @click="toggleExpand('recharge', row, idx)">
<div class="item-main">
<div class="item-left">
<div class="amount">+ {{ formatTrunc(row.amount, 2) }} {{ row.fromSymbol || 'USDT' }}</div>
<div class="amount">+ {{ formatDec6(row.amount) }} {{ (row.fromSymbol || 'USDT').toUpperCase() }}</div>
<div class="chain">{{ formatChain(row.fromChain) }}</div>
</div>
<div class="item-right">
@@ -23,8 +23,20 @@
</div>
<div v-show="isExpanded('recharge', row, idx)" class="expand-panel">
<div class="expand-grid">
<div class="expand-item"><span class="label">充值地址</span><span class="value mono-ellipsis" :title="row.fromAddress">{{ row.fromAddress }}</span></div>
<div class="expand-item" v-if="row.txHash"><span class="label">交易哈希</span><span class="value mono-ellipsis" :title="row.txHash">{{ row.txHash }}</span></div>
<div class="expand-item">
<span class="label">充值地址</span>
<div class="value value-row">
<span class="mono-ellipsis" :title="row.fromAddress">{{ row.fromAddress }}</span>
<el-button type="text" size="mini" icon="el-icon-document-copy" @click.stop="handleCopy(row.fromAddress, '充值地址')">复制</el-button>
</div>
</div>
<div class="expand-item" v-if="row.txHash">
<span class="label">交易哈希</span>
<div class="value value-row">
<span class="mono-ellipsis" :title="row.txHash">{{ row.txHash }}</span>
<el-button type="text" size="mini" icon="el-icon-document-copy" @click.stop="handleCopy(row.txHash, '交易哈希')">复制</el-button>
</div>
</div>
</div>
</div>
</div>
@@ -42,7 +54,7 @@
<div v-for="(row, idx) in withdrawRows" :key="getRowKey(row, idx)" class="record-item" :class="statusClass(row.status)" @click="toggleExpand('withdraw', row, idx)">
<div class="item-main">
<div class="item-left">
<div class="amount">- {{ formatTrunc(row.amount, 2) }} {{ row.toSymbol || 'USDT' }}</div>
<div class="amount">- {{ formatDec6(row.amount) }} {{ (row.toSymbol || 'USDT').toUpperCase() }}</div>
<div class="chain">{{ formatChain(row.toChain) }}</div>
</div>
<div class="item-right">
@@ -52,8 +64,20 @@
</div>
<div v-show="isExpanded('withdraw', row, idx)" class="expand-panel">
<div class="expand-grid">
<div class="expand-item"><span class="label">收款地址</span><span class="value mono-ellipsis" :title="row.toAddress">{{ row.toAddress }}</span></div>
<div class="expand-item" v-if="row.txHash"><span class="label">交易哈希</span><span class="value mono-ellipsis" :title="row.txHash">{{ row.txHash }}</span></div>
<div class="expand-item">
<span class="label">收款地址</span>
<div class="value value-row">
<span class="mono-ellipsis" :title="row.toAddress">{{ row.toAddress }}</span>
<el-button type="text" size="mini" icon="el-icon-document-copy" @click.stop="handleCopy(row.toAddress, '收款地址')">复制</el-button>
</div>
</div>
<div class="expand-item" v-if="row.txHash">
<span class="label">交易哈希</span>
<div class="value value-row">
<span class="mono-ellipsis" :title="row.txHash">{{ row.txHash }}</span>
<el-button type="text" size="mini" icon="el-icon-document-copy" @click.stop="handleCopy(row.txHash, '交易哈希')">复制</el-button>
</div>
</div>
</div>
</div>
</div>
@@ -71,7 +95,7 @@
<div v-for="(row, idx) in consumeRows" :key="getRowKey(row, idx)" class="record-item" :class="statusClass(row.status)" @click="toggleExpand('consume', row, idx)">
<div class="item-main">
<div class="item-left">
<div class="amount">- {{ formatTrunc(row.realAmount, 2) }} {{ (row.fromSymbol || 'USDT').toUpperCase() }}</div>
<div class="amount">- {{ formatDec6(row.realAmount) }} {{ (row.fromSymbol || 'USDT').toUpperCase() }}</div>
<div class="chain">{{ formatChain(row.fromChain) }}</div>
</div>
<div class="item-right">
@@ -138,7 +162,7 @@ export default {
// },
// {
// createTime: '2024-01-15 14:30:25',
// amount: 100,
// amount: 100.656578965,
// fromAddress: 'djdddksfhsfj',
// fromChain: 'tron',
// fromSymbol: 'USDT',
@@ -345,9 +369,16 @@ export default {
getPayStatusType(s) { return ({ 0: 'danger', 1: 'success', 2: 'warning', 3: 'danger' })[s] || 'info' },
getPayStatusText(s) { return ({ 0: '支付失败', 1: '支付成功', 2: '待校验', 3: '证书校验失败' })[s] || '未知' },
/**
* 将链名称标准化为大写简称
* @param {string} chain - 后端返回的链标识,如 tron/eth/ethereum/bsc/polygon
* @returns {string} 大写显示,如 TRON/ETH/BSC/POLYGON
*/
formatChain(chain) {
const map = { tron: 'Tron (TRC20)', ethereum: 'Ethereum (ERC20)', bsc: 'BSC (BEP20)', polygon: 'Polygon (MATIC)' }
return map[chain] || chain
if (!chain) return ''
const key = String(chain).toLowerCase()
const map = { tron: 'TRON', trx: 'TRON', eth: 'ETH', ethereum: 'ETH', bsc: 'BSC', polygon: 'POLYGON', matic: 'POLYGON' }
return (map[key] || String(chain)).toUpperCase()
},
formatFullTime(time) { if (!time) return ''; try { return new Date(time).toLocaleString('zh-CN') } catch (e) { return String(time) } },
formatTime(time) { return this.formatFullTime(time) },
@@ -363,6 +394,27 @@ export default {
const padded = decPart.padEnd(d, '0')
return `${intPart}.${padded}`
},
/**
* 金额显示保留最多6位小数直接截断不四舍五入不补尾随0始终返回非负字符串
* @param {number|string} value
* @returns {string}
*/
formatDec6(value) {
if (value === null || value === undefined || value === '') return '0'
let s = String(value)
// 展开科学计数法为普通小数,避免 1e-7 之类展示
if (/e/i.test(s)) {
const n = Number(value)
if (!Number.isFinite(n)) return '0'
s = n.toFixed(20).replace(/\.0+$/, '').replace(/(\.\d*?)0+$/, '$1')
}
const m = s.match(/^(-?)(\d+)(?:\.(\d+))?$/)
if (!m) return s
let intPart = m[2]
let decPart = m[3] || ''
if (decPart.length > 6) decPart = decPart.slice(0, 6)
return decPart ? `${intPart}.${decPart}` : intPart
},
handleSizeChange(val) {
console.log(`每页 ${val}`);
this.pagination.pageSize = val;
@@ -376,6 +428,33 @@ export default {
this.loadList();
},
/**
* 复制文本到剪贴板
* @param {string} text - 需要复制的内容
* @param {string} [label] - 语义标签,用于提示文案
*/
async handleCopy(text, label = '内容') {
try {
const value = String(text || '')
if (navigator && navigator.clipboard && navigator.clipboard.writeText) {
await navigator.clipboard.writeText(value)
} else {
const ta = document.createElement('textarea')
ta.value = value
ta.style.position = 'fixed'
ta.style.left = '-9999px'
document.body.appendChild(ta)
ta.focus()
ta.select()
document.execCommand('copy')
document.body.removeChild(ta)
}
this.$message.success(`${label}已复制`)
} catch (e) {
this.$message.error('复制失败,请手动选择复制')
}
},
/**
* Tab 名称转状态码
* @param {string} tabName - 'recharge' | 'withdraw' | 'consume'
@@ -434,6 +513,7 @@ export default {
.expand-item { display: grid; grid-template-columns: 80px 1fr; gap: 6px; align-items: center; }
.label { color: #666; font-size: 13px; text-align: right; }
.value { color: #333; font-size: 13px; text-align: left; }
.value-row { display: inline-flex; align-items: center; gap: 6px; }
.mono { font-family: "Monaco", "Menlo", monospace; }
.mono-ellipsis { font-family: "Monaco", "Menlo", monospace; max-width: 480px; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: #999; padding: 20px 0; }