customProgress.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <div class="progress-container">
  3. <div
  4. :class="['progress-inner', { started: total !== 0 }]"
  5. :data-precrnt="total + '%'"
  6. :style="{ width: total + '%' }"
  7. ></div>
  8. <div
  9. class="progress-round"
  10. style="top: 50%; left: 50%; transform: translate(-50%, -50%)"
  11. data-precrnt="50%"
  12. ></div>
  13. <div
  14. class="progress-round"
  15. style="top: 50%; left: 75%; transform: translate(-75%, -50%)"
  16. data-precrnt="75%"
  17. ></div>
  18. <div
  19. class="progress-round"
  20. style="top: 50%; left: 90%; transform: translate(-90%, -50%)"
  21. data-precrnt="90%"
  22. ></div>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. name: 'customProgress',
  28. props: {
  29. value: {
  30. type: [String, Number],
  31. default: 0,
  32. },
  33. },
  34. computed: {
  35. total: {
  36. get() {
  37. return this.value;
  38. },
  39. },
  40. },
  41. };
  42. </script>
  43. <style lang="less" scoped>
  44. .progress-container {
  45. height: 12px;
  46. background: #fae8d4;
  47. border-radius: 6px;
  48. position: relative;
  49. .progress-inner {
  50. height: 12px;
  51. background: linear-gradient(90deg, #fde08d 0%, #ff0000 100%);
  52. border-radius: 6px;
  53. transition: width 0.5s;
  54. position: relative;
  55. z-index: 1;
  56. &.started::after {
  57. position: absolute;
  58. top: 50%;
  59. right: -13.5px;
  60. transform: translateY(-50%);
  61. display: block;
  62. content: attr(data-precrnt);
  63. font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
  64. font-weight: bold;
  65. font-size: 9px;
  66. color: #ffffff;
  67. line-height: 16px;
  68. text-align: center;
  69. width: 35px;
  70. height: 16px;
  71. background: #ff3535;
  72. border-radius: 9px;
  73. }
  74. }
  75. .progress-round {
  76. width: 8px;
  77. height: 8px;
  78. background: #ff2855;
  79. border-radius: 50%;
  80. position: absolute;
  81. z-index: 0;
  82. &::after {
  83. position: absolute;
  84. top: -30px;
  85. left: 50%;
  86. transform: translateX(-50%);
  87. display: block;
  88. content: attr(data-precrnt);
  89. width: 33px;
  90. height: 19px;
  91. background: #ff3535;
  92. border: 1px solid #fff3cf;
  93. font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
  94. font-weight: bold;
  95. font-size: 9px;
  96. color: #ffffff;
  97. line-height: 12px;
  98. text-align: center;
  99. font-style: normal;
  100. border-radius: 25px;
  101. line-height: 19px;
  102. }
  103. &::before {
  104. position: absolute;
  105. top: -14px;
  106. z-index: 2;
  107. left: 50%;
  108. transform: translateX(-50%);
  109. display: block;
  110. content: '';
  111. left: 50%;
  112. width: 0;
  113. height: 0;
  114. border-left: 3px solid transparent;
  115. border-right: 3px solid transparent;
  116. border-top: 8px solid #ff3535;
  117. }
  118. }
  119. }
  120. </style>