Blame view

node_modules/uview-ui/components/u-line-progress/u-line-progress.vue 3.52 KB
c7add6cf   “wangming”   初始版本开发完毕
1
  <template>
25852764   unknown   s
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  	<view class="u-progress" :style="{
  		borderRadius: round ? '100rpx' : 0,
  		height: height + 'rpx',
  		backgroundColor: inactiveColor
  	}">
  		<view :class="[
  			type ? `u-type-${type}-bg` : '',
  			striped ? 'u-striped' : '',
  			striped && stripedActive ? 'u-striped-active' : ''
  		]" class="u-active" :style="[progressStyle]">
  			<slot v-if="$slots.default || $slots.$default" />
  			<block v-else-if="showPercent">
  				{{percent + '%'}}
  			</block>
c7add6cf   “wangming”   初始版本开发完毕
16
17
18
19
20
  		</view>
  	</view>
  </template>
  
  <script>
c7add6cf   “wangming”   初始版本开发完毕
21
22
23
24
  	/**
  	 * lineProgress 线型进度条
  	 * @description 展示操作或任务的当前进度,比如上传文件,是一个线形的进度条。
  	 * @tutorial https://www.uviewui.com/components/lineProgress.html
25852764   unknown   s
25
26
27
28
29
30
31
32
33
  	 * @property {String Number} percent 进度条百分比值,为数值类型,0-100
  	 * @property {Boolean} round 进度条两端是否为半圆(默认true
  	 * @property {String} type 如设置,active-color值将会失效
  	 * @property {String} active-color 进度条激活部分的颜色(默认#19be6b
  	 * @property {String} inactive-color 进度条的底色(默认#ececec
  	 * @property {Boolean} show-percent 是否在进度条内部显示当前的百分比值数值(默认true
  	 * @property {String Number} height 进度条的高度,单位rpx(默认28
  	 * @property {Boolean} striped 是否显示进度条激活部分的条纹(默认false
  	 * @property {Boolean} striped-active 条纹是否具有动态效果(默认false
c7add6cf   “wangming”   初始版本开发完毕
34
35
36
37
  	 * @example <u-line-progress :percent="70" :show-percent="true"></u-line-progress>
  	 */
  	export default {
  		name: "u-line-progress",
25852764   unknown   s
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  		props: {
  			// 两端是否显示半圆形
  			round: {
  				type: Boolean,
  				default: true
  			},
  			// 主题颜色
  			type: {
  				type: String,
  				default: ''
  			},
  			// 激活部分的颜色
  			activeColor: {
  				type: String,
  				default: '#19be6b'
  			},
  			inactiveColor: {
  				type: String,
  				default: '#ececec'
  			},
  			// 进度百分比,数值
  			percent: {
  				type: Number,
  				default: 0
  			},
  			// 是否在进度条内部显示百分比的值
  			showPercent: {
  				type: Boolean,
  				default: true
  			},
  			// 进度条的高度,单位rpx
  			height: {
  				type: [Number, String],
  				default: 28
  			},
  			// 是否显示条纹
  			striped: {
  				type: Boolean,
  				default: false
  			},
  			// 条纹是否显示活动状态
  			stripedActive: {
  				type: Boolean,
  				default: false
c7add6cf   “wangming”   初始版本开发完毕
82
83
  			}
  		},
25852764   unknown   s
84
85
86
  		data() {
  			return {
  
c7add6cf   “wangming”   初始版本开发完毕
87
88
89
  			}
  		},
  		computed: {
25852764   unknown   s
90
91
92
93
94
  			progressStyle() {
  				let style = {};
  				style.width = this.percent + '%';
  				if(this.activeColor) style.backgroundColor = this.activeColor;
  				return style;
c7add6cf   “wangming”   初始版本开发完毕
95
96
  			}
  		},
c7add6cf   “wangming”   初始版本开发完毕
97
  		methods: {
c7add6cf   “wangming”   初始版本开发完毕
98
  
c7add6cf   “wangming”   初始版本开发完毕
99
100
101
102
103
  		}
  	}
  </script>
  
  <style lang="scss" scoped>
25852764   unknown   s
104
105
106
  	@import "../../libs/css/style.components.scss";
  	
  	.u-progress {
c7add6cf   “wangming”   初始版本开发完毕
107
  		overflow: hidden;
25852764   unknown   s
108
109
110
111
112
113
114
115
  		height: 15px;
  		/* #ifndef APP-NVUE */
  		display: inline-flex;
  		/* #endif */
  		align-items: center;
  		width: 100%;
  		border-radius: 100rpx;
  	}
c7add6cf   “wangming”   初始版本开发完毕
116
  
25852764   unknown   s
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
  	.u-active {
  		width: 0;
  		height: 100%;
  		align-items: center;
  		@include vue-flex;
  		justify-items: flex-end;
  		justify-content: space-around;
  		font-size: 20rpx;
  		color: #ffffff;
  		transition: all 0.4s ease;
  	}
  
  	.u-striped {
  		background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
  		background-size: 39px 39px;
  	}
  
  	.u-striped-active {
  		animation: progress-stripes 2s linear infinite;
  	}
c7add6cf   “wangming”   初始版本开发完毕
137
  
25852764   unknown   s
138
139
140
  	@keyframes progress-stripes {
  		0% {
  			background-position: 0 0;
c7add6cf   “wangming”   初始版本开发完毕
141
142
  		}
  
25852764   unknown   s
143
144
  		100% {
  			background-position: 39px 0;
c7add6cf   “wangming”   初始版本开发完毕
145
146
147
  		}
  	}
  </style>