feat: 添加金额格式化函数,优化收益钱包和账户余额的展示格式

This commit is contained in:
2026-01-19 01:17:07 +07:00
parent 8d0e5fbb29
commit 9bcfe1d8fe

View File

@@ -13,6 +13,14 @@ const { userProfile } = storeToRefs(userStore);
const balanceWallet = await walletStore.getWalletByType("balance"); const balanceWallet = await walletStore.getWalletByType("balance");
const profitWallet = await walletStore.getWalletByType("profit"); const profitWallet = await walletStore.getWalletByType("profit");
function formatAmount(amount: number | string) {
const num = Number(amount);
return num.toLocaleString("zh-CN", {
minimumFractionDigits: 0,
maximumFractionDigits: 2,
});
}
function handleRecharge() { function handleRecharge() {
router.push("/recharge"); router.push("/recharge");
} }
@@ -92,19 +100,19 @@ async function handleLogout() {
<!-- 余额展示 --> <!-- 余额展示 -->
<div class="grid grid-cols-2 gap-4 mb-4"> <div class="grid grid-cols-2 gap-4 mb-4">
<div class="bg-linear-to-br from-[#fff7f0] to-[#ffe8e8] rounded-xl p-4"> <div class="bg-linear-to-br from-[#fff7f0] to-[#ffe8e8] rounded-xl p-4">
<div class="text-xs mb-1"> <div class="text-sm mb-1 font-semibold">
收益钱包 收益钱包
</div> </div>
<div class="text-2xl font-bold text-[#c41e3a] mb-1"> <div class="text-lg font-bold text-[#c41e3a] mb-1 leading-tight">
¥{{ Number(profitWallet?.available).toString() }} ¥{{ formatAmount(profitWallet?.available || 0) }}
</div> </div>
</div> </div>
<div class="bg-linear-to-br from-[#fff7f0] to-[#ffe8e8] rounded-xl p-4"> <div class="bg-linear-to-br from-[#fff7f0] to-[#ffe8e8] rounded-xl p-4">
<div class="text-xs mb-1"> <div class="text-sm mb-1 font-semibold">
账户余额 账户余额
</div> </div>
<div class="text-2xl font-bold text-[#c41e3a] mb-1"> <div class="text-lg font-bold text-[#c41e3a] mb-1 leading-tight">
¥{{ Number(balanceWallet?.available).toString() }} ¥{{ formatAmount(balanceWallet?.available || 0) }}
</div> </div>
</div> </div>
</div> </div>