sadais-piui 1.2.7-beta68 → 1.2.7-beta69
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
* @Author: zhangzhenfei
|
|
3
3
|
* @Date: 2022-06-28 16:53:54
|
|
4
|
-
* @LastEditTime: 2023-
|
|
4
|
+
* @LastEditTime: 2023-05-12 16:02:29
|
|
5
5
|
* @LastEditors: zhangzhenfei
|
|
6
6
|
* @Description: 日历日期数据
|
|
7
|
-
* @FilePath: /
|
|
7
|
+
* @FilePath: /piui-awesome/src/piui/components/pi-calendar-panel/components/calendar-days/index.vue
|
|
8
8
|
-->
|
|
9
9
|
|
|
10
10
|
<template>
|
|
@@ -251,51 +251,51 @@ export default {
|
|
|
251
251
|
...day,
|
|
252
252
|
...this.$pi.date.parseDate(new Date(this.year, this.month - 1, i - firstDayCount))
|
|
253
253
|
}
|
|
254
|
+
}
|
|
254
255
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
const isDisabled = this.isDisabled(day)
|
|
257
|
+
// 禁用
|
|
258
|
+
if (isDisabled) {
|
|
259
|
+
day.disabled = true
|
|
260
|
+
}
|
|
261
|
+
// 单选选中样式
|
|
262
|
+
if (this.type === 'date' && this.isSameDay(this.calendarValue, day)) {
|
|
263
|
+
const activeStyle = {
|
|
264
|
+
color: this.activeColor,
|
|
265
|
+
borderRadius: this.getActiveBorderRadius
|
|
259
266
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
267
|
+
if (this.activeBg) activeStyle.background = this.activeBg
|
|
268
|
+
day.activeStyle = activeStyle
|
|
269
|
+
}
|
|
270
|
+
// 范围选中样式
|
|
271
|
+
if (this.type === 'range') {
|
|
272
|
+
const start = this.calendarValue[0]
|
|
273
|
+
const end = this.calendarValue[1]
|
|
274
|
+
const isBegin = this.isSameDay(start, day)
|
|
275
|
+
const isEnd = this.isSameDay(end, day)
|
|
276
|
+
const inRange =
|
|
277
|
+
start && end && day.timestamp > start.timestamp && day.timestamp < end.timestamp
|
|
278
|
+
const rangeStyle = {}
|
|
279
|
+
// 处理中间范围的样式
|
|
280
|
+
if (inRange) {
|
|
281
|
+
rangeStyle.color = this.rangeColor
|
|
282
|
+
rangeStyle.background = this.rangeBg
|
|
268
283
|
}
|
|
269
|
-
//
|
|
270
|
-
if (
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if (isBegin || isEnd) {
|
|
285
|
-
rangeStyle.color = this.activeColor
|
|
286
|
-
rangeStyle.borderRadius = isBegin
|
|
287
|
-
? `${this.getActiveBorderRadius} 0 0 0`
|
|
288
|
-
: `0 0 ${this.getActiveBorderRadius} 0`
|
|
289
|
-
if (this.activeBg) rangeStyle.background = this.activeBg
|
|
290
|
-
}
|
|
291
|
-
day.range = true
|
|
292
|
-
day.rangeStyle = rangeStyle
|
|
293
|
-
// type 为 range 开始和结束的提示
|
|
294
|
-
if (isBegin) day.tip = this.startText
|
|
295
|
-
if (isEnd) day.tip = this.endText
|
|
296
|
-
if (isBegin && isEnd) {
|
|
297
|
-
day.tip = this.startText + '-' + this.endText
|
|
298
|
-
}
|
|
284
|
+
// 处理两端
|
|
285
|
+
if (isBegin || isEnd) {
|
|
286
|
+
rangeStyle.color = this.activeColor
|
|
287
|
+
rangeStyle.borderRadius = isBegin
|
|
288
|
+
? `${this.getActiveBorderRadius} 0 0 0`
|
|
289
|
+
: `0 0 ${this.getActiveBorderRadius} 0`
|
|
290
|
+
if (this.activeBg) rangeStyle.background = this.activeBg
|
|
291
|
+
}
|
|
292
|
+
day.range = true
|
|
293
|
+
day.rangeStyle = rangeStyle
|
|
294
|
+
// type 为 range 开始和结束的提示
|
|
295
|
+
if (isBegin) day.tip = this.startText
|
|
296
|
+
if (isEnd) day.tip = this.endText
|
|
297
|
+
if (isBegin && isEnd) {
|
|
298
|
+
day.tip = this.startText + '-' + this.endText
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
// 是否打点
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
* @Author: zhouxianpan
|
|
3
3
|
* @Date: 2021-09-06 10:07:33
|
|
4
|
-
* @LastEditTime: 2023-04-
|
|
4
|
+
* @LastEditTime: 2023-04-20 17:11:04
|
|
5
5
|
* @LastEditors: zhangzhenfei
|
|
6
6
|
* @Description:
|
|
7
|
-
* @FilePath: \piui\components\pi-circle-progress\index.vue
|
|
7
|
+
* @FilePath: \piui-awesome\src\piui\components\pi-circle-progress\index.vue
|
|
8
8
|
-->
|
|
9
9
|
<template>
|
|
10
10
|
<view
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
width: parentWidthPx + 'px',
|
|
14
14
|
height: parentWidthPx + 'px',
|
|
15
15
|
backgroundColor: getType.bgColor,
|
|
16
|
-
borderRadius: '50%'
|
|
16
|
+
borderRadius: '50%'
|
|
17
17
|
}"
|
|
18
18
|
>
|
|
19
19
|
<canvas
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
class="pi-canvas-bg"
|
|
23
23
|
:style="{
|
|
24
24
|
width: widthPx + 'px',
|
|
25
|
-
height: widthPx + 'px'
|
|
25
|
+
height: widthPx + 'px'
|
|
26
26
|
}"
|
|
27
27
|
/>
|
|
28
28
|
<canvas
|
|
@@ -31,97 +31,95 @@
|
|
|
31
31
|
class="pi-canvas"
|
|
32
32
|
:style="{
|
|
33
33
|
width: widthPx + 'px',
|
|
34
|
-
height: widthPx + 'px'
|
|
34
|
+
height: widthPx + 'px'
|
|
35
35
|
}"
|
|
36
36
|
/>
|
|
37
37
|
</view>
|
|
38
38
|
</template>
|
|
39
39
|
<script>
|
|
40
|
-
import { getConfig } from
|
|
41
|
-
const { circleProgress } = getConfig()
|
|
40
|
+
import { getConfig } from '../../config'
|
|
41
|
+
const { circleProgress } = getConfig()
|
|
42
42
|
|
|
43
43
|
export default {
|
|
44
|
-
name:
|
|
44
|
+
name: 'PiCircleProgress',
|
|
45
45
|
props: {
|
|
46
46
|
// 圆环进度百分比值
|
|
47
47
|
percent: {
|
|
48
48
|
type: Number,
|
|
49
49
|
default: circleProgress.percent,
|
|
50
50
|
// 限制值在0到100之间
|
|
51
|
-
validator:
|
|
52
|
-
return val >= 0 && val <= 100
|
|
53
|
-
}
|
|
51
|
+
validator: val => {
|
|
52
|
+
return val >= 0 && val <= 100
|
|
53
|
+
}
|
|
54
54
|
},
|
|
55
55
|
// 整个圆环进度区域的背景色
|
|
56
56
|
bgColor: {
|
|
57
57
|
type: String,
|
|
58
|
-
default: circleProgress.bgColor
|
|
58
|
+
default: circleProgress.bgColor
|
|
59
59
|
},
|
|
60
60
|
// 底部圆环的颜色(灰色的圆环)
|
|
61
61
|
inactiveColor: {
|
|
62
62
|
type: String,
|
|
63
|
-
default: circleProgress.inactiveColor
|
|
63
|
+
default: circleProgress.inactiveColor
|
|
64
64
|
},
|
|
65
65
|
// 圆环激活部分的颜色
|
|
66
66
|
activeColor: {
|
|
67
67
|
type: String,
|
|
68
|
-
default: circleProgress.activeColor
|
|
68
|
+
default: circleProgress.activeColor
|
|
69
69
|
},
|
|
70
70
|
// 圆环线条的宽度,单位rpx
|
|
71
71
|
borderWidth: {
|
|
72
72
|
type: [Number, String],
|
|
73
|
-
default: circleProgress.borderWidth
|
|
73
|
+
default: circleProgress.borderWidth
|
|
74
74
|
},
|
|
75
75
|
// 整个圆形的宽度,单位rpx
|
|
76
76
|
width: {
|
|
77
77
|
type: [Number, String],
|
|
78
|
-
default: circleProgress.width
|
|
78
|
+
default: circleProgress.width
|
|
79
79
|
},
|
|
80
80
|
// 整个圆环执行一圈的时间,单位ms
|
|
81
81
|
duration: {
|
|
82
82
|
type: [Number, String],
|
|
83
|
-
default: circleProgress.duration
|
|
83
|
+
default: circleProgress.duration
|
|
84
84
|
},
|
|
85
85
|
// 主题类型
|
|
86
86
|
type: {
|
|
87
87
|
type: String,
|
|
88
88
|
default: circleProgress.type,
|
|
89
|
-
validator: function
|
|
90
|
-
return [
|
|
91
|
-
|
|
92
|
-
);
|
|
93
|
-
},
|
|
89
|
+
validator: function(value) {
|
|
90
|
+
return ['success', 'error', 'info', 'primary', 'warning'].includes(value)
|
|
91
|
+
}
|
|
94
92
|
},
|
|
95
93
|
// 主题列表
|
|
96
94
|
typeList: {
|
|
97
95
|
type: Object,
|
|
98
96
|
default() {
|
|
99
|
-
return circleProgress.typeList
|
|
100
|
-
}
|
|
97
|
+
return circleProgress.typeList
|
|
98
|
+
}
|
|
101
99
|
},
|
|
102
100
|
|
|
103
101
|
// 字体大小
|
|
104
102
|
fontSize: {
|
|
105
103
|
type: String,
|
|
106
|
-
default: circleProgress.fontSize
|
|
104
|
+
default: circleProgress.fontSize
|
|
107
105
|
},
|
|
108
106
|
// 显示的文字 默认为空
|
|
109
107
|
text: {
|
|
110
108
|
type: String,
|
|
111
|
-
default: circleProgress.text
|
|
109
|
+
default: circleProgress.text
|
|
112
110
|
},
|
|
113
111
|
linearGradient: {
|
|
114
112
|
type: Object,
|
|
115
113
|
default() {
|
|
116
|
-
return circleProgress.linearGradient
|
|
117
|
-
}
|
|
118
|
-
}
|
|
114
|
+
return circleProgress.linearGradient
|
|
115
|
+
}
|
|
116
|
+
}
|
|
119
117
|
},
|
|
120
118
|
data() {
|
|
121
119
|
return {
|
|
122
120
|
// #ifdef MP-WEIXIN
|
|
123
|
-
elBgId:
|
|
124
|
-
elId:
|
|
121
|
+
elBgId: 'pCircleProgressBgId', // 微信小程序中不能使用this.$pi形式动态生成id值,否则会报错
|
|
122
|
+
elId: 'pCircleProgressElId',
|
|
125
123
|
// #endif
|
|
126
124
|
// #ifndef MP-WEIXIN
|
|
127
125
|
elBgId: this.$pi.guid(), // 支付宝等小程序 动态生产ID
|
|
@@ -134,8 +132,8 @@ export default {
|
|
|
134
132
|
borderWidthPx: uni.upx2px(this.borderWidth), // 转成px后的圆环的宽度
|
|
135
133
|
startAngle: -Math.PI / 2, // canvas画圆的起始角度,默认为3点钟方向,定位到12点钟方向
|
|
136
134
|
newPercent: 0, // 当动态修改进度值的时候,保存进度值的变化前后值,用于比较用
|
|
137
|
-
oldPercent: 0
|
|
138
|
-
}
|
|
135
|
+
oldPercent: 0 // 当动态修改进度值的时候,保存进度值的变化前后值,用于比较用
|
|
136
|
+
}
|
|
139
137
|
},
|
|
140
138
|
computed: {
|
|
141
139
|
/**
|
|
@@ -143,14 +141,18 @@ export default {
|
|
|
143
141
|
* 如果有传入 进度条底部颜色、进度条颜色、背景颜色时就使用它们的
|
|
144
142
|
*/
|
|
145
143
|
getType() {
|
|
146
|
-
const { type, inactiveColor, activeColor, bgColor } = this
|
|
147
|
-
const typeData = this.$pi.lang.mergeDeep(this.typeList[type], {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
})
|
|
152
|
-
return
|
|
153
|
-
|
|
144
|
+
const { type, inactiveColor, activeColor, bgColor } = this
|
|
145
|
+
// const typeData = this.$pi.lang.mergeDeep(this.typeList[type], {
|
|
146
|
+
// inactiveColor,
|
|
147
|
+
// activeColor,
|
|
148
|
+
// bgColor
|
|
149
|
+
// })
|
|
150
|
+
return {
|
|
151
|
+
inactiveColor: inactiveColor || this.typeList[type]['inactiveColor'],
|
|
152
|
+
activeColor: activeColor || this.typeList[type]['activeColor'],
|
|
153
|
+
bgColor: bgColor || this.typeList[type]['bgColor']
|
|
154
|
+
}
|
|
155
|
+
}
|
|
154
156
|
// 有type主题时,优先起作用(弃用)
|
|
155
157
|
// circleColor() {
|
|
156
158
|
// if (['success', 'error', 'info', 'primary', 'warning'].indexOf(this.type) >= 0)
|
|
@@ -161,160 +163,137 @@ export default {
|
|
|
161
163
|
watch: {
|
|
162
164
|
// 深度监听进度
|
|
163
165
|
percent(nVal, oVal = 0) {
|
|
164
|
-
if (nVal > 100) nVal = 100
|
|
165
|
-
if (nVal < 0) oVal = 0
|
|
166
|
+
if (nVal > 100) nVal = 100
|
|
167
|
+
if (nVal < 0) oVal = 0
|
|
166
168
|
// 此值其实等于this.percent,命名一个新值
|
|
167
|
-
this.newPercent = nVal
|
|
168
|
-
this.oldPercent = oVal
|
|
169
|
+
this.newPercent = nVal
|
|
170
|
+
this.oldPercent = oVal
|
|
169
171
|
setTimeout(() => {
|
|
170
172
|
// 无论是百分比值增加还是减少,需要操作还是原来的旧的百分比值
|
|
171
173
|
// 将此值减少或者新增到新的百分比值
|
|
172
|
-
this.drawCircleByProgress(oVal)
|
|
173
|
-
}, 50)
|
|
174
|
-
}
|
|
174
|
+
this.drawCircleByProgress(oVal)
|
|
175
|
+
}, 50)
|
|
176
|
+
}
|
|
175
177
|
},
|
|
176
178
|
mounted() {
|
|
177
179
|
// 背景圆
|
|
178
|
-
this.drawProgressBg()
|
|
180
|
+
this.drawProgressBg()
|
|
179
181
|
setTimeout(() => {
|
|
180
182
|
// 进度圆
|
|
181
|
-
this.drawCircleByProgress(this.percent)
|
|
182
|
-
}, 500)
|
|
183
|
+
this.drawCircleByProgress(this.percent)
|
|
184
|
+
}, 500)
|
|
183
185
|
},
|
|
184
186
|
created() {
|
|
185
|
-
this.newPercent = this.percent
|
|
186
|
-
this.oldPercent = 0
|
|
187
|
+
this.newPercent = this.percent
|
|
188
|
+
this.oldPercent = 0
|
|
187
189
|
},
|
|
188
190
|
methods: {
|
|
189
191
|
drawProgressBg() {
|
|
190
192
|
// console.log(this)
|
|
191
|
-
let ctx = uni.createCanvasContext(this.elBgId, this)
|
|
192
|
-
ctx.setLineWidth(this.borderWidthPx)
|
|
193
|
+
let ctx = uni.createCanvasContext(this.elBgId, this)
|
|
194
|
+
ctx.setLineWidth(this.borderWidthPx) // 设置圆环宽度
|
|
193
195
|
// ctx.setStrokeStyle(this.inactiveColor) // 线条颜色
|
|
194
|
-
ctx.setStrokeStyle(this.getType.inactiveColor)
|
|
195
|
-
ctx.beginPath()
|
|
196
|
+
ctx.setStrokeStyle(this.getType.inactiveColor) // 线条颜色
|
|
197
|
+
ctx.beginPath() // 开描绘路径
|
|
196
198
|
// 设置一个原点(110,110),半径为100的圆的路径到当前路径
|
|
197
|
-
let radius = this.widthPx / 2
|
|
199
|
+
let radius = this.widthPx / 2
|
|
198
200
|
// 用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
|
|
199
|
-
ctx.arc(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
radius - this.borderWidthPx,
|
|
203
|
-
0,
|
|
204
|
-
2 * Math.PI,
|
|
205
|
-
false
|
|
206
|
-
);
|
|
207
|
-
ctx.stroke(); // 对路径进行描绘
|
|
208
|
-
ctx.draw();
|
|
201
|
+
ctx.arc(radius, radius, radius - this.borderWidthPx, 0, 2 * Math.PI, false)
|
|
202
|
+
ctx.stroke() // 对路径进行描绘
|
|
203
|
+
ctx.draw()
|
|
209
204
|
},
|
|
210
205
|
// 激活部分
|
|
211
206
|
drawCircleByProgress(progress) {
|
|
212
207
|
// 第一次操作进度环时将上下文保存到了this.data中,直接使用即可
|
|
213
|
-
let ctx = this.progressContext
|
|
208
|
+
let ctx = this.progressContext
|
|
214
209
|
if (!ctx) {
|
|
215
|
-
ctx = uni.createCanvasContext(this.elId, this)
|
|
216
|
-
this.progressContext = ctx
|
|
210
|
+
ctx = uni.createCanvasContext(this.elId, this)
|
|
211
|
+
this.progressContext = ctx
|
|
217
212
|
}
|
|
218
|
-
let radius = this.widthPx / 2
|
|
213
|
+
let radius = this.widthPx / 2
|
|
219
214
|
// 表示进度的两端为圆形
|
|
220
|
-
ctx.setLineCap(
|
|
215
|
+
ctx.setLineCap('round')
|
|
221
216
|
// 设置线条的宽度和颜色
|
|
222
|
-
ctx.setLineWidth(this.borderWidthPx)
|
|
217
|
+
ctx.setLineWidth(this.borderWidthPx)
|
|
223
218
|
if (
|
|
224
219
|
this.linearGradient &&
|
|
225
220
|
this.linearGradient.show &&
|
|
226
221
|
this.linearGradient.colorStop.length >= 2
|
|
227
222
|
) {
|
|
228
223
|
// this.imageData.slice(pos * 4, pos * 4 + 4);
|
|
229
|
-
let colorData = this.createColorData()
|
|
224
|
+
let colorData = this.createColorData()
|
|
230
225
|
for (let i = 0; i < progress; i++) {
|
|
231
|
-
const index = Math.round((i * 255) / progress)
|
|
232
|
-
const color = colorData.slice(index * 4, index * 4 + 4)
|
|
233
|
-
ctx.beginPath()
|
|
226
|
+
const index = Math.round((i * 255) / progress)
|
|
227
|
+
const color = colorData.slice(index * 4, index * 4 + 4)
|
|
228
|
+
ctx.beginPath()
|
|
234
229
|
|
|
235
|
-
ctx.setStrokeStyle(
|
|
236
|
-
|
|
237
|
-
)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
ctx.arc(
|
|
242
|
-
radius,
|
|
243
|
-
radius,
|
|
244
|
-
radius - this.borderWidthPx,
|
|
245
|
-
startAngle,
|
|
246
|
-
endAngle,
|
|
247
|
-
false
|
|
248
|
-
);
|
|
249
|
-
ctx.stroke();
|
|
230
|
+
ctx.setStrokeStyle(`rgba(${color[0]},${color[1]},${color[2]},${color[3] / 255})`)
|
|
231
|
+
ctx.globalAlpha = color[3] / 255
|
|
232
|
+
let endAngle = ((2 * Math.PI) / 100) * (i + 1) + this.startAngle
|
|
233
|
+
let startAngle = this.startAngle + ((2 * Math.PI) / 100) * i
|
|
234
|
+
ctx.arc(radius, radius, radius - this.borderWidthPx, startAngle, endAngle, false)
|
|
235
|
+
ctx.stroke()
|
|
250
236
|
}
|
|
251
237
|
} else {
|
|
252
238
|
// ctx.setStrokeStyle(this.circleColor)
|
|
253
|
-
ctx.setStrokeStyle(this.getType.activeColor)
|
|
239
|
+
ctx.setStrokeStyle(this.getType.activeColor)
|
|
254
240
|
// 结束角的计算依据为:将2π分为100份,乘以当前的进度值,得出终止点的弧度值,加起始角,为整个圆从默认的
|
|
255
241
|
// 3点钟方向开始画图,转为更好理解的12点钟方向开始作图,这需要起始角和终止角同时加上this.startAngle值
|
|
256
|
-
let endAngle = ((2 * Math.PI) / 100) * progress + this.startAngle
|
|
257
|
-
ctx.beginPath()
|
|
242
|
+
let endAngle = ((2 * Math.PI) / 100) * progress + this.startAngle
|
|
243
|
+
ctx.beginPath()
|
|
258
244
|
// 半径为整个canvas宽度的一半
|
|
259
|
-
ctx.arc(
|
|
260
|
-
|
|
261
|
-
radius,
|
|
262
|
-
radius - this.borderWidthPx,
|
|
263
|
-
this.startAngle,
|
|
264
|
-
endAngle,
|
|
265
|
-
false
|
|
266
|
-
);
|
|
267
|
-
ctx.stroke();
|
|
245
|
+
ctx.arc(radius, radius, radius - this.borderWidthPx, this.startAngle, endAngle, false)
|
|
246
|
+
ctx.stroke()
|
|
268
247
|
}
|
|
269
|
-
ctx.beginPath()
|
|
270
|
-
ctx.textAlign =
|
|
271
|
-
ctx.textBaseline =
|
|
272
|
-
ctx.font = this.fontSize +
|
|
273
|
-
ctx.fillText(this.text, radius, radius)
|
|
274
|
-
ctx.stroke()
|
|
275
|
-
ctx.draw()
|
|
248
|
+
ctx.beginPath()
|
|
249
|
+
ctx.textAlign = 'center'
|
|
250
|
+
ctx.textBaseline = 'middle'
|
|
251
|
+
ctx.font = this.fontSize + ' Arial'
|
|
252
|
+
ctx.fillText(this.text, radius, radius)
|
|
253
|
+
ctx.stroke()
|
|
254
|
+
ctx.draw()
|
|
276
255
|
|
|
277
256
|
// 将总过渡时间除以100,得出每修改百分之一进度所需的时间
|
|
278
|
-
let time = Math.floor(this.duration / 100)
|
|
257
|
+
let time = Math.floor(this.duration / 100)
|
|
279
258
|
// 如果变更后新值大于旧值,意味着增大了百分比
|
|
280
259
|
if (this.newPercent > this.oldPercent) {
|
|
281
260
|
// 每次递增百分之一
|
|
282
|
-
progress
|
|
261
|
+
progress++
|
|
283
262
|
// 如果新增后的值,大于需要设置的值百分比值,停止继续增加
|
|
284
|
-
if (progress > this.newPercent) return
|
|
263
|
+
if (progress > this.newPercent) return
|
|
285
264
|
} else {
|
|
286
265
|
// 同理于上面
|
|
287
|
-
progress
|
|
288
|
-
if (progress < this.newPercent) return
|
|
266
|
+
progress--
|
|
267
|
+
if (progress < this.newPercent) return
|
|
289
268
|
}
|
|
290
269
|
setTimeout(() => {
|
|
291
270
|
// 定时器,每次操作间隔为time值,为了让进度条有动画效果
|
|
292
|
-
this.drawCircleByProgress(progress)
|
|
293
|
-
}, time)
|
|
271
|
+
this.drawCircleByProgress(progress)
|
|
272
|
+
}, time)
|
|
294
273
|
},
|
|
295
274
|
createColorData() {
|
|
296
|
-
let canvas
|
|
297
|
-
let ctx
|
|
275
|
+
let canvas
|
|
276
|
+
let ctx
|
|
298
277
|
// #ifndef MP-WEIXIN
|
|
299
|
-
canvas = document.createElement(
|
|
300
|
-
canvas.width = 256
|
|
301
|
-
canvas.height = 1
|
|
302
|
-
ctx = canvas.getContext(
|
|
278
|
+
canvas = document.createElement('canvas')
|
|
279
|
+
canvas.width = 256
|
|
280
|
+
canvas.height = 1
|
|
281
|
+
ctx = canvas.getContext('2d')
|
|
303
282
|
// #endif
|
|
304
283
|
// #ifdef MP-WEIXIN
|
|
305
|
-
canvas = uni.createOffscreenCanvas({ type:
|
|
306
|
-
ctx = canvas.getContext(
|
|
284
|
+
canvas = uni.createOffscreenCanvas({ type: '2d', width: 256, height: 1 })
|
|
285
|
+
ctx = canvas.getContext('2d')
|
|
307
286
|
// #endif
|
|
308
|
-
const linearGradient = ctx.createLinearGradient(0, 0, 256, 1)
|
|
309
|
-
this.linearGradient.colorStop.forEach(
|
|
310
|
-
linearGradient.addColorStop(color.percent, color.value)
|
|
311
|
-
})
|
|
312
|
-
ctx.fillStyle = linearGradient
|
|
313
|
-
ctx.fillRect(0, 0, 256, 1)
|
|
314
|
-
return ctx.getImageData(0, 0, 256, 1).data
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
287
|
+
const linearGradient = ctx.createLinearGradient(0, 0, 256, 1)
|
|
288
|
+
this.linearGradient.colorStop.forEach(color => {
|
|
289
|
+
linearGradient.addColorStop(color.percent, color.value)
|
|
290
|
+
})
|
|
291
|
+
ctx.fillStyle = linearGradient
|
|
292
|
+
ctx.fillRect(0, 0, 256, 1)
|
|
293
|
+
return ctx.getImageData(0, 0, 256, 1).data
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
318
297
|
</script>
|
|
319
298
|
<style scoped lang="scss">
|
|
320
299
|
.circle-progress {
|