From d6d5f533cf06580131262a29896346b6245a1d8d Mon Sep 17 00:00:00 2001 From: BAKEYi <16298417+bakeyi@user.noreply.gitee.com> Date: Wed, 3 Jun 2026 17:54:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=87=E5=85=83=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/home/home.vue | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/pages/home/home.vue b/pages/home/home.vue index 3f0e943..3ec9aa2 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -146,8 +146,11 @@ 成交金额 - {{ orderDetail.amount }} - 昨日{{ orderDetail.yAmount }}元 + + {{ formattedAmount.val }} + {{ formattedAmount.unit }} + + 昨日{{ formattedYAmount.val }}{{ formattedYAmount.unit }} @@ -249,6 +252,14 @@ export default { }; }, computed: { + // 格式化今日成交金额 + formattedAmount() { + return this.formatMoney(this.orderDetail.amount); + }, + // 格式化昨日成交金额 + formattedYAmount() { + return this.formatMoney(this.orderDetail.yAmount); + }, // 依靠后端实际返回的资料详情来判断是否真的提交过申请,而不是无脑信 id_type: -1 isUnderReview() { if (!this.isLogin) return false; @@ -364,6 +375,19 @@ export default { } }, methods: { + // 金额转换万单位处理 + formatMoney(amount) { + let num = parseFloat(amount); + if (isNaN(num)) return { val: '0', unit: '元' }; + + if (num >= 10000) { + // 达到一万及以上,除以10000,最多保留两位小数(parseFloat会自动去掉末尾的0) + let val = parseFloat((num / 10000).toFixed(2)); + return { val: val, unit: '万元' }; + } + // 小于一万,原样返回,单位为元 + return { val: num, unit: '元' }; + }, // 处理登录跳转 handleLoginRedirect() { // 如果 isLogin 为 false(未登录状态),则跳转到登录页