sadais-piui 1.2.7-beta14 → 1.2.7-beta17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/pi-circle-progress/index.vue +105 -116
- package/components/pi-steps/index.vue +85 -33
- package/config/circleProgress.js +7 -11
- package/config/steps.js +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
:style="{
|
|
13
13
|
width: widthPx + 'px',
|
|
14
14
|
height: widthPx + 'px',
|
|
15
|
-
backgroundColor: bgColor
|
|
15
|
+
backgroundColor: bgColor
|
|
16
16
|
}"
|
|
17
17
|
>
|
|
18
18
|
<canvas
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
class="pi-canvas-bg"
|
|
22
22
|
:style="{
|
|
23
23
|
width: widthPx + 'px',
|
|
24
|
-
height: widthPx + 'px'
|
|
24
|
+
height: widthPx + 'px'
|
|
25
25
|
}"
|
|
26
26
|
/>
|
|
27
27
|
<canvas
|
|
@@ -30,164 +30,161 @@
|
|
|
30
30
|
class="pi-canvas"
|
|
31
31
|
:style="{
|
|
32
32
|
width: widthPx + 'px',
|
|
33
|
-
height: widthPx + 'px'
|
|
33
|
+
height: widthPx + 'px'
|
|
34
34
|
}"
|
|
35
35
|
/>
|
|
36
36
|
</view>
|
|
37
37
|
</template>
|
|
38
38
|
<script>
|
|
39
|
-
import { getConfig } from
|
|
40
|
-
const { circleProgress } = getConfig()
|
|
39
|
+
import { getConfig } from '../../config'
|
|
40
|
+
const { circleProgress } = getConfig()
|
|
41
41
|
|
|
42
42
|
export default {
|
|
43
|
-
name:
|
|
43
|
+
name: 'PiCircleProgress',
|
|
44
44
|
props: {
|
|
45
45
|
// 圆环进度百分比值
|
|
46
46
|
percent: {
|
|
47
47
|
type: Number,
|
|
48
48
|
default: circleProgress.percent,
|
|
49
49
|
// 限制值在0到100之间
|
|
50
|
-
validator:
|
|
51
|
-
return val >= 0 && val <= 100
|
|
52
|
-
}
|
|
50
|
+
validator: val => {
|
|
51
|
+
return val >= 0 && val <= 100
|
|
52
|
+
}
|
|
53
53
|
},
|
|
54
54
|
// 整个圆环进度区域的背景色
|
|
55
55
|
bgColor: {
|
|
56
56
|
type: String,
|
|
57
|
-
default: circleProgress.bgColor
|
|
57
|
+
default: circleProgress.bgColor
|
|
58
58
|
},
|
|
59
59
|
// 底部圆环的颜色(灰色的圆环)
|
|
60
60
|
inactiveColor: {
|
|
61
61
|
type: String,
|
|
62
|
-
default: circleProgress.inactiveColor
|
|
62
|
+
default: circleProgress.inactiveColor
|
|
63
63
|
},
|
|
64
64
|
// 圆环激活部分的颜色
|
|
65
65
|
activeColor: {
|
|
66
66
|
type: String,
|
|
67
|
-
default: circleProgress.activeColor
|
|
67
|
+
default: circleProgress.activeColor
|
|
68
68
|
},
|
|
69
69
|
// 圆环线条的宽度,单位rpx
|
|
70
70
|
borderWidth: {
|
|
71
71
|
type: [Number, String],
|
|
72
|
-
default: circleProgress.borderWidth
|
|
72
|
+
default: circleProgress.borderWidth
|
|
73
73
|
},
|
|
74
74
|
// 整个圆形的宽度,单位rpx
|
|
75
75
|
width: {
|
|
76
76
|
type: [Number, String],
|
|
77
|
-
default: circleProgress.width
|
|
77
|
+
default: circleProgress.width
|
|
78
78
|
},
|
|
79
79
|
// 整个圆环执行一圈的时间,单位ms
|
|
80
80
|
duration: {
|
|
81
81
|
type: [Number, String],
|
|
82
|
-
default: circleProgress.duration
|
|
82
|
+
default: circleProgress.duration
|
|
83
83
|
},
|
|
84
84
|
// 主题类型
|
|
85
85
|
type: {
|
|
86
86
|
type: String,
|
|
87
|
-
default: circleProgress.type
|
|
87
|
+
default: circleProgress.type
|
|
88
88
|
},
|
|
89
89
|
|
|
90
90
|
// 字体大小
|
|
91
91
|
fontSize: {
|
|
92
92
|
type: String,
|
|
93
|
-
default: circleProgress.fontSize
|
|
93
|
+
default: circleProgress.fontSize
|
|
94
94
|
},
|
|
95
95
|
// 显示的文字 默认为空
|
|
96
96
|
text: {
|
|
97
97
|
type: String,
|
|
98
|
-
default: circleProgress.text
|
|
98
|
+
default: circleProgress.text
|
|
99
99
|
},
|
|
100
100
|
linearGradient: {
|
|
101
101
|
type: Object,
|
|
102
|
-
default
|
|
103
|
-
|
|
102
|
+
default() {
|
|
103
|
+
return circleProgress.linearGradient
|
|
104
|
+
}
|
|
105
|
+
}
|
|
104
106
|
},
|
|
105
107
|
data() {
|
|
106
108
|
return {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
// #ifdef MP-WEIXIN
|
|
110
|
+
elBgId: 'pCircleProgressBgId', // 微信小程序中不能使用this.$pi形式动态生成id值,否则会报错
|
|
111
|
+
elId: 'pCircleProgressElId',
|
|
112
|
+
// #endif
|
|
113
|
+
// #ifndef MP-WEIXIN
|
|
109
114
|
elBgId: this.$pi.guid(), // 支付宝等小程序 动态生产ID
|
|
110
115
|
elId: this.$pi.guid(),
|
|
116
|
+
// #endif
|
|
111
117
|
progressContext: null,
|
|
112
118
|
// 开始的角度
|
|
113
119
|
widthPx: uni.upx2px(this.width), // 转成px后的整个组件的背景宽度
|
|
114
120
|
borderWidthPx: uni.upx2px(this.borderWidth), // 转成px后的圆环的宽度
|
|
115
121
|
startAngle: -Math.PI / 2, // canvas画圆的起始角度,默认为3点钟方向,定位到12点钟方向
|
|
116
122
|
newPercent: 0, // 当动态修改进度值的时候,保存进度值的变化前后值,用于比较用
|
|
117
|
-
oldPercent: 0
|
|
118
|
-
}
|
|
123
|
+
oldPercent: 0 // 当动态修改进度值的时候,保存进度值的变化前后值,用于比较用
|
|
124
|
+
}
|
|
119
125
|
},
|
|
120
126
|
computed: {
|
|
121
127
|
// 有type主题时,优先起作用
|
|
122
128
|
circleColor() {
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return this.$u.color[this.type];
|
|
128
|
-
else return this.activeColor;
|
|
129
|
-
},
|
|
129
|
+
if (['success', 'error', 'info', 'primary', 'warning'].indexOf(this.type) >= 0)
|
|
130
|
+
return this.$u.color[this.type]
|
|
131
|
+
else return this.activeColor
|
|
132
|
+
}
|
|
130
133
|
},
|
|
131
134
|
watch: {
|
|
132
135
|
// 深度监听进度
|
|
133
136
|
percent(nVal, oVal = 0) {
|
|
134
|
-
if (nVal > 100) nVal = 100
|
|
135
|
-
if (nVal < 0) oVal = 0
|
|
137
|
+
if (nVal > 100) nVal = 100
|
|
138
|
+
if (nVal < 0) oVal = 0
|
|
136
139
|
// 此值其实等于this.percent,命名一个新值
|
|
137
|
-
this.newPercent = nVal
|
|
138
|
-
this.oldPercent = oVal
|
|
140
|
+
this.newPercent = nVal
|
|
141
|
+
this.oldPercent = oVal
|
|
139
142
|
setTimeout(() => {
|
|
140
143
|
// 无论是百分比值增加还是减少,需要操作还是原来的旧的百分比值
|
|
141
144
|
// 将此值减少或者新增到新的百分比值
|
|
142
|
-
this.drawCircleByProgress(oVal)
|
|
143
|
-
}, 50)
|
|
144
|
-
}
|
|
145
|
+
this.drawCircleByProgress(oVal)
|
|
146
|
+
}, 50)
|
|
147
|
+
}
|
|
145
148
|
},
|
|
146
149
|
mounted() {
|
|
147
150
|
// 背景圆
|
|
148
|
-
this.drawProgressBg()
|
|
151
|
+
this.drawProgressBg()
|
|
149
152
|
setTimeout(() => {
|
|
150
153
|
// 进度圆
|
|
151
|
-
this.drawCircleByProgress(this.percent)
|
|
152
|
-
}, 500)
|
|
154
|
+
this.drawCircleByProgress(this.percent)
|
|
155
|
+
}, 500)
|
|
153
156
|
},
|
|
154
157
|
created() {
|
|
155
|
-
this.newPercent = this.percent
|
|
156
|
-
this.oldPercent = 0
|
|
158
|
+
this.newPercent = this.percent
|
|
159
|
+
this.oldPercent = 0
|
|
157
160
|
},
|
|
158
161
|
methods: {
|
|
159
162
|
drawProgressBg() {
|
|
160
|
-
console.log(this)
|
|
161
|
-
let ctx = uni.createCanvasContext(this.elBgId, this)
|
|
162
|
-
ctx.setLineWidth(this.borderWidthPx)
|
|
163
|
-
ctx.setStrokeStyle(this.inactiveColor)
|
|
164
|
-
ctx.beginPath()
|
|
163
|
+
console.log(this)
|
|
164
|
+
let ctx = uni.createCanvasContext(this.elBgId, this)
|
|
165
|
+
ctx.setLineWidth(this.borderWidthPx) // 设置圆环宽度
|
|
166
|
+
ctx.setStrokeStyle(this.inactiveColor) // 线条颜色
|
|
167
|
+
ctx.beginPath() // 开描绘路径
|
|
165
168
|
// 设置一个原点(110,110),半径为100的圆的路径到当前路径
|
|
166
|
-
let radius = this.widthPx / 2
|
|
169
|
+
let radius = this.widthPx / 2
|
|
167
170
|
// 用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
|
|
168
|
-
ctx.arc(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
radius - this.borderWidthPx,
|
|
172
|
-
0,
|
|
173
|
-
2 * Math.PI,
|
|
174
|
-
false
|
|
175
|
-
);
|
|
176
|
-
ctx.stroke(); // 对路径进行描绘
|
|
177
|
-
ctx.draw();
|
|
171
|
+
ctx.arc(radius, radius, radius - this.borderWidthPx, 0, 2 * Math.PI, false)
|
|
172
|
+
ctx.stroke() // 对路径进行描绘
|
|
173
|
+
ctx.draw()
|
|
178
174
|
},
|
|
179
175
|
// 激活部分
|
|
180
176
|
drawCircleByProgress(progress) {
|
|
181
177
|
// 第一次操作进度环时将上下文保存到了this.data中,直接使用即可
|
|
182
|
-
let ctx = this.progressContext
|
|
178
|
+
let ctx = this.progressContext
|
|
183
179
|
if (!ctx) {
|
|
184
|
-
ctx = uni.createCanvasContext(this.elId, this)
|
|
185
|
-
this.progressContext = ctx
|
|
180
|
+
ctx = uni.createCanvasContext(this.elId, this)
|
|
181
|
+
this.progressContext = ctx
|
|
186
182
|
}
|
|
183
|
+
let radius = this.widthPx / 2
|
|
187
184
|
// 表示进度的两端为圆形
|
|
188
|
-
ctx.setLineCap(
|
|
185
|
+
ctx.setLineCap('round')
|
|
189
186
|
// 设置线条的宽度和颜色
|
|
190
|
-
ctx.setLineWidth(this.borderWidthPx)
|
|
187
|
+
ctx.setLineWidth(this.borderWidthPx)
|
|
191
188
|
if (
|
|
192
189
|
this.linearGradient &&
|
|
193
190
|
this.linearGradient.show &&
|
|
@@ -195,85 +192,77 @@ export default {
|
|
|
195
192
|
) {
|
|
196
193
|
// this.imageData.slice(pos * 4, pos * 4 + 4);
|
|
197
194
|
let colorData = this.createColorData()
|
|
198
|
-
for(let i = 0;i < progress;i++){
|
|
199
|
-
const index= Math.round(i*255/progress)
|
|
200
|
-
const color = colorData.slice(index * 4,index * 4 + 4)
|
|
195
|
+
for (let i = 0; i < progress; i++) {
|
|
196
|
+
const index = Math.round((i * 255) / progress)
|
|
197
|
+
const color = colorData.slice(index * 4, index * 4 + 4)
|
|
201
198
|
ctx.beginPath()
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
let
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
radius - this.borderWidthPx,
|
|
210
|
-
startAngle,
|
|
211
|
-
endAngle,
|
|
212
|
-
false
|
|
213
|
-
);
|
|
214
|
-
ctx.stroke();
|
|
199
|
+
|
|
200
|
+
ctx.setStrokeStyle(`rgba(${color[0]},${color[1]},${color[2]},${color[3] / 255})`)
|
|
201
|
+
ctx.globalAlpha = color[3] / 255
|
|
202
|
+
let endAngle = ((2 * Math.PI) / 100) * (i + 1) + this.startAngle
|
|
203
|
+
let startAngle = this.startAngle + ((2 * Math.PI) / 100) * i
|
|
204
|
+
ctx.arc(radius, radius, radius - this.borderWidthPx, startAngle, endAngle, false)
|
|
205
|
+
ctx.stroke()
|
|
215
206
|
}
|
|
216
207
|
} else {
|
|
217
|
-
ctx.setStrokeStyle(this.circleColor)
|
|
208
|
+
ctx.setStrokeStyle(this.circleColor)
|
|
218
209
|
// 结束角的计算依据为:将2π分为100份,乘以当前的进度值,得出终止点的弧度值,加起始角,为整个圆从默认的
|
|
219
210
|
// 3点钟方向开始画图,转为更好理解的12点钟方向开始作图,这需要起始角和终止角同时加上this.startAngle值
|
|
220
|
-
let endAngle = ((2 * Math.PI) / 100) * progress + this.startAngle
|
|
221
|
-
ctx.beginPath()
|
|
211
|
+
let endAngle = ((2 * Math.PI) / 100) * progress + this.startAngle
|
|
212
|
+
ctx.beginPath()
|
|
222
213
|
// 半径为整个canvas宽度的一半
|
|
223
|
-
|
|
224
|
-
ctx.
|
|
225
|
-
radius,
|
|
226
|
-
radius,
|
|
227
|
-
radius - this.borderWidthPx,
|
|
228
|
-
this.startAngle,
|
|
229
|
-
endAngle,
|
|
230
|
-
false
|
|
231
|
-
);
|
|
232
|
-
ctx.stroke();
|
|
214
|
+
ctx.arc(radius, radius, radius - this.borderWidthPx, this.startAngle, endAngle, false)
|
|
215
|
+
ctx.stroke()
|
|
233
216
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
217
|
+
ctx.beginPath()
|
|
218
|
+
ctx.textAlign = 'center'
|
|
219
|
+
ctx.textBaseline = 'middle'
|
|
220
|
+
ctx.font = this.fontSize + ' Arial'
|
|
221
|
+
ctx.fillText(this.text, radius, radius)
|
|
222
|
+
ctx.stroke()
|
|
223
|
+
ctx.draw()
|
|
224
|
+
|
|
238
225
|
// 将总过渡时间除以100,得出每修改百分之一进度所需的时间
|
|
239
|
-
let time = Math.floor(this.duration / 100)
|
|
240
|
-
ctx.draw();
|
|
226
|
+
let time = Math.floor(this.duration / 100)
|
|
241
227
|
// 如果变更后新值大于旧值,意味着增大了百分比
|
|
242
228
|
if (this.newPercent > this.oldPercent) {
|
|
243
229
|
// 每次递增百分之一
|
|
244
|
-
progress
|
|
230
|
+
progress++
|
|
245
231
|
// 如果新增后的值,大于需要设置的值百分比值,停止继续增加
|
|
246
|
-
if (progress > this.newPercent) return
|
|
232
|
+
if (progress > this.newPercent) return
|
|
247
233
|
} else {
|
|
248
234
|
// 同理于上面
|
|
249
|
-
progress
|
|
250
|
-
if (progress < this.newPercent) return
|
|
235
|
+
progress--
|
|
236
|
+
if (progress < this.newPercent) return
|
|
251
237
|
}
|
|
252
238
|
setTimeout(() => {
|
|
253
239
|
// 定时器,每次操作间隔为time值,为了让进度条有动画效果
|
|
254
|
-
this.drawCircleByProgress(progress)
|
|
255
|
-
}, time)
|
|
240
|
+
this.drawCircleByProgress(progress)
|
|
241
|
+
}, time)
|
|
256
242
|
},
|
|
257
|
-
|
|
243
|
+
createColorData() {
|
|
244
|
+
let canvas
|
|
245
|
+
let ctx
|
|
258
246
|
// #ifndef MP-WEIXIN
|
|
259
|
-
|
|
247
|
+
canvas = document.createElement('canvas')
|
|
260
248
|
canvas.width = 256
|
|
261
249
|
canvas.height = 1
|
|
262
|
-
|
|
250
|
+
ctx = canvas.getContext('2d')
|
|
263
251
|
// #endif
|
|
264
|
-
//ifdef MP-WEIXIN
|
|
265
|
-
|
|
252
|
+
// #ifdef MP-WEIXIN
|
|
253
|
+
canvas = uni.createOffscreenCanvas({ type: '2d', width: 256, height: 1 })
|
|
254
|
+
ctx = canvas.getContext('2d')
|
|
266
255
|
// #endif
|
|
267
|
-
const linearGradient =
|
|
256
|
+
const linearGradient = ctx.createLinearGradient(0, 0, 256, 1)
|
|
268
257
|
this.linearGradient.colorStop.forEach(color => {
|
|
269
|
-
linearGradient.addColorStop(color.percent,color.value)
|
|
258
|
+
linearGradient.addColorStop(color.percent, color.value)
|
|
270
259
|
})
|
|
271
260
|
ctx.fillStyle = linearGradient
|
|
272
|
-
ctx.fillRect(0,0,256,1)
|
|
273
|
-
return ctx.getImageData(0,0,256,1).data
|
|
261
|
+
ctx.fillRect(0, 0, 256, 1)
|
|
262
|
+
return ctx.getImageData(0, 0, 256, 1).data
|
|
274
263
|
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
277
266
|
</script>
|
|
278
267
|
<style scoped lang="scss">
|
|
279
268
|
.circle-progress {
|
|
@@ -8,42 +8,56 @@
|
|
|
8
8
|
:class="[itemClass, item.mode, direction, { active: index < val }]"
|
|
9
9
|
>
|
|
10
10
|
<view class="step-icon pi-flex-row-center" :style="[item.style]">
|
|
11
|
-
<
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
<view class="step-icon-inner">
|
|
12
|
+
<template v-if="item.mode === 'dot'">
|
|
13
|
+
<view class="item-dot pi-radius-round" :style="[item.dotStyle]" />
|
|
14
|
+
</template>
|
|
15
|
+
<!-- 数字-->
|
|
16
|
+
<template v-if="item.mode === 'number'">
|
|
17
|
+
<text v-if="index >= val">
|
|
18
|
+
{{ index + 1 }}
|
|
19
|
+
</text>
|
|
20
|
+
<pi-icon v-else name="check" color="#ffffff" />
|
|
21
|
+
</template>
|
|
22
|
+
<!-- 图标 -->
|
|
23
|
+
<pi-icon
|
|
24
|
+
v-if="item.mode === 'icon'"
|
|
25
|
+
:custom-style="item.icon.customStyle"
|
|
26
|
+
:custom-class="item.icon.customClass"
|
|
27
|
+
:name="item.icon.name"
|
|
28
|
+
:dot="item.icon.dot"
|
|
29
|
+
:dot-radius="item.icon.dotRadius"
|
|
30
|
+
:badge="item.icon.badge"
|
|
31
|
+
:color="item.icon.color"
|
|
32
|
+
:size="item.icon.size"
|
|
33
|
+
:class-prefix="item.icon.classPrefix"
|
|
34
|
+
/>
|
|
35
|
+
</view>
|
|
34
36
|
</view>
|
|
35
37
|
|
|
36
38
|
<!-- 文字 -->
|
|
37
39
|
<view :class="['pi-steps-item-text']" :style="{ color: item.style.fontColor }">
|
|
38
40
|
<slot name="item" :item="item" :index="index" :active="index < val">
|
|
39
41
|
<view>{{ item.name }}</view>
|
|
40
|
-
<text class="pi-fz-20" style="word-break:break-all">
|
|
42
|
+
<text v-if="item.desc" class="pi-fz-20 pi-mg-top-10" style="word-break:break-all">
|
|
43
|
+
{{ item.desc }}
|
|
44
|
+
</text>
|
|
41
45
|
</slot>
|
|
42
46
|
</view>
|
|
43
47
|
|
|
44
48
|
<!-- 中线 -->
|
|
45
|
-
<view
|
|
46
|
-
|
|
49
|
+
<view
|
|
50
|
+
v-if="index < items.length - 1"
|
|
51
|
+
class="pi-steps-item-line"
|
|
52
|
+
:style="[lineStyle, item.lineStyle]"
|
|
53
|
+
>
|
|
54
|
+
<pi-line
|
|
55
|
+
:direction="direction"
|
|
56
|
+
length="100%"
|
|
57
|
+
:hair-line="false"
|
|
58
|
+
:color="item.icon.color"
|
|
59
|
+
border-style="dashed"
|
|
60
|
+
/>
|
|
47
61
|
</view>
|
|
48
62
|
</view>
|
|
49
63
|
</view>
|
|
@@ -138,7 +152,10 @@ export default {
|
|
|
138
152
|
}
|
|
139
153
|
},
|
|
140
154
|
data() {
|
|
141
|
-
return {
|
|
155
|
+
return {
|
|
156
|
+
iconsRect: [],
|
|
157
|
+
itemsRect: []
|
|
158
|
+
}
|
|
142
159
|
},
|
|
143
160
|
computed: {
|
|
144
161
|
getDotMaxSize() {
|
|
@@ -191,16 +208,18 @@ export default {
|
|
|
191
208
|
} else {
|
|
192
209
|
style.backgroundColor = this.getCurrentColor
|
|
193
210
|
}
|
|
211
|
+
item.icon.color = this.getCurrentColor
|
|
194
212
|
} else if (index < this.val && this.activeColor) {
|
|
195
213
|
// 已激活步骤
|
|
196
214
|
style.fontColor = this.activeColor
|
|
197
215
|
if (item.mode === 'icon') {
|
|
198
216
|
style.color = this.activeColor
|
|
199
217
|
} else if (item.mode === 'dot') {
|
|
200
|
-
item.dotStyle.backgroundColor = this.
|
|
218
|
+
item.dotStyle.backgroundColor = this.activeColor
|
|
201
219
|
} else {
|
|
202
220
|
style.backgroundColor = this.activeColor
|
|
203
221
|
}
|
|
222
|
+
item.icon.color = this.activeColor
|
|
204
223
|
} else if (index > this.val) {
|
|
205
224
|
// 未激活步骤
|
|
206
225
|
style.fontColor = this.color
|
|
@@ -213,14 +232,47 @@ export default {
|
|
|
213
232
|
if (item.mode === 'number') {
|
|
214
233
|
style.backgroundColor = this.color
|
|
215
234
|
}
|
|
235
|
+
item.icon.color = this.color
|
|
216
236
|
}
|
|
217
237
|
item.style = style
|
|
238
|
+
item.lineStyle = {}
|
|
239
|
+
if (
|
|
240
|
+
this.direction === 'column' &&
|
|
241
|
+
this.itemsRect.length &&
|
|
242
|
+
this.iconsRect.length &&
|
|
243
|
+
index < this.itemsRect.length - 1
|
|
244
|
+
) {
|
|
245
|
+
// 动态计算线的位置和高度
|
|
246
|
+
item.lineStyle.top = `${this.iconsRect[index].top -
|
|
247
|
+
this.itemsRect[index].top +
|
|
248
|
+
this.iconsRect[index].height +
|
|
249
|
+
2}px`
|
|
250
|
+
item.lineStyle.height = `${this.itemsRect[index].height -
|
|
251
|
+
this.iconsRect[index + 1].height}px`
|
|
252
|
+
}
|
|
218
253
|
return item
|
|
219
254
|
})
|
|
220
255
|
}
|
|
221
256
|
},
|
|
222
|
-
watch: {
|
|
223
|
-
|
|
257
|
+
watch: {
|
|
258
|
+
items: {
|
|
259
|
+
deep: true,
|
|
260
|
+
immediate: false,
|
|
261
|
+
handler(value) {
|
|
262
|
+
this.init()
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
mounted() {
|
|
267
|
+
this.init()
|
|
268
|
+
},
|
|
269
|
+
methods: {
|
|
270
|
+
async init() {
|
|
271
|
+
this.iconsRect = await this.$pi.common.queryRect(this, '.step-icon-inner', true)
|
|
272
|
+
this.itemsRect = await this.$pi.common.queryRect(this, '.pi-steps-item', true)
|
|
273
|
+
console.log(TAG, '计算.pi-steps布局', this.itemsRect, this.iconsRect)
|
|
274
|
+
}
|
|
275
|
+
}
|
|
224
276
|
}
|
|
225
277
|
</script>
|
|
226
278
|
|
|
@@ -256,7 +308,7 @@ export default {
|
|
|
256
308
|
display: flex;
|
|
257
309
|
flex-direction: row;
|
|
258
310
|
justify-content: flex-start;
|
|
259
|
-
align-items:
|
|
311
|
+
align-items: baseline;
|
|
260
312
|
min-height: 120rpx;
|
|
261
313
|
.pi-steps-item-text {
|
|
262
314
|
width: 95%;
|
|
@@ -266,15 +318,15 @@ export default {
|
|
|
266
318
|
}
|
|
267
319
|
.pi-steps-item-line {
|
|
268
320
|
position: absolute;
|
|
269
|
-
top: 75%;
|
|
270
321
|
z-index: 0;
|
|
271
|
-
height: 50%;
|
|
272
322
|
}
|
|
273
323
|
}
|
|
274
324
|
.item-dot,
|
|
275
325
|
.step-icon {
|
|
276
326
|
border-radius: 50%;
|
|
277
327
|
overflow: hidden;
|
|
328
|
+
position: relative;
|
|
329
|
+
z-index: 2;
|
|
278
330
|
}
|
|
279
331
|
|
|
280
332
|
&.active {
|
package/config/circleProgress.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
percent:50,
|
|
3
|
-
bgColor:'#ffffff', // 环形进度区域背景色,字符串形式,默认值:'#ffffff'
|
|
2
|
+
percent: 50, // 环形进度条,限制0-100之间,数字形式,默认值:50
|
|
3
|
+
bgColor: '#ffffff', // 环形进度区域背景色,字符串形式,默认值:'#ffffff'
|
|
4
4
|
inactiveColor: '#ececec', // 环形进度条底色,字符串形式,默认值:'#ececec'
|
|
5
5
|
activeColor: '#19be6b', // 环形进度条激活的颜色,字符串形式,默认值:'#19be6b'
|
|
6
|
-
borderWidth:14,
|
|
7
|
-
width:200
|
|
6
|
+
borderWidth: 14, // 环形进度条的线条宽度,字符串/数字形式,默认值:14
|
|
7
|
+
width: 200, // 环形进度条整个圆的宽度,字符串/数字形式,默认值:200
|
|
8
8
|
duration: 1500, // 整个圆环执行至进度条所需的时间,单位ms,字符串/数字形式,默认值:1500
|
|
9
|
-
type:''
|
|
10
|
-
fontSize:'16px'
|
|
11
|
-
text:''
|
|
12
|
-
linearGradient:{
|
|
13
|
-
show:false,
|
|
14
|
-
colorStop:[]
|
|
15
|
-
}
|
|
9
|
+
type: '', // 环形进度条的主题
|
|
10
|
+
fontSize: '16px', // 环形进度条中间显示文字的大小,字符串形式,默认值:'16px'
|
|
11
|
+
text: '' // 环形进度条中间显示的文字,字符串形式,默认值:''
|
|
16
12
|
}
|
package/config/steps.js
CHANGED
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
customStyle: {}, // 自定义样式,对象形式(默认值:{})
|
|
6
6
|
items: [], // 选项列表,默认([])
|
|
7
7
|
mode: 'dot', // 步骤条的类型,默认('dot')
|
|
8
|
-
activeColor: '', // 激活步骤的颜色
|
|
8
|
+
activeColor: '#5a7dff', // 激活步骤的颜色
|
|
9
9
|
color: '#cccccc', // 未激活的颜色
|
|
10
10
|
currentColor: '#666666', // 当前步骤的颜色
|
|
11
11
|
direction: 'row', // 排列方向
|