feat: 进度条添加百分比展示

This commit is contained in:
2026-06-05 10:26:19 +08:00
parent d657df4ba3
commit 7fd6871e3c
2 changed files with 31 additions and 0 deletions
+15
View File
@@ -18,6 +18,7 @@
class="progress" class="progress"
:style="{ width: `${calcProgressPercent(v)}%` }" :style="{ width: `${calcProgressPercent(v)}%` }"
></view> ></view>
<view class="progress-percent">{{ Math.round(calcProgressPercent(v)) }}%</view>
</view> </view>
</view> </view>
<view class="first-time" <view class="first-time"
@@ -186,6 +187,7 @@
} }
.progress-bar { .progress-bar {
position: relative;
height: 15rpx; height: 15rpx;
border-radius: 999rpx; border-radius: 999rpx;
background: linear-gradient(90deg, #2c63ff 0%, #ff3b30 100%); background: linear-gradient(90deg, #2c63ff 0%, #ff3b30 100%);
@@ -199,6 +201,19 @@
background: rgba(255, 255, 255, 0.92); background: rgba(255, 255, 255, 0.92);
} }
.progress-percent {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 18rpx;
font-weight: 600;
color: rgba(27, 43, 75, 0.92);
line-height: 1;
pointer-events: none;
text-shadow: 0 0 6rpx rgba(255, 255, 255, 0.9);
}
.stats { .stats {
margin-top: 20rpx; margin-top: 20rpx;
} }
+16
View File
@@ -19,6 +19,7 @@
<view class="record-progress"> <view class="record-progress">
<view class="progress-bar"> <view class="progress-bar">
<view class="progress" :style="{ width: `${item.progress}%` }"></view> <view class="progress" :style="{ width: `${item.progress}%` }"></view>
<view class="progress-percent">{{ Math.round(Number(item.progress) || 0) }}%</view>
</view> </view>
</view> </view>
@@ -180,6 +181,7 @@
width: 100%; width: 100%;
height: 340rpx; height: 340rpx;
display: block; display: block;
transform: 3s ease-in-out;
} }
.record-list { .record-list {
@@ -222,6 +224,7 @@
border-radius: 999rpx; border-radius: 999rpx;
background: linear-gradient(90deg, #2c63ff 0%, #ff3b30 100%); background: linear-gradient(90deg, #2c63ff 0%, #ff3b30 100%);
overflow: hidden; overflow: hidden;
position: relative;
} }
.progress { .progress {
@@ -231,6 +234,19 @@
background: rgba(255, 255, 255, 0.92); background: rgba(255, 255, 255, 0.92);
} }
.progress-percent {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 18rpx;
font-weight: 600;
color: rgba(17, 17, 17, 0.9);
line-height: 1;
pointer-events: none;
text-shadow: 0 0 6rpx rgba(255, 255, 255, 0.9);
}
.record-meta { .record-meta {
margin-top: 18rpx; margin-top: 18rpx;
display: flex; display: flex;