tm-steps.vue 2.6 KB

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