Blame view

node_modules/uview-ui/components/u-steps/u-steps.vue 4.45 KB
c7add6cf   “wangming”   初始版本开发完毕
1
  <template>
25852764   unknown   s
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  	<view class="">
  		<view
  			class="u-steps"
  			:style="{
  				flexDirection: direction
  			}"
  		>
  			<view class="u-steps__item" 
  				:class="['u-steps__item--' + direction]" 
  				v-for="(item, index) in list" :key="index"
  			>
  				<view
  					class="u-steps__item__num"
  					v-if="mode == 'number'"
  					:style="{
  						backgroundColor: current < index ? 'transparent' : activeColor,
  						borderColor: current < index ? unActiveColor : activeColor
  					}"
  				>
  					<text v-if="current < index" :style="{
  						color: current < index ? unActiveColor : activeColor,
  					}">
  						{{ index + 1 }}
  					</text>
  					<u-icon v-else size="22" color="#ffffff" :name="icon"></u-icon>
  				</view>
  				<view class="u-steps__item__dot" v-if="mode == 'dot'" :style="{ 
  					backgroundColor: index <= current ? activeColor : unActiveColor 
  				}"></view>
  				<text class="u-line-1" :style="{ 
  					color: index <= current ? activeColor : unActiveColor,
  				}" :class="['u-steps__item__text--' + direction]">
  					{{ item.name }}
  				</text>
  				<view class="u-steps__item__line" :class="['u-steps__item__line--' + mode]" v-if="index < list.length - 1">
  					<u-line :direction="direction" length="100%" :hair-line="false" :color="unActiveColor"></u-line>
  				</view>
  			</view>
  		</view>
c7add6cf   “wangming”   初始版本开发完毕
41
42
43
44
  	</view>
  </template>
  
  <script>
25852764   unknown   s
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  /**
   * steps 步骤条
   * @description 该组件一般用于完成一个任务要分几个步骤,标识目前处于第几步的场景。
   * @tutorial https://www.uviewui.com/components/steps.html
   * @property {String} mode 设置模式(默认dot
   * @property {Array} list 数轴条数据,数组。具体见上方示例
   * @property {String} type type主题(默认primary
   * @property {String} direction row-横向,column-竖向(默认row
   * @property {Number String} current 设置当前处于第几步
   * @property {String} active-color 已完成步骤的激活颜色,如设置,type值会失效
   * @property {String} un-active-color 未激活的颜色,用于表示未完成步骤的颜色(默认#606266
   * @example <u-steps :list="numList" active-color="#fa3534"></u-steps>
   */
  export default {
  	name: 'u-steps',
  	props: {
  		// 步骤条的类型,dot|number
  		mode: {
  			type: String,
  			default: 'dot'
c7add6cf   “wangming”   初始版本开发完毕
65
  		},
25852764   unknown   s
66
67
68
69
70
  		// 步骤条的数据
  		list: {
  			type: Array,
  			default() {
  				return [];
c7add6cf   “wangming”   初始版本开发完毕
71
72
  			}
  		},
25852764   unknown   s
73
74
75
76
  		// 主题类型, primary|success|info|warning|error
  		type: {
  			type: String,
  			default: 'primary'
c7add6cf   “wangming”   初始版本开发完毕
77
  		},
25852764   unknown   s
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  		// 当前哪一步是激活的
  		current: {
  			type: [Number, String],
  			default: 0
  		},
  		// 激活步骤的颜色
  		activeColor: {
  			type: String,
  			default: '#2979ff'
  		},
  		// 未激活的颜色
  		unActiveColor: {
  			type: String,
  			default: '#909399'
c7add6cf   “wangming”   初始版本开发完毕
92
  		},
25852764   unknown   s
93
94
95
96
97
98
99
100
101
  		// 自定义图标
  		icon: {
  			type: String,
  			default: 'checkmark'
  		},
  		// step的排列方向,row-横向,column-竖向
  		direction: {
  			type: String,
  			default: 'row'
c7add6cf   “wangming”   初始版本开发完毕
102
  		}
25852764   unknown   s
103
104
105
106
107
  	},
  	data() {
  		return {};
  	},
  };
c7add6cf   “wangming”   初始版本开发完毕
108
109
110
  </script>
  
  <style lang="scss" scoped>
25852764   unknown   s
111
  @import '../../libs/css/style.components.scss';
c7add6cf   “wangming”   初始版本开发完毕
112
  
25852764   unknown   s
113
114
  $u-steps-item-number-width: 44rpx;
  $u-steps-item-dot-width: 20rpx;
c7add6cf   “wangming”   初始版本开发完毕
115
  
25852764   unknown   s
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  .u-steps {
  	@include vue-flex;
  	
  	.u-steps__item {
  		flex: 1;
  		text-align: center;
  		position: relative;
  		min-width: 100rpx;
  		font-size: 26rpx;
  		color: #8799a3;
  		@include vue-flex;
  		justify-content: center;
  		flex-direction: column;
  		align-items: center;
  		
c7add6cf   “wangming”   初始版本开发完毕
131
  		&--row {
25852764   unknown   s
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
  			@include vue-flex;
  			flex-direction: column;
  			
  			.u-steps__item__line {
  				position: absolute;
  				z-index: 0;
  				left: 75%;
  				width: 50%;
  				
  				&--dot {
  					top: calc(#{$u-steps-item-dot-width} / 2);
  				}
  				
  				&--number {
  					top: calc(#{$u-steps-item-number-width} / 2);
  				}
  			}
  		}
  		
  		&--column {
  			@include vue-flex;
c7add6cf   “wangming”   初始版本开发完毕
153
  			flex-direction: row;
25852764   unknown   s
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
  			justify-content: flex-start;
  			min-height: 120rpx;
  			
  			.u-steps__item__line {
  				position: absolute;
  				z-index: 0;
  				height: 50%;
  				top: 75%;
  				
  				&--dot {
  					left: calc(#{$u-steps-item-dot-width} / 2);
  				}
  				
  				&--number {
  					left: calc(#{$u-steps-item-number-width} / 2);
  				}
  			}
  		}
  		
  		&__num {
  			@include vue-flex;
  			align-items: center;
  			justify-content: center;
  			width: $u-steps-item-number-width;
  			height: $u-steps-item-number-width;
  			border: 1px solid #8799a3;
  			border-radius: 50%;
  			overflow: hidden;
  		}
  		
  		&__dot {
  			width: $u-steps-item-dot-width;
  			height: $u-steps-item-dot-width;
  			@include vue-flex;
  			border-radius: 50%;
  		}
  		
  		&__text--row {
  			margin-top: 14rpx;
  		}
  		
  		&__text--column {
  			margin-left: 14rpx;
c7add6cf   “wangming”   初始版本开发完毕
197
198
  		}
  	}
25852764   unknown   s
199
  }
c7add6cf   “wangming”   初始版本开发完毕
200
  </style>