推拿小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
1.6 KiB

  1. <template>
  2. <view class="progress__view">
  3. <view class="mark" :style="{ marginLeft: `${percentage}%` }">{{ current }}</view>
  4. <view class="progress">
  5. <view class="progress-active" :style="{ width: `${percentage}%` }">
  6. <view class="progress-active-dot"></view>
  7. </view>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. props: {
  14. current: {
  15. type: Number,
  16. default: 0,
  17. },
  18. total: {
  19. type: Number,
  20. default: 100,
  21. }
  22. },
  23. computed: {
  24. percentage() {
  25. return Math.floor(this.current / this.total * 100)
  26. }
  27. }
  28. }
  29. </script>
  30. <style lang="scss" scoped>
  31. $progress-height: 14rpx;
  32. .progress__view {
  33. width: 100%;
  34. font-size: 0;
  35. }
  36. .mark {
  37. background-color: $uni-color-light;
  38. color: $uni-text-color-inverse;
  39. font-size: 18rpx;
  40. padding: 0 10rpx;
  41. display: inline-block;
  42. border-radius: 5rpx;
  43. transform: translateX(calc(-50% - #{$progress-height} / 2 ));
  44. position: relative;
  45. margin-bottom: 8rpx;
  46. &:after {
  47. content: ' ';
  48. position: absolute;
  49. top: 100%;
  50. left: 50%;
  51. transform: translateX(-50%);
  52. width: 0;
  53. height: 0;
  54. border: 4rpx solid transparent;
  55. border-top-color: $uni-color-light;
  56. }
  57. }
  58. .progress {
  59. width: 100%;
  60. height: $progress-height;
  61. border-radius: 7rpx;
  62. background-color: #CEE2AA;
  63. &-active {
  64. background-color: $uni-color-light;
  65. height: 100%;
  66. border-radius: 7rpx;
  67. position: relative;
  68. &-dot {
  69. position: absolute;
  70. top: 0;
  71. right: 0;
  72. width: $progress-height;
  73. height: $progress-height;
  74. background-color: $uni-fg-color;
  75. border-radius: 50%;
  76. }
  77. }
  78. }
  79. </style>