index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <view>
  3. <sjs src="../wxs/utils.sjs" module="utils" />
  4. <view :class="'custom-class ' + utils.bem('steps', [direction])">
  5. <view class="van-step__wrapper">
  6. <view :wx:for="steps" wx:key="index" :class="utils.bem('step', [direction, status(index, active)]) + ' van-hairline'">
  7. <view class="van-step__title" :style="index === active ? 'color: ' + activeColor : ''">
  8. <view>{{ item.text }}</view>
  9. <view>{{ item.desc }}</view>
  10. </view>
  11. <view class="van-step__circle-container">
  12. <block :wx:if="index !== active">
  13. <van-icon :wx:if="inactiveIcon" color="#969799" :name="inactiveIcon" custom-class="van-step__icon" />
  14. <view wx:else class="van-step__circle" :style="index < active ? 'background-color: ' + activeColor : ''" />
  15. </block>
  16. <van-icon wx:else :name="activeIcon" :color="activeColor" custom-class="van-step__icon" />
  17. </view>
  18. <view :wx:if="index !== steps.length - 1" class="van-step__line" :style="index < active ? 'background-color: ' + activeColor : ''" />
  19. </view>
  20. </view>
  21. </view>
  22. <sjs module="status">
  23. function get(index, active) { if (index < active) { return 'finish'; } else if (index === active) { return 'process'; } return ''; } module.exports = get;
  24. </sjs>
  25. </view>
  26. </template>
  27. <script>
  28. import { VantComponent } from '../common/component';
  29. import { GREEN } from '../common/color';
  30. export default {
  31. data() {
  32. return {};
  33. },
  34. props: {
  35. icon: String,
  36. steps: Array,
  37. active: Number,
  38. direction: {
  39. type: String,
  40. default: 'horizontal'
  41. },
  42. activeColor: {
  43. type: String,
  44. default: GREEN
  45. },
  46. activeIcon: {
  47. type: String,
  48. default: 'checked'
  49. },
  50. inactiveIcon: String
  51. }
  52. };
  53. </script>
  54. <style>
  55. @import '../common/index.ttss';
  56. .van-steps {
  57. overflow: hidden;
  58. background-color: #fff;
  59. background-color: var(--steps-background-color, #fff);
  60. }
  61. .van-steps--horizontal {
  62. padding: 10px;
  63. }
  64. .van-steps--horizontal .van-step__wrapper {
  65. position: relative;
  66. display: -webkit-flex;
  67. display: flex;
  68. overflow: hidden;
  69. }
  70. .van-steps--vertical {
  71. padding-left: 10px;
  72. }
  73. .van-steps--vertical .van-step__wrapper {
  74. padding: 0 0 0 20px;
  75. }
  76. .van-step {
  77. position: relative;
  78. -webkit-flex: 1;
  79. flex: 1;
  80. font-size: 14px;
  81. font-size: var(--step-font-size, 14px);
  82. color: #969799;
  83. color: var(--step-text-color, #969799);
  84. }
  85. .van-step--finish {
  86. color: #323233;
  87. color: var(--step-finish-text-color, #323233);
  88. }
  89. .van-step__circle {
  90. border-radius: 50%;
  91. width: 5px;
  92. width: var(--step-circle-size, 5px);
  93. height: 5px;
  94. height: var(--step-circle-size, 5px);
  95. background-color: #969799;
  96. background-color: var(--step-circle-color, #969799);
  97. }
  98. .van-step--horizontal {
  99. padding-bottom: 14px;
  100. }
  101. .van-step--horizontal:first-child .van-step__title {
  102. -webkit-transform: none;
  103. transform: none;
  104. }
  105. .van-step--horizontal:first-child .van-step__circle-container {
  106. padding: 0 8px 0 0;
  107. -webkit-transform: translate3d(0, 50%, 0);
  108. transform: translate3d(0, 50%, 0);
  109. }
  110. .van-step--horizontal:last-child {
  111. position: absolute;
  112. right: 0;
  113. width: auto;
  114. }
  115. .van-step--horizontal:last-child .van-step__title {
  116. text-align: right;
  117. -webkit-transform: none;
  118. transform: none;
  119. }
  120. .van-step--horizontal:last-child .van-step__circle-container {
  121. right: 0;
  122. padding: 0 0 0 8px;
  123. -webkit-transform: translate3d(0, 50%, 0);
  124. transform: translate3d(0, 50%, 0);
  125. }
  126. .van-step--horizontal .van-step__circle-container {
  127. position: absolute;
  128. bottom: 6px;
  129. z-index: 1;
  130. -webkit-transform: translate3d(-50%, 50%, 0);
  131. transform: translate3d(-50%, 50%, 0);
  132. background-color: #fff;
  133. background-color: var(--white, #fff);
  134. padding: 0 8px;
  135. padding: 0 var(--padding-xs, 8px);
  136. }
  137. .van-step--horizontal .van-step__title {
  138. display: inline-block;
  139. -webkit-transform: translate3d(-50%, 0, 0);
  140. transform: translate3d(-50%, 0, 0);
  141. font-size: 12px;
  142. font-size: var(--step-horizontal-title-font-size, 12px);
  143. }
  144. .van-step--horizontal .van-step__line {
  145. position: absolute;
  146. right: 0;
  147. bottom: 6px;
  148. left: 0;
  149. height: 1px;
  150. -webkit-transform: translate3d(0, 50%, 0);
  151. transform: translate3d(0, 50%, 0);
  152. background-color: #ebedf0;
  153. background-color: var(--step-line-color, #ebedf0);
  154. }
  155. .van-step--horizontal.van-step--process {
  156. color: #323233;
  157. color: var(--step-process-text-color, #323233);
  158. }
  159. .van-step--horizontal.van-step--process .van-step__icon {
  160. display: block;
  161. line-height: 1;
  162. font-size: 12px;
  163. font-size: var(--step-icon-size, 12px);
  164. }
  165. .van-step--vertical {
  166. padding: 10px 10px 10px 0;
  167. line-height: 18px;
  168. }
  169. .van-step--vertical:after {
  170. border-bottom-width: 1px;
  171. }
  172. .van-step--vertical:last-child:after {
  173. border-bottom-width: none;
  174. }
  175. .van-step--vertical:first-child:before {
  176. position: absolute;
  177. top: 0;
  178. left: -15px;
  179. z-index: 1;
  180. width: 1px;
  181. height: 20px;
  182. content: '';
  183. background-color: #fff;
  184. background-color: var(--white, #fff);
  185. }
  186. .van-step--vertical .van-step__circle,
  187. .van-step--vertical .van-step__icon,
  188. .van-step--vertical .van-step__line {
  189. position: absolute;
  190. top: 19px;
  191. left: -14px;
  192. z-index: 2;
  193. -webkit-transform: translate3d(-50%, -50%, 0);
  194. transform: translate3d(-50%, -50%, 0);
  195. }
  196. .van-step--vertical .van-step__icon {
  197. line-height: 1;
  198. font-size: 12px;
  199. font-size: var(--step-icon-size, 12px);
  200. }
  201. .van-step--vertical .van-step__line {
  202. z-index: 1;
  203. width: 1px;
  204. height: 100%;
  205. -webkit-transform: translate3d(-50%, 0, 0);
  206. transform: translate3d(-50%, 0, 0);
  207. background-color: #ebedf0;
  208. background-color: var(--step-line-color, #ebedf0);
  209. }
  210. </style>