StepBar.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div class="step">
  3. <div class="step-container">
  4. <div v-for="(item, i) in stepList" :key="i">
  5. <div :class="['step-container-wrapper', { active: i === stepNumber }]">
  6. <span :class="['step-number', { completed: i < stepNumber }]" v-text="i < stepNumber ? '√' : i + 1"></span>
  7. <span class="step-name">{{ stepName(i) }}</span>
  8. <span v-if="i < 2" :class="['step-line', { completed: i < stepNumber }]"></span>
  9. </div>
  10. <div :class="['step-container-name', { active: i === stepNumber }]">
  11. {{ $t(item.name) }}
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'StepBar'
  20. };
  21. </script>
  22. <script setup>
  23. import { inject } from 'vue';
  24. const props = defineProps({
  25. // 步骤条第几步,以 0 开始
  26. stepNumber: {
  27. default: 0,
  28. type: Number
  29. }
  30. });
  31. const stepList = [
  32. {
  33. name: 'Key264'
  34. },
  35. { name: 'Key275' },
  36. { name: 'Key265' }
  37. ];
  38. const $t = inject('$t');
  39. function stepName(num) {
  40. if (num === props.stepNumber) return $t('Key282');
  41. if (num > props.stepNumber) return $t('Key263');
  42. if (num < props.stepNumber) return $t('Key623');
  43. }
  44. </script>
  45. <style lang="scss" scoped>
  46. .step {
  47. position: fixed;
  48. top: $header-h;
  49. left: 0;
  50. z-index: 9;
  51. width: 100%;
  52. height: $step-h;
  53. background-color: #fff;
  54. border-top: 1px solid #d9d9d9;
  55. &-container {
  56. display: flex;
  57. align-items: center;
  58. justify-content: center;
  59. width: $basic-width;
  60. min-width: $basic-width;
  61. height: 100%;
  62. margin: 0 auto;
  63. &-wrapper {
  64. color: #808080;
  65. .step-number {
  66. padding: 9px 14px;
  67. border: 1px solid #808080;
  68. border-radius: 50%;
  69. &.completed {
  70. color: $basic-color;
  71. border-color: $basic-color;
  72. }
  73. }
  74. .step-name {
  75. margin-left: 16px;
  76. }
  77. .step-line {
  78. display: inline-block;
  79. width: 240px;
  80. height: 1px;
  81. margin: 0 24px 0 48px;
  82. vertical-align: middle;
  83. background-color: #d9d9d9;
  84. &.completed {
  85. background-color: $basic-color;
  86. }
  87. }
  88. &.active {
  89. color: #000;
  90. .step-number {
  91. color: #fff;
  92. background-color: $basic-color;
  93. border-color: $basic-color;
  94. }
  95. }
  96. }
  97. &-name {
  98. padding-left: 54px;
  99. margin-top: 18px;
  100. font-size: 14px;
  101. color: #808080;
  102. &.active {
  103. color: #000;
  104. }
  105. }
  106. }
  107. }
  108. </style>