QuotaProgressBar.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <view class="quota-progress-bar">
  3. <view class="quota-label">
  4. <text class="quota-name">{{ name }}</text>
  5. <text class="quota-count">{{ remaining }} / {{ total }}</text>
  6. </view>
  7. <view class="quota-track">
  8. <view class="quota-fill" :style="{ width: percent + '%' }"></view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'QuotaProgressBar',
  15. props: {
  16. remaining: { type: Number, default: 0 },
  17. total: { type: Number, default: 0 },
  18. name: { type: String, default: '' }
  19. },
  20. computed: {
  21. percent() {
  22. if (!this.total) return 0
  23. return Math.round((this.remaining / this.total) * 100)
  24. }
  25. }
  26. }
  27. </script>
  28. <style scoped>
  29. .quota-progress-bar {
  30. margin-bottom: 16rpx;
  31. }
  32. .quota-label {
  33. display: flex;
  34. justify-content: space-between;
  35. font-size: 24rpx;
  36. color: #666;
  37. margin-bottom: 8rpx;
  38. }
  39. .quota-track {
  40. height: 12rpx;
  41. background: #f0f0f0;
  42. border-radius: 6rpx;
  43. overflow: hidden;
  44. }
  45. .quota-fill {
  46. height: 100%;
  47. background: #F97316;
  48. border-radius: 6rpx;
  49. transition: width 0.3s;
  50. }
  51. </style>