cwg-StepList.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="step">
  3. <view class="step-list">
  4. <view v-for="i in options.length" :key="i" class="step-item" :style="{ width: `${100 / options.length}%` }">
  5. <view class="item-li" :class="[
  6. currentStep <= i ? '' : 'ok',
  7. currentStep === i ? 'active' : '',
  8. ]">
  9. <view :class="[i == 1 ? '' : 'step-dash step-dash1']"></view>
  10. <image v-if="currentStep > i" src="/static/images/success.png" alt="" />
  11. <text v-else></text>
  12. <view :class="[i == options.length ? '' : 'step-dash step-dash2']"></view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="step-ul">
  17. <view v-for="t in options" :key="t" class="step-li" :style="{ width: `${100 / options.length}%` }">
  18. {{ t }}
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script setup lang="ts">
  24. const props = defineProps<{
  25. currentStep: number;
  26. options: Array<string>;
  27. }>();
  28. </script>
  29. <style scoped lang="scss">
  30. @import "@/uni.scss";
  31. .step {
  32. padding-bottom: px2rpx(31);
  33. .step-list {
  34. display: flex;
  35. align-items: center;
  36. .step-item {
  37. display: flex;
  38. justify-content: center;
  39. align-items: center;
  40. .item-li {
  41. display: flex;
  42. width: 100%;
  43. justify-content: center;
  44. align-items: center;
  45. span {
  46. display: inline-block;
  47. width: px2rpx(44);
  48. height: px2rpx(44);
  49. aspect-ratio: 1/1;
  50. border-radius: 114px;
  51. border: 2px solid #beb6b6;
  52. position: relative;
  53. &::after {
  54. position: absolute;
  55. top: 50%;
  56. left: 50%;
  57. transform: translate(-50%, -50%);
  58. content: "";
  59. width: px2rpx(4);
  60. height: px2rpx(4);
  61. border-radius: 50%;
  62. background: #beb6b6;
  63. }
  64. }
  65. em {
  66. height: px2rpx(2);
  67. flex: 1 0 0;
  68. background: transparent;
  69. }
  70. .step-dash {
  71. height: px2rpx(2);
  72. flex: 1 0 0;
  73. background: #beb6b6;
  74. }
  75. img {
  76. display: inline-block;
  77. width: px2rpx(44);
  78. height: px2rpx(44);
  79. }
  80. }
  81. .active {
  82. span {
  83. display: inline-block;
  84. width: px2rpx(44);
  85. height: px2rpx(44);
  86. aspect-ratio: 1/1;
  87. border-radius: 114px;
  88. border: 2px solid #ff4766;
  89. position: relative;
  90. &::after {
  91. position: absolute;
  92. top: 50%;
  93. left: 50%;
  94. transform: translate(-50%, -50%);
  95. content: "";
  96. width: px2rpx(4);
  97. height: px2rpx(4);
  98. border-radius: 50%;
  99. background: #ff4766;
  100. }
  101. }
  102. em {
  103. height: px2rpx(2);
  104. flex: 1 0 0;
  105. background: transparent;
  106. }
  107. .step-dash {
  108. height: px2rpx(2);
  109. flex: 1 0 0;
  110. background: #beb6b6;
  111. }
  112. .step-dash1 {
  113. background: #ff4766;
  114. }
  115. }
  116. .ok {
  117. span {
  118. display: inline-block;
  119. width: px2rpx(44);
  120. height: px2rpx(44);
  121. aspect-ratio: 1/1;
  122. border-radius: 114px;
  123. border: 2px solid #ff4766;
  124. position: relative;
  125. &::after {
  126. position: absolute;
  127. top: 50%;
  128. left: 50%;
  129. transform: translate(-50%, -50%);
  130. content: "";
  131. width: px2rpx(4);
  132. height: px2rpx(4);
  133. border-radius: 50%;
  134. background: #ff4766;
  135. }
  136. }
  137. em {
  138. height: px2rpx(2);
  139. flex: 1 0 0;
  140. background: transparent;
  141. }
  142. .step-dash {
  143. height: px2rpx(2);
  144. flex: 1 0 0;
  145. background: #ff4766;
  146. }
  147. }
  148. }
  149. }
  150. .step-ul {
  151. display: flex;
  152. justify-content: space-between;
  153. align-items: flex-start;
  154. color: #474747;
  155. text-align: center;
  156. font-family: Roboto;
  157. font-size: px2rpx(14);
  158. font-style: normal;
  159. font-weight: 400;
  160. line-height: px2rpx(20);
  161. letter-spacing: px2rpx(0.014);
  162. .step-li {
  163. text-align: center;
  164. }
  165. }
  166. }
  167. </style>