万元计算
This commit is contained in:
parent
1e56c78f12
commit
d6d5f533cf
|
|
@ -146,8 +146,11 @@
|
|||
</view>
|
||||
<view class="grid-item">
|
||||
<text class="label">成交金额</text>
|
||||
<view class="val-box"><text class="val">{{ orderDetail.amount }}</text> <text class="unit">元</text></view>
|
||||
<text class="yesterday">昨日{{ orderDetail.yAmount }}元</text>
|
||||
<view class="val-box">
|
||||
<text class="val">{{ formattedAmount.val }}</text>
|
||||
<text class="unit">{{ formattedAmount.unit }}</text>
|
||||
</view>
|
||||
<text class="yesterday">昨日{{ formattedYAmount.val }}{{ formattedYAmount.unit }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -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(未登录状态),则跳转到登录页
|
||||
|
|
|
|||
Loading…
Reference in New Issue