Step.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view class="div container">
  3. <view class="div uni-steps">
  4. <view
  5. :class="'uni-steps-' + direction"
  6. class="div uni-steps-items">
  7. <view
  8. v-for="(item, index) in options"
  9. :key="index"
  10. :class="{ 'uni-steps-process': index === active, 'uni-steps-finish': index < active }"
  11. class="div uni-steps-item">
  12. <view
  13. :style="'color: '+(index === active ? activeColor : '')"
  14. class="div uni-steps-item-title-container">
  15. <view class="div uni-steps-item-title">{{ item.title }}</view>
  16. <view
  17. v-if="item.desc"
  18. class="div uni-steps-item-desc">{{ item.desc }}</view>
  19. </view>
  20. <view class="div uni-steps-item-circle-container">
  21. <view
  22. v-if="index !== active"
  23. :style="'background-color:'+ (index < active ? activeColor : '')"
  24. class="div uni-steps-item-circle" />
  25. <view v-else class="div uni-steps-item-check iconfont" :style="'color:'+activeColor">&#xe69d;</view>
  26. </view>
  27. <view
  28. v-if="index !== options.length - 1"
  29. :style="'background-color:'+(index < active ? activeColor : '')"
  30. class="div uni-steps-item-line" />
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. name: 'GoodsStep',
  39. data () {
  40. return {
  41. activeColor: '#f01414',
  42. direction: 'row'
  43. }
  44. },
  45. props: {
  46. options: { type: Array },
  47. active: {
  48. type: Number,
  49. default: 0
  50. }
  51. },
  52. created () {
  53. },
  54. methods: {
  55. }
  56. }
  57. </script>
  58. <style scoped lang="scss">
  59. $uni-border-color-light: #ebedf0; //较浅的灰色,如steps时间轴的颜色
  60. $uni-text-color-grey:#999;
  61. $uni-font-size-base:14px;
  62. $uni-font-size-sm:12px;
  63. $uni-bg-color:#fff;
  64. $uni-border-radius-circle:50%;
  65. $uni-text-color:#333;
  66. .uni-steps {
  67. width: 100%;
  68. box-sizing: border-box;
  69. display: flex;
  70. flex-direction: column;
  71. overflow: hidden;
  72. position: relative;
  73. &-items {
  74. position: relative;
  75. display: flex;
  76. flex-direction: row;
  77. margin: 10px;
  78. box-sizing: border-box;
  79. overflow: hidden;
  80. &.uni-steps-column {
  81. margin: 10px 0;
  82. padding-left: 31px;
  83. flex-direction: column;
  84. .uni-steps-item {
  85. &:after {
  86. content: ' ';
  87. position: absolute;
  88. height: 1px;
  89. width: 100%;
  90. bottom: 9px;
  91. left: 0;
  92. background-color: $uni-border-color-light;
  93. transform: scaleY(0.5);
  94. }
  95. &:last-child {
  96. position: relative;
  97. &:after {
  98. height: 0px;
  99. }
  100. .uni-steps-item-title-container {
  101. text-align: left;
  102. }
  103. .uni-steps-item-circle-container {
  104. left: -17px;
  105. right: auto;
  106. }
  107. }
  108. &-title-container {
  109. transform: none;
  110. display: block;
  111. line-height: 36px;
  112. }
  113. &-title {
  114. text-overflow: ellipsis;
  115. white-space: nowrap;
  116. overflow: hidden;
  117. }
  118. &-desc {
  119. white-space: normal;
  120. display: -webkit-box;
  121. -webkit-box-orient: vertical;
  122. -webkit-line-clamp: 2;
  123. overflow: hidden;
  124. }
  125. &-circle-container {
  126. left: -17px;
  127. top: -1px;
  128. bottom: auto;
  129. padding: 8px 0px;
  130. z-index: 1;
  131. }
  132. &-line {
  133. height: 100%;
  134. width: 1px;
  135. left: -15px;
  136. top: -1px;
  137. bottom: auto;
  138. }
  139. &.uni-steps-process {
  140. .uni-steps-item-circle-container {
  141. bottom: auto;
  142. left: -21px;
  143. }
  144. }
  145. }
  146. }
  147. }
  148. &-item {
  149. flex: 1;
  150. position: relative;
  151. padding-bottom: 18px;
  152. &-title-container {
  153. text-align: left;
  154. margin-left: 3px;
  155. display: inline-block;
  156. transform: translateX(-50%);
  157. color: $uni-text-color-grey;
  158. }
  159. &-title {
  160. font-size: $uni-font-size-base;
  161. }
  162. &-desc {
  163. font-size: $uni-font-size-sm;
  164. }
  165. &:first-child {
  166. .uni-steps-item-title-container {
  167. transform: none;
  168. margin-left: 0;
  169. }
  170. }
  171. &:last-child {
  172. position: absolute;
  173. right: 0;
  174. .uni-steps-item-title-container {
  175. transform: none;
  176. text-align: right;
  177. }
  178. .uni-steps-item-circle-container {
  179. left: auto;
  180. right: -8px;
  181. }
  182. }
  183. &-circle-container {
  184. position: absolute;
  185. bottom: 8px;
  186. left: -8px;
  187. padding: 0 8px;
  188. background-color: $uni-bg-color;
  189. z-index: 1;
  190. }
  191. &-circle {
  192. width: 5px;
  193. height: 5px;
  194. background-color: $uni-text-color-grey;
  195. border-radius: $uni-border-radius-circle;
  196. }
  197. &-line {
  198. background-color: $uni-border-color-light;
  199. position: absolute;
  200. bottom: 10px;
  201. left: 0;
  202. width: 100%;
  203. height: 1px;
  204. }
  205. &.uni-steps-finish {
  206. .uni-steps-item-title-container {
  207. color: $uni-text-color;
  208. }
  209. }
  210. &.uni-steps-process {
  211. .uni-steps-item-circle-container {
  212. bottom: 3px;
  213. height: 14px;
  214. line-height: 14px;
  215. display: flex;
  216. }
  217. }
  218. }
  219. }
  220. .uni-steps-item-check{font-size:$subFontSize}
  221. </style>