customProgress.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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', { 'progress-round-white': +total >= 50 }]"
  10. style="top: 50%; left: 50%; transform: translate(-50%, -50%)"
  11. data-precrnt="50%"
  12. ></div>
  13. <div
  14. :class="['progress-round', { 'progress-round-white': +total >= 75 }]"
  15. style="top: 50%; left: 75%; transform: translate(-75%, -50%)"
  16. data-precrnt="75%"
  17. ></div>
  18. <div
  19. :class="['progress-round', { 'progress-round-white': +total >= 90 }]"
  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. z-index: 0;
  50. .progress-inner {
  51. height: 12px;
  52. background: linear-gradient(90deg, #fde08d 0%, #ff0000 100%);
  53. border-radius: 6px;
  54. transition: width 0.5s;
  55. position: relative;
  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. z-index: 1;
  74. }
  75. }
  76. .progress-round {
  77. width: 8px;
  78. height: 8px;
  79. background: #ff2855;
  80. border-radius: 50%;
  81. position: absolute;
  82. z-index: 0;
  83. &.progress-round-white{
  84. background: #FFFFFF;
  85. }
  86. &::after {
  87. position: absolute;
  88. top: 13px;
  89. left: -50%;
  90. // transform: translateX(-50%);
  91. display: block;
  92. content: attr(data-precrnt);
  93. font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
  94. font-weight: 400;
  95. font-size: 10px;
  96. color: #000000;
  97. line-height: 12px;
  98. font-style: normal;
  99. // width: 33px;
  100. // height: 19px;
  101. // background: #ff3535;
  102. // border: 1px solid #fff3cf;
  103. // font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
  104. // font-weight: bold;
  105. // font-size: 9px;
  106. // color: #ffffff;
  107. // line-height: 12px;
  108. // text-align: center;
  109. // font-style: normal;
  110. // border-radius: 25px;
  111. // line-height: 19px;
  112. }
  113. &::before {
  114. // position: absolute;
  115. // top: -14px;
  116. // z-index: 2;
  117. // left: 50%;
  118. // transform: translateX(-50%);
  119. // display: block;
  120. // content: '';
  121. // left: 50%;
  122. // width: 0;
  123. // height: 0;
  124. // border-left: 3px solid transparent;
  125. // border-right: 3px solid transparent;
  126. // border-top: 8px solid #ff3535;
  127. }
  128. }
  129. }
  130. </style>