index.vue 5.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <uni-shadow-root class="vant-dist-steps-index"><view :class="'custom-class '+(utils.bem('steps', [direction]))">
  3. <view class="van-step__wrapper">
  4. <view v-for="(item,index) in (steps)" :key="item.index" @click="onClick" :data-index="index" :class="(utils.bem('step', [direction, status(index, active)]))+' van-hairline'" :style="status(index, active) === 'inactive' ? 'color: ' + inactiveColor: ''">
  5. <view class="van-step__title" :style="index === active ? 'color: ' + activeColor : ''">
  6. <view>{{ item.text }}</view>
  7. <view class="desc-class">{{ item.desc }}</view>
  8. </view>
  9. <view class="van-step__circle-container">
  10. <block v-if="index !== active">
  11. <van-icon v-if="item.inactiveIcon || inactiveIcon" :color="status(index, active) === 'inactive' ? inactiveColor: activeColor" :name="item.inactiveIcon || inactiveIcon" custom-class="van-step__icon"></van-icon>
  12. <view v-else class="van-step__circle" :style="'background-color: ' + (index < active ? activeColor : inactiveColor)"></view>
  13. </block>
  14. <van-icon v-else :name="item.activeIcon || activeIcon" :color="activeColor" custom-class="van-step__icon"></van-icon>
  15. </view>
  16. <view v-if="index !== steps.length - 1" class="van-step__line" :style="'background-color: ' + (index < active ? activeColor : inactiveColor)"></view>
  17. </view>
  18. </view>
  19. </view></uni-shadow-root>
  20. </template>
  21. <wxs src="../wxs/utils.wxs" module="utils"></wxs><wxs module="status" src="./index-status.wxs"></wxs>
  22. <script>
  23. import VanIcon from '../icon/index.vue'
  24. global['__wxVueOptions'] = {components:{'van-icon': VanIcon}}
  25. global['__wxRoute'] = 'vant/dist/steps/index'
  26. import { VantComponent } from '../common/component';
  27. import { GREEN, GRAY_DARK } from '../common/color';
  28. VantComponent({
  29. classes: ['desc-class'],
  30. props: {
  31. icon: String,
  32. steps: Array,
  33. active: Number,
  34. direction: {
  35. type: String,
  36. value: 'horizontal',
  37. },
  38. activeColor: {
  39. type: String,
  40. value: GREEN,
  41. },
  42. inactiveColor: {
  43. type: String,
  44. value: GRAY_DARK,
  45. },
  46. activeIcon: {
  47. type: String,
  48. value: 'checked',
  49. },
  50. inactiveIcon: String,
  51. },
  52. methods: {
  53. onClick(event) {
  54. const { index } = event.currentTarget.dataset;
  55. this.$emit('click-step', index);
  56. },
  57. },
  58. });
  59. export default global['__wxComponents']['vant/dist/steps/index']
  60. </script>
  61. <style platform="mp-weixin">
  62. @import '../common/index.css';.van-steps{overflow:hidden;background-color:#fff;background-color:var(--steps-background-color,#fff)}.van-steps--horizontal{padding:10px}.van-steps--horizontal .van-step__wrapper{position:relative;display:flex;overflow:hidden}.van-steps--vertical{padding-left:10px}.van-steps--vertical .van-step__wrapper{padding:0 0 0 20px}.van-step{position:relative;flex:1;font-size:14px;font-size:var(--step-font-size,14px);color:#969799;color:var(--step-text-color,#969799)}.van-step--finish{color:#323233;color:var(--step-finish-text-color,#323233)}.van-step__circle{border-radius:50%;width:5px;width:var(--step-circle-size,5px);height:5px;height:var(--step-circle-size,5px);background-color:#969799;background-color:var(--step-circle-color,#969799)}.van-step--horizontal{padding-bottom:14px}.van-step--horizontal:first-child .van-step__title{transform:none}.van-step--horizontal:first-child .van-step__circle-container{padding:0 8px 0 0;transform:translate3d(0,50%,0)}.van-step--horizontal:last-child{position:absolute;right:0;width:auto}.van-step--horizontal:last-child .van-step__title{text-align:right;transform:none}.van-step--horizontal:last-child .van-step__circle-container{right:0;padding:0 0 0 8px;transform:translate3d(0,50%,0)}.van-step--horizontal .van-step__circle-container{position:absolute;bottom:6px;z-index:1;transform:translate3d(-50%,50%,0);background-color:#fff;background-color:var(--white,#fff);padding:0 8px;padding:0 var(--padding-xs,8px)}.van-step--horizontal .van-step__title{display:inline-block;transform:translate3d(-50%,0,0);font-size:12px;font-size:var(--step-horizontal-title-font-size,12px)}.van-step--horizontal .van-step__line{position:absolute;right:0;bottom:6px;left:0;height:1px;transform:translate3d(0,50%,0);background-color:#ebedf0;background-color:var(--step-line-color,#ebedf0)}.van-step--horizontal.van-step--process{color:#323233;color:var(--step-process-text-color,#323233)}.van-step--horizontal.van-step--process .van-step__icon{display:block;line-height:1;font-size:12px;font-size:var(--step-icon-size,12px)}.van-step--vertical{padding:10px 10px 10px 0;line-height:18px}.van-step--vertical:after{border-bottom-width:1px}.van-step--vertical:last-child:after{border-bottom-width:none}.van-step--vertical:first-child:before{position:absolute;top:0;left:-15px;z-index:1;width:1px;height:20px;content:"";background-color:#fff;background-color:var(--white,#fff)}.van-step--vertical .van-step__circle,.van-step--vertical .van-step__icon,.van-step--vertical .van-step__line{position:absolute;top:19px;left:-14px;z-index:2;transform:translate3d(-50%,-50%,0)}.van-step--vertical .van-step__icon{line-height:1;font-size:12px;font-size:var(--step-icon-size,12px)}.van-step--vertical .van-step__line{z-index:1;width:1px;height:100%;transform:translate3d(-50%,0,0);background-color:#ebedf0;background-color:var(--step-line-color,#ebedf0)}
  63. </style>