StepProgress.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="step-progress">
  3. <div class="step-wrapper">
  4. <div v-for="(step, index) in steps" :key="index" class="step">
  5. <!-- 点 -->
  6. <div class="circle" :class="{ active: index < activeStep }"></div>
  7. <!-- 线(最后一个点没有线) -->
  8. <div
  9. v-if="index !== steps.length - 1"
  10. class="line"
  11. :class="{ active: index < activeStep }"
  12. ></div>
  13. <!-- 文本 -->
  14. <div class="label" :class="{ active: index < activeStep }">{{ step }}</div>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script setup lang="ts">
  20. defineProps<{
  21. /** 当前激活的步骤 (1~N) */
  22. activeStep: number
  23. }>()
  24. /** 默认四步 */
  25. const steps = ['确认开票信息', '开票认证', '完成缴税', '提交开票申请']
  26. </script>
  27. <style scoped lang="scss">
  28. .step-progress {
  29. width: 100%;
  30. box-sizing: border-box;
  31. padding: 4vw 3vw 2vw;
  32. border-radius: 2vw;
  33. .step-wrapper {
  34. display: flex;
  35. align-items: flex-start;
  36. justify-content: space-between;
  37. position: relative;
  38. }
  39. .step {
  40. flex: 1;
  41. display: flex;
  42. flex-direction: column;
  43. align-items: center;
  44. position: relative;
  45. text-align: center;
  46. /* 点 */
  47. .circle {
  48. width: 4vw;
  49. height: 4vw;
  50. border-radius: 50%;
  51. background: #dcdcdc;
  52. z-index: 1;
  53. transition: background 0.3s ease;
  54. &.active {
  55. background: #ff7a00;
  56. }
  57. }
  58. /* 线:在点右侧 */
  59. .line {
  60. position: absolute;
  61. top: 2vw; /* 与圆心对齐 */
  62. left: 50%;
  63. width: 100%;
  64. height: 0.6vw;
  65. background: #e0e0e0;
  66. border-radius: 1vw;
  67. z-index: 0;
  68. transition: background 0.3s ease;
  69. &.active {
  70. background: linear-gradient(90deg, #ff7a00, #ffa94d);
  71. }
  72. }
  73. /* 文本 */
  74. .label {
  75. margin-top: 1.6vw;
  76. font-size: 3.2vw;
  77. color: #aaa;
  78. white-space: nowrap;
  79. transition: color 0.3s ease;
  80. &.active {
  81. color: #ff7a00;
  82. font-weight: 600;
  83. }
  84. }
  85. }
  86. /* 最后一个点右边不画线 */
  87. .step:last-child .line {
  88. display: none;
  89. }
  90. }
  91. </style>