feat: 我的店铺进度条
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
<view class="progress-bar">
|
||||
<view
|
||||
class="progress"
|
||||
:style="{ width: `${Math.max(0, Math.min(100, Number(v.progress) || 0))}%` }"
|
||||
:style="{ width: `${calcProgressPercent(v)}%` }"
|
||||
></view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -55,6 +55,10 @@
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
totalEarnings: {
|
||||
type: [Number, String],
|
||||
default: 0,
|
||||
},
|
||||
source: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
@@ -65,6 +69,15 @@
|
||||
|
||||
const renderList = computed(() => (Array.isArray(props.list) ? props.list : []));
|
||||
|
||||
const calcProgressPercent = (item) => {
|
||||
const total = Number(props.totalEarnings) || 0;
|
||||
const cur = Number(item?.earnings) || 0;
|
||||
if (total <= 0 || cur <= 0) return 0;
|
||||
const pct = (cur / total) * 100;
|
||||
if (!Number.isFinite(pct)) return 0;
|
||||
return Math.max(0, Math.min(100, pct));
|
||||
};
|
||||
|
||||
const toListRecord = (item) => {
|
||||
const skuId = item?.skuId ?? '';
|
||||
const url =
|
||||
|
||||
Reference in New Issue
Block a user