<template>
<view class>
<view class="u-steps">
<view class="u-steps-item" v-for="(item,index) in list" :key="index">
<view class="u-steps-item-num" v-if="mode == 'number' && current < index">{{index+1}}</view>
<view
class="u-steps-item-dot"
v-if="mode == 'dot'"
:style="{backgroundColor: index <= current ? activeColor : unActiveColor}"
></view>
<u-icon
size
class="u-steps-item-checked"
:style="{backgroundColor: index <= current ? activeColor : unActiveColor}"
v-if="mode == 'number' && current >= index"
:name="icon"
></u-icon>
<text :style="{color: index <= current ? activeColor : unActiveColor}">{{item.name}}</text>
<view
class="u-steps-item-line"
:style="{backgroundColor: index <= current ? activeColor : unActiveColor, top: mode == 'dot' ? '12rpx' : '18rpx'}"
></view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'u-steps',
props: {
mode: {
type: String,
default: 'dot'
},
list: {
type: Array,
default() {
return []
}
},
type: {
type: String,
default: 'primary'
},
current: {
type: [Number, String],
default: 0
},
activeColor: {
type: String,
default: '#2979ff'
},
unActiveColor: {
type: String,
default: '#606266'
},
icon: {
type: String,
default: 'checkmark'
}
},
data() {
return {}
}
}
</script>
<style lang="scss" scoped>
@import '../../libs/css/style.components.scss';
.u-steps {
display: flex;
}
.u-steps-item {
flex: 1;
text-align: center;
position: relative;
min-width: 50rpx;
font-size: 10rpx;
color: #8799a3;
}
.u-steps-item .u-steps-item-line {
content: '';
position: absolute;
height: 2rpx;
width: calc(100% - 30rpx);
left: calc(0rpx - (100% - 30rpx) / 2);
top: 36rpx;
z-index: 0;
}
.u-steps-item:first-child .u-steps-item-line {
display: none;
}
.u-steps-item-num {
display: flex;
align-items: center;
justify-content: center;
width: 22rpx;
height: 22rpx;
border: 1px solid #8799a3;
border-radius: 50%;
margin: 7rpx auto;
overflow: hidden;
}
.u-steps-item-dot {
width: 10rpx;
height: 10rpx;
display: flex;
border-radius: 50%;
margin: 7rpx auto;
}
.u-steps-item-checked {
display: flex;
align-items: center;
justify-content: center;
width: 22rpx;
color: #fff !important;
height: 22rpx;
border-radius: 50%;
margin: 7rpx auto;
overflow: hidden;
}
</style>