tm-steps.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="tm-steps">
  3. <view class="tm-steps-top">
  4. <view class="item" v-for="(item, index) in options"
  5. :style="{flex: index === 0 ? 'none' : 1}"
  6. :class="{active: active === index, over: active > index}"
  7. :key="index">
  8. <view class="line" v-if="index !== 0"></view>
  9. <view class="content">
  10. <view class="content-top">
  11. <image v-if="active > index"
  12. src="../../static/steps-over.png"></image>
  13. <view v-else>{{ index + 1 }}</view>
  14. </view>
  15. <text>{{ item.title }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. <scroll-view scroll-y="true" class="component-wrap">
  20. <component v-bind:is="options[active].component"></component>
  21. </scroll-view>
  22. </view>
  23. </template>
  24. <script>
  25. /**
  26. * 步骤条
  27. * 参数说明:
  28. * options:{
  29. * title: '显示的文字',
  30. * component: '内容组件(传组件对象或者全局注册过的组件名)'
  31. }
  32. * active:当前进度,从0开始
  33. */
  34. export default {
  35. props: ['options', 'active']
  36. }
  37. </script>
  38. <style lang="less">
  39. .tm-steps {
  40. display: flex;
  41. flex-direction: column;
  42. width: 100%;
  43. height: 100%;
  44. .tm-steps-top {
  45. display: flex;
  46. flex-direction: row;
  47. justify-content: space-between;
  48. align-items: center;
  49. padding: 37.5rpx 25rpx 50rpx 25rpx;
  50. .item {
  51. display: flex;
  52. flex: 1;
  53. flex-direction: row;
  54. justify-content: flex-end;
  55. font-size: 17.5rpx;
  56. line-height: 26.25rpx;
  57. color: #B8BFCC;
  58. .content {
  59. display: flex;
  60. flex-direction: column;
  61. justify-content: center;
  62. align-items: center;
  63. margin: 0 18.75rpx;
  64. min-width: 37.5rpx;
  65. text {
  66. white-space: nowrap;
  67. }
  68. .content-top {
  69. margin-bottom: 10rpx;
  70. width: 37.5rpx;
  71. height: 37.5rpx;
  72. line-height: 37.5rpx;
  73. text-align: center;
  74. view {
  75. border-radius: 50%;
  76. color: #fff;
  77. background-color: #B8BECC;
  78. }
  79. image {
  80. width: 100%;
  81. height: 100%;
  82. }
  83. }
  84. }
  85. .line {
  86. margin-top: 18.12rpx;
  87. height: 1.25rpx;
  88. width: 100%;
  89. background-color: #B8BECC;
  90. }
  91. &.active {
  92. color: #3377FF;
  93. .content .content-top view {
  94. background-color: #3377FF;
  95. }
  96. .line {
  97. background-color: #3377FF;
  98. }
  99. }
  100. &.over {
  101. color: #292C33;
  102. .line {
  103. background-color: #3377FF;
  104. }
  105. }
  106. }
  107. }
  108. .component-wrap {
  109. width: 100%;
  110. height: calc(100% - 160rpx);
  111. }
  112. }
  113. </style>