tui-steps.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view class="tui-steps-box" :class="{'tui-steps-column':direction==='column'}">
  3. <view class="tui-step-item" :style="{width:direction==='column'?'100%':spacing}" :class="[direction==='row'?'tui-step-horizontal':'tui-step-vertical']"
  4. v-for="(item,index) in items" :key="index">
  5. <view class="tui-step-item-ico" :style="{width:direction==='column'?'36rpx':'100%'}">
  6. <view class="tui-step-ico" :class="[direction==='column'?'tui-step-column_ico':'tui-step-row_ico']" :style="{width:type==2 || activeSteps===index?'36rpx':'16rpx',height:type==2 || activeSteps===index?'36rpx':'16rpx',backgroundColor:index<=activeSteps?activeColor:(type==2?'#fff':deactiveColor),borderColor:index<=activeSteps?activeColor:deactiveColor}">
  7. <!-- <icon type="success_no_circle" :size="12" color="#fff"></icon> -->
  8. <text v-if="activeSteps!==index" :style="{color:index<=activeSteps?'#fff':''}">{{type==1?'':index+1}}</text>
  9. <tui-icon name="check" :size="16" color="#fff" v-if="activeSteps===index"></tui-icon>
  10. </view>
  11. <view class="tui-step-line" :class="['tui-step-'+direction+'_line']" :style="{backgroundColor:index<=activeSteps-1?activeColor:deactiveColor}"
  12. v-if="index!=items.length-1"></view>
  13. </view>
  14. <view class="tui-step-item-main" :class="['tui-step-'+direction+'_item_main']">
  15. <view class="tui-step-item-title" :style="{color:index<=activeSteps?activeColor:deactiveColor,fontSize:titleSize+'rpx',lineHeight:titleSize+'rpx',fontWeight:bold?'bold':'normal'}">
  16. {{item.title}}
  17. </view>
  18. <view class="tui-step-item-content" :style="{color:index<=activeSteps?activeColor:deactiveColor,fontSize:descSize+'rpx'}">
  19. {{item.desc}}
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. //如果自定义传入图标内容,则需要拆分组件
  27. export default {
  28. name:"tuiSteps",
  29. props: {
  30. // 1-默认步骤 2-数字步骤
  31. type: {
  32. type: Number,
  33. default: 1
  34. },
  35. spacing: {
  36. type: String,
  37. default: '160rpx'
  38. },
  39. // 方向 row column
  40. direction: {
  41. type: String,
  42. default: 'row'
  43. },
  44. // 激活状态成功颜色
  45. activeColor: {
  46. type: String,
  47. default: '#5677fc'
  48. },
  49. // 未激活状态颜色
  50. deactiveColor: {
  51. type: String,
  52. default: '#999999'
  53. },
  54. //title字体大小
  55. titleSize: {
  56. type: Number,
  57. default: 28
  58. },
  59. //title是否粗体
  60. bold: {
  61. type: Boolean,
  62. default: false
  63. },
  64. //desc字体大小
  65. descSize: {
  66. type: Number,
  67. default: 24
  68. },
  69. // 当前步骤
  70. activeSteps: {
  71. type: Number,
  72. default: -1
  73. },
  74. /**
  75. * [{
  76. title: "标题",
  77. desc: "描述"
  78. }]
  79. * */
  80. items: {
  81. type: Array,
  82. default () {
  83. return []
  84. }
  85. }
  86. },
  87. data() {
  88. return {
  89. };
  90. }
  91. }
  92. </script>
  93. <style scoped>
  94. .tui-steps-box {
  95. width: 100%;
  96. display: flex;
  97. justify-content: center;
  98. }
  99. .tui-steps-column {
  100. flex-direction: column;
  101. }
  102. .tui-step-ico {
  103. border-radius: 40rpx;
  104. position: relative;
  105. z-index: 3;
  106. margin: 0 auto;
  107. border-width: 1rpx;
  108. border-style: solid;
  109. display: flex;
  110. align-items: center;
  111. justify-content: center;
  112. }
  113. .tui-step-row_ico {
  114. top: 50%;
  115. transform: translateY(-50%);
  116. }
  117. .tui-step-column_ico {
  118. top: 0;
  119. }
  120. .tui-step-line {
  121. position: absolute;
  122. left: 50%;
  123. top: 20rpx;
  124. width: 100%;
  125. height: 1rpx;
  126. }
  127. .tui-step-row_item_main {
  128. text-align: center
  129. }
  130. .tui-step-item {
  131. font-size: 24rpx;
  132. position: relative;
  133. box-sizing: border-box;
  134. }
  135. .tui-step-item-ico {
  136. height: 36rpx;
  137. line-height: 36rpx;
  138. text-align: center;
  139. }
  140. .tui-step-item-main {
  141. margin-top: 16rpx;
  142. clear: both
  143. }
  144. .tui-step-item-title {
  145. word-break: break-all;
  146. }
  147. .tui-step-item-content {
  148. margin-top: 8rpx;
  149. word-break: break-all;
  150. }
  151. .tui-step-vertical {
  152. width: 100%;
  153. display: flex;
  154. padding-bottom: 60rpx
  155. }
  156. .tui-step-column_item_main {
  157. margin-top: 0;
  158. padding-left: 20rpx;
  159. }
  160. .tui-step-column_line {
  161. position: absolute;
  162. height: 100%;
  163. top: 0;
  164. left: 18rpx;
  165. margin: 0;
  166. width: 1rpx
  167. }
  168. </style>