feat: 进度条百分比保留两位小数

This commit is contained in:
2026-06-12 09:51:42 +08:00
parent 6dee56e17f
commit 795de5ff62
3 changed files with 15 additions and 5 deletions
+5 -1
View File
@@ -18,7 +18,7 @@
class="progress"
:style="{ width: `${calcProgressPercent(v)}%` }"
></view>
<view class="progress-percent">{{ Math.round(calcProgressPercent(v)) }}%</view>
<view class="progress-percent">{{ formatProgressPercent(v) }}%</view>
</view>
</view>
<view class="first-time"
@@ -75,6 +75,10 @@
return Math.max(0, Math.min(100, pct));
};
const formatProgressPercent = (item) => {
return calcProgressPercent(item).toFixed(2);
};
const toListRecord = (item) => {
const skuId = item?.skuId ?? '';
const url =
+7 -1
View File
@@ -18,7 +18,7 @@
<view class="record-progress">
<view class="progress-bar">
<view class="progress" :style="{ width: `${item.progress}%` }"></view>
<view class="progress-percent">{{ Math.round(Number(item.progress) || 0) }}%</view>
<view class="progress-percent">{{ formatPercent(item.progress) }}%</view>
</view>
</view>
@@ -78,6 +78,12 @@
return num.toFixed(2);
};
const formatPercent = (value) => {
const num = Number(value);
if (!Number.isFinite(num)) return '0.00';
return num.toFixed(2);
};
const mapOrderToRecord = (order) => {
const items = Array.isArray(order?.items) ? order.items : [];
const firstItem = items[0] || {};