@tuya-miniapp/smart-ui 2.3.8 → 2.3.9-beta-1

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.
@@ -76,4 +76,5 @@
76
76
  readonly="{{readonly}}"
77
77
  />
78
78
  </block>
79
+ <smart-toast wx:if="{{toastId}}" id="{{toastId}}" />
79
80
  </view>
@@ -143,6 +143,10 @@ SmartComponent({
143
143
  dayClassMap: {
144
144
  type: null,
145
145
  },
146
+ toastId: {
147
+ type: String,
148
+ value: 'smart-toast-calendar',
149
+ },
146
150
  },
147
151
  data: {
148
152
  subtitle: '',
@@ -390,8 +394,8 @@ SmartComponent({
390
394
  if (complete && this.data.type === 'range') {
391
395
  const valid = this.checkRange(date);
392
396
  if (!valid) {
393
- // auto selected to max range if showConfirm
394
- if (this.data.showConfirm) {
397
+ // auto selected to max range if type is range
398
+ if (this.data.type === 'range' && this.data.maxRange) {
395
399
  this.emit([date[0], getDayByOffset(date[0], this.data.maxRange - 1)]);
396
400
  }
397
401
  else {
@@ -416,7 +420,7 @@ SmartComponent({
416
420
  if (maxRange && calcDateNum(date) > maxRange) {
417
421
  if (showRangePrompt) {
418
422
  Toast({
419
- selector: '#smart-toast-calendar',
423
+ selector: '#' + this.data.toastId,
420
424
  context: this,
421
425
  message: rangePrompt || `选择天数不能超过 ${maxRange} 天`,
422
426
  });
@@ -6,6 +6,7 @@
6
6
  "month-list": "../calendar-month-list/index",
7
7
  "year-list": "../calendar-year-list/index",
8
8
  "smart-button": "../button/index",
9
- "smart-popup": "../popup/index"
9
+ "smart-popup": "../popup/index",
10
+ "smart-toast": "../toast/index"
10
11
  }
11
12
  }
@@ -1 +1 @@
1
- @import '../common/index.css';
1
+ @import '../common/index.css';.smart-progress-circle{overflow:hidden}
@@ -5,10 +5,7 @@
5
5
  /* eslint-disable prettier/prettier */
6
6
  import { SmartComponent } from '../common/component';
7
7
  // @ts-ignore
8
- function percentToDecimal(percent) {
9
- percent = percent.replace('%', '');
10
- return percent / 100;
11
- }
8
+ import Render from './index.rjs';
12
9
  const idListRef = {
13
10
  value: [],
14
11
  };
@@ -43,8 +40,8 @@ SmartComponent({
43
40
  type: Number,
44
41
  value: 0,
45
42
  observer(val) {
46
- if (this.data.canvasId) {
47
- this.render(val, this.data.canvasId);
43
+ if (this.render && this.data.dpr) {
44
+ this.render.init(this.data);
48
45
  }
49
46
  },
50
47
  },
@@ -60,14 +57,21 @@ SmartComponent({
60
57
  },
61
58
  data: {
62
59
  canvasId: '',
63
- dpr: 1,
60
+ dpr: 0,
61
+ },
62
+ watch: {
63
+ dpr() {
64
+ if (this.render) {
65
+ this.render.init(this.data);
66
+ }
67
+ },
64
68
  },
65
69
  created() {
66
70
  this.initId();
67
- this.initRate();
71
+ this.render = new Render(this);
68
72
  },
69
73
  mounted() {
70
- this.render(this.data.percent, this.data.canvasId);
74
+ this.initRate();
71
75
  },
72
76
  destroyed() {
73
77
  idListRef.value = idListRef.value.filter(id => id !== this.data.canvasId);
@@ -86,120 +90,6 @@ SmartComponent({
86
90
  });
87
91
  idListRef.value.push(id);
88
92
  },
89
- initRate() {
90
- wx.getSystemInfo({
91
- success: res => {
92
- const dpr = res.pixelRatio; // 获取设备像素比
93
- this.setData({
94
- dpr: dpr,
95
- });
96
- },
97
- });
98
- const sizeVal = this.parseSize();
99
- const params = {
100
- canvasWidth: +sizeVal,
101
- canvasHeight: +sizeVal,
102
- width: +sizeVal,
103
- height: +sizeVal,
104
- lineWidth: this.data.trackWidth,
105
- trackColor: this.data.trackColor,
106
- fillColor: this.data.fillColor,
107
- fillColorStops: this.data.fillColorStops,
108
- maskColor: this.data.maskColor,
109
- dpr: this.data.dpr,
110
- };
111
- this.setData(params);
112
- },
113
- renderAll(canvas, ctx, progress, ops = {
114
- lineCap: 'round',
115
- }) {
116
- const radius = ((canvas.width - canvas.lineWidth) * 0.9) / 2; // 圆形半径
117
- const lineWidth = canvas.lineWidth; // 进度条宽度
118
- const startAngle = Math.PI; // 起始角度(3点钟方向)
119
- const endAngle = 4 * Math.PI; // 结束角度(360度)
120
- // 绘制环形进度条的函数
121
- function drawProgressBar(progress, color) {
122
- ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
123
- // 绘制灰色背景
124
- ctx.beginPath();
125
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
126
- // 填充颜色
127
- ctx.setFillStyle(canvas.maskColor); // 你想填充的颜色
128
- ctx.fill(); // 填充路径
129
- ctx.setLineWidth(lineWidth);
130
- ctx.setStrokeStyle(canvas.trackColor); // 灰色背景
131
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
132
- ctx.stroke();
133
- // 绘制进度条
134
- const progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
135
- ctx.beginPath();
136
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, startAngle + progressAngle);
137
- ctx.setLineWidth(lineWidth);
138
- if (canvas.fillColorStops) {
139
- // 创建线性渐变(起点x,y 到 终点x,y)
140
- const gradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
141
- for (const stop in canvas.fillColorStops) {
142
- // 添加渐变色
143
- gradient.addColorStop(percentToDecimal(stop), canvas.fillColorStops[stop]);
144
- }
145
- ctx.setStrokeStyle(gradient); // 自定义颜色
146
- }
147
- else {
148
- ctx.setStrokeStyle(color); // 自定义颜色
149
- }
150
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
151
- ctx.stroke();
152
- ctx.scale(canvas.dpr, canvas.dpr);
153
- ctx.draw();
154
- }
155
- // 示例:绘制不同的进度条
156
- drawProgressBar(progress, canvas.fillColor); // 25%的蓝色进度条
157
- },
158
- renderHalf(canvas, ctx, progress, ops = {
159
- lineCap: 'round',
160
- }) {
161
- const radius = ((canvas.width - canvas.lineWidth) * 0.9) / 2; // 圆形半径
162
- const lineWidth = canvas.lineWidth; // 进度条宽度
163
- const startAngle = 1 * Math.PI; // 起始角度(3点钟方向)
164
- const endAngle = 2 * Math.PI; // 结束角度(360度)
165
- // 绘制环形进度条的函数
166
- function drawProgressBar(progress, color) {
167
- ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
168
- // 绘制灰色背景
169
- ctx.beginPath();
170
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
171
- // 填充颜色
172
- ctx.setFillStyle(canvas.maskColor); // 你想填充的颜色
173
- ctx.fill(); // 填充路径
174
- ctx.setLineWidth(lineWidth);
175
- ctx.setStrokeStyle(canvas.trackColor); // 灰色背景
176
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
177
- ctx.stroke();
178
- // 绘制进度条
179
- const progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
180
- ctx.beginPath();
181
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, startAngle + progressAngle);
182
- ctx.setLineWidth(lineWidth);
183
- if (canvas.fillColorStops) {
184
- // 创建线性渐变(起点x,y 到 终点x,y)
185
- const gradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
186
- for (const stop in canvas.fillColorStops) {
187
- // 添加渐变色
188
- gradient.addColorStop(percentToDecimal(stop), canvas.fillColorStops[stop]);
189
- }
190
- ctx.setStrokeStyle(gradient); // 自定义颜色
191
- }
192
- else {
193
- ctx.setStrokeStyle(color); // 自定义颜色
194
- }
195
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
196
- ctx.stroke();
197
- ctx.scale(canvas.dpr, canvas.dpr);
198
- ctx.draw();
199
- }
200
- // 示例:绘制不同的进度条
201
- drawProgressBar(progress, canvas.fillColor); // 25%的蓝色进度条
202
- },
203
93
  parseSize() {
204
94
  if (typeof this.data.size === 'number')
205
95
  return this.data.size;
@@ -211,63 +101,27 @@ SmartComponent({
211
101
  }
212
102
  return this.data.size;
213
103
  },
214
- renderHalf2(canvas, ctx, progress, ops = {
215
- lineCap: 'round',
216
- }) {
217
- const radius = ((canvas.width - canvas.lineWidth) * 0.9) / 2; // 圆形半径
218
- const lineWidth = canvas.lineWidth; // 进度条宽度
219
- const startAngle = 0.8 * Math.PI; // 起始角度(3点钟方向)
220
- const endAngle = 2.2 * Math.PI; // 结束角度(360度)
221
- // 绘制环形进度条的函数
222
- function drawProgressBar(progress, color) {
223
- ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
224
- // 绘制灰色背景
225
- ctx.beginPath();
226
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
227
- // 填充颜色
228
- ctx.setFillStyle(canvas.maskColor); // 你想填充的颜色
229
- ctx.fill(); // 填充路径
230
- ctx.setLineWidth(lineWidth);
231
- ctx.setStrokeStyle(canvas.trackColor); // 灰色背景
232
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
233
- ctx.stroke();
234
- // 绘制进度条
235
- const progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
236
- ctx.beginPath();
237
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, startAngle + progressAngle);
238
- ctx.setLineWidth(lineWidth);
239
- if (canvas.fillColorStops) {
240
- // 创建线性渐变(起点x,y 到 终点x,y)
241
- const gradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
242
- for (const stop in canvas.fillColorStops) {
243
- // 添加渐变色
244
- gradient.addColorStop(percentToDecimal(stop), canvas.fillColorStops[stop]);
245
- }
246
- ctx.setStrokeStyle(gradient); // 自定义颜色
247
- }
248
- else {
249
- ctx.setStrokeStyle(color); // 自定义颜色
250
- }
251
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
252
- ctx.stroke();
253
- ctx.scale(canvas.dpr, canvas.dpr);
254
- ctx.draw();
255
- }
256
- // 示例:绘制不同的进度条
257
- drawProgressBar(progress, canvas.fillColor); // 25%的蓝色进度条
258
- },
259
- render(val, canvasId) {
260
- // @ts-ignore
261
- const context = ty.createCanvasContext(canvasId);
262
- if (this.data.mode === 'basic') {
263
- this.renderAll(this.data, context, val / 100, this.data.round ? { lineCap: 'round' } : { lineCap: '' });
264
- }
265
- if (this.data.mode === 'angle') {
266
- this.renderHalf(this.data, context, val / 200, this.data.round ? { lineCap: 'round' } : { lineCap: '' });
267
- }
268
- if (this.data.mode === 'angle2') {
269
- this.renderHalf2(this.data, context, val / 150, this.data.round ? { lineCap: 'round' } : { lineCap: '' });
270
- }
104
+ initRate() {
105
+ wx.getSystemInfo({
106
+ success: res => {
107
+ const dpr = res.pixelRatio; // 获取设备像素比
108
+ const sizeVal = this.parseSize();
109
+ const params = {
110
+ canvasWidth: +sizeVal,
111
+ canvasHeight: +sizeVal,
112
+ width: +sizeVal,
113
+ height: +sizeVal,
114
+ lineWidth: this.data.trackWidth,
115
+ trackColor: this.data.trackColor,
116
+ fillColor: this.data.fillColor,
117
+ fillColorStops: this.data.fillColorStops,
118
+ maskColor: this.data.maskColor,
119
+ dpr: dpr,
120
+ canvasId: this.data.canvasId,
121
+ };
122
+ this.setData(params);
123
+ },
124
+ });
271
125
  },
272
126
  },
273
127
  });
@@ -0,0 +1,230 @@
1
+ export default Render({
2
+ canvas: null,
3
+ lineWidth: 10,
4
+ maskColor: '#ffffff',
5
+ trackColor: '#d3d3d3',
6
+ fillColorStops: null,
7
+ dpr: 1,
8
+ fillColor: '#007AFF',
9
+
10
+ async init(data) {
11
+ let canvas = this.canvas;
12
+ if (!canvas) {
13
+ canvas = await getCanvasById(data.canvasId);
14
+ this.canvas = canvas;
15
+ }
16
+ if (!canvas) {
17
+ console.error('canvas not found');
18
+ return;
19
+ }
20
+
21
+ const canvaswidth = data.width * data.dpr;
22
+ const canvasheight = data.height * data.dpr;
23
+ canvas.width = canvaswidth;
24
+ canvas.height = canvasheight;
25
+ canvas.style.width = `${data.width}px`;
26
+ canvas.style.height = `${data.height}px`;
27
+
28
+ const ctx = canvas.getContext('2d');
29
+
30
+ this.width = data.width;
31
+ this.height = data.height;
32
+
33
+ this.dpr = data.dpr;
34
+ this.lineWidth = data.trackWidth;
35
+ this.maskColor = data.maskColor;
36
+ this.trackColor = data.trackColor;
37
+ this.fillColorStops = data.fillColorStops;
38
+ this.dpr = data.dpr;
39
+ this.fillColor = data.fillColor;
40
+ this.mode = data.mode;
41
+ this.gradientColor = data.gradientColor;
42
+
43
+ ctx.scale(this.dpr, this.dpr);
44
+ this.render(data.percent);
45
+ },
46
+ percentToDecimal(percent) {
47
+ percent = percent.replace('%', '');
48
+ return percent / 100;
49
+ },
50
+ renderAll(
51
+ progress,
52
+ ops = {
53
+ lineCap: 'round',
54
+ }
55
+ ) {
56
+ const canvas = this.canvas;
57
+ const ctx = canvas.getContext('2d');
58
+
59
+ const lineWidth = this.lineWidth; // 进度条宽度
60
+ const radius = ((this.width - lineWidth) * 0.9) / 2; // 圆形半径
61
+ const startAngle = Math.PI; // 起始角度(3点钟方向)
62
+ const endAngle = 4 * Math.PI; // 结束角度(360度)
63
+
64
+ // 绘制环形进度条的函数
65
+ const drawProgressBar = (progress, color) => {
66
+ ctx.clearRect(0, 0, this.width, this.height); // 清除画布
67
+ // 绘制灰色背景
68
+ ctx.beginPath();
69
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, endAngle);
70
+ ctx.lineWidth = lineWidth;
71
+ // 填充颜色
72
+ ctx.fillStyle = this.maskColor; // 你想填充的颜色
73
+ ctx.fill(); // 填充路径
74
+ ctx.strokeStyle = this.trackColor; // 灰色背景
75
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
76
+ ctx.stroke();
77
+
78
+ // 绘制进度条
79
+ const progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
80
+ ctx.beginPath();
81
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, startAngle + progressAngle);
82
+ ctx.lineWidth = lineWidth;
83
+
84
+ if (this.fillColorStops) {
85
+ // 创建线性渐变(起点x,y 到 终点x,y)
86
+ const gradient = ctx.createLinearGradient(0, 0, this.width, 0);
87
+
88
+ for (const stop in this.fillColorStops) {
89
+ // 添加渐变色
90
+ gradient.addColorStop(this.percentToDecimal(stop), this.fillColorStops[stop]);
91
+ }
92
+
93
+ ctx.strokeStyle = gradient; // 自定义颜色
94
+ } else {
95
+ ctx.strokeStyle = color; // 自定义颜色
96
+ }
97
+
98
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
99
+ ctx.stroke();
100
+ };
101
+
102
+ drawProgressBar(progress, this.fillColor); // 25%的蓝色进度条
103
+ },
104
+
105
+ renderHalf(
106
+ progress,
107
+ ops = {
108
+ lineCap: 'round',
109
+ }
110
+ ) {
111
+ const canvas = this.canvas;
112
+ const ctx = canvas.getContext('2d');
113
+
114
+ const lineWidth = this.lineWidth; // 进度条宽度
115
+ const radius = ((this.width - lineWidth) * 0.9) / 2; // 圆形半径
116
+ const startAngle = 1 * Math.PI; // 起始角度(3点钟方向)
117
+ const endAngle = 2 * Math.PI; // 结束角度(360度)
118
+
119
+ // 绘制环形进度条的函数
120
+ const drawProgressBar = (progress, color) => {
121
+ ctx.clearRect(0, 0, this.width, this.height); // 清除画布
122
+
123
+ // 绘制灰色背景
124
+ ctx.beginPath();
125
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, endAngle);
126
+ // 填充颜色
127
+ ctx.fillStyle = this.maskColor; // 你想填充的颜色
128
+ ctx.fill(); // 填充路径
129
+ ctx.lineWidth = lineWidth;
130
+ ctx.strokeStyle = this.trackColor; // 灰色背景
131
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
132
+ ctx.stroke();
133
+
134
+ // 绘制进度条
135
+ const progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
136
+ ctx.beginPath();
137
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, startAngle + progressAngle);
138
+ ctx.lineWidth = lineWidth;
139
+
140
+ if (this.fillColorStops) {
141
+ // 创建线性渐变(起点x,y 到 终点x,y)
142
+ const gradient = ctx.createLinearGradient(0, 0, this.width, 0);
143
+
144
+ for (const stop in this.fillColorStops) {
145
+ // 添加渐变色
146
+ gradient.addColorStop(this.percentToDecimal(stop), this.fillColorStops[stop]);
147
+ }
148
+
149
+ ctx.strokeStyle = gradient; // 自定义颜色
150
+ } else {
151
+ ctx.strokeStyle = color; // 自定义颜色
152
+ }
153
+
154
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
155
+ ctx.stroke();
156
+ };
157
+
158
+ // 示例:绘制不同的进度条
159
+ drawProgressBar(progress, this.fillColor); // 25%的蓝色进度条
160
+ },
161
+
162
+ renderHalf2(
163
+ progress,
164
+ ops = {
165
+ lineCap: 'round',
166
+ }
167
+ ) {
168
+ const canvas = this.canvas;
169
+ const ctx = canvas.getContext('2d');
170
+
171
+ const radius = ((this.width - lineWidth) * 0.9) / 2; // 圆形半径
172
+ const lineWidth = canvas.lineWidth; // 进度条宽度
173
+
174
+ const startAngle = 0.8 * Math.PI; // 起始角度(3点钟方向)
175
+ const endAngle = 2.2 * Math.PI; // 结束角度(360度)
176
+
177
+ // 绘制环形进度条的函数
178
+ const drawProgressBar = (progress, color) => {
179
+ ctx.clearRect(0, 0, this.width, this.height); // 清除画布
180
+
181
+ // 绘制灰色背景
182
+ ctx.beginPath();
183
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, endAngle);
184
+ // 填充颜色
185
+ ctx.fillStyle = this.maskColor; // 你想填充的颜色
186
+ ctx.fill(); // 填充路径
187
+ ctx.lineWidth = lineWidth;
188
+ ctx.strokeStyle = this.trackColor; // 灰色背景
189
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
190
+ ctx.stroke();
191
+
192
+ // 绘制进度条
193
+ const progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
194
+ ctx.beginPath();
195
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, startAngle + progressAngle);
196
+ ctx.lineWidth = lineWidth;
197
+
198
+ if (this.fillColorStops) {
199
+ // 创建线性渐变(起点x,y 到 终点x,y)
200
+ const gradient = ctx.createLinearGradient(0, 0, this.width, 0);
201
+
202
+ for (const stop in this.fillColorStops) {
203
+ // 添加渐变色
204
+ gradient.addColorStop(this.percentToDecimal(stop), this.fillColorStops[stop]);
205
+ }
206
+
207
+ ctx.strokeStyle = gradient; // 自定义颜色
208
+ } else {
209
+ ctx.strokeStyle = color; // 自定义颜色
210
+ }
211
+
212
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
213
+ ctx.stroke();
214
+ };
215
+
216
+ // 示例:绘制不同的进度条
217
+ drawProgressBar(progress, this.fillColor); // 25%的蓝色进度条
218
+ },
219
+ render(val) {
220
+ if (this.mode === 'basic') {
221
+ this.renderAll(val / 100, this.round ? { lineCap: 'round' } : { lineCap: '' });
222
+ }
223
+ if (this.mode === 'angle') {
224
+ this.renderHalf(val / 200, this.round ? { lineCap: 'round' } : { lineCap: '' });
225
+ }
226
+ if (this.mode === 'angle2') {
227
+ this.renderHalf2(val / 150, this.round ? { lineCap: 'round' } : { lineCap: '' });
228
+ }
229
+ },
230
+ });
@@ -1,9 +1,8 @@
1
- <canvas
2
- class="smart-progress-circle"
1
+ <view class="smart-progress-circle" style="width:{{width}}px;height:{{height}}px">
2
+ <canvas
3
3
  type="2d"
4
4
  wx:if="{{canvasId}}"
5
- width="{{ canvasWidth * dpr }}"
6
- height="{{ canvasHeight * dpr }}"
7
5
  canvas-id="{{canvasId}}"
8
- style="width: {{width}}px; height:{{height}}px; {{customStyle}}"
9
- ></canvas>
6
+ style="{{customStyle}}"
7
+ ></canvas>
8
+ </view>
@@ -1 +1 @@
1
- @import '../common/index.wxss';
1
+ @import '../common/index.wxss';.smart-progress-circle{overflow:hidden}
@@ -1 +1 @@
1
- @import '../common/index.css';.smart-nav-bar{background-color:var(--nav-bar-background-color,var(--app-B2,#fff));box-sizing:initial;height:var(--nav-bar-height,46px);line-height:var(--nav-bar-height,46px);position:relative;text-align:center;-webkit-user-select:none;user-select:none}.smart-nav-bar__content{align-items:center;display:flex;height:100%;position:relative}.smart-nav-bar__text{color:var(--nav-bar-text-color,var(--app-B2-N1,#000));display:inline-block;font-size:var(--nav-bar-text-font-size,16px);margin:0 calc(var(--padding-md, 16px)*-1);padding:0 var(--padding-md,16px);vertical-align:middle}.smart-nav-bar__text--hover{opacity:.3}.smart-nav-bar__text--home{color:var(--nav-bar-home-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-home-font-size,22px);font-weight:var(--nav-bar-home-font-weight,600)}.smart-nav-bar__text--title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600)}.smart-nav-bar__arrow{vertical-align:middle}.smart-nav-bar__arrow>view{background:var(--nav-bar-arrow-color,var(--app-B2-N1,#000))}.smart-nav-bar__icon-wrap{align-items:center;display:flex;height:var(--nav-bar-icon-size,32px);justify-content:center;margin:var(--nav-bar-icon-margin,0);width:var(--nav-bar-icon-size,32px)}.smart-nav-bar__icon>view{background:var(--nav-bar-icon-color,var(--app-B2-N1,#000))}.smart-nav-bar--safe{padding-top:var(--app-device-status-height,20px)}.smart-nav-bar--fixed{left:0;position:fixed;top:0;width:100%}.smart-nav-bar--round{border-radius:var(--nav-bar-round-border-radius,16px 16px 0 0);min-height:var(--nav-bar-round-min-height,56px)}.smart-nav-bar__title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600);margin:0 auto;max-width:60%}.smart-nav-bar__left,.smart-nav-bar__right{align-items:center;bottom:0;display:flex;position:absolute;top:0}.smart-nav-bar__left{left:var(--padding-md,16px)}.smart-nav-bar__right{right:var(--padding-md,16px)}
1
+ @import '../common/index.css';.smart-nav-bar{background-color:var(--nav-bar-background-color,var(--app-B2,#fff));box-sizing:initial;height:var(--nav-bar-height,var(--app-device-navbar-height,46px));line-height:var(--nav-bar-height,var(--app-device-navbar-height,46px));position:relative;text-align:center;-webkit-user-select:none;user-select:none}.smart-nav-bar__content{align-items:center;display:flex;height:100%;position:relative}.smart-nav-bar__text{color:var(--nav-bar-text-color,var(--app-B2-N1,#000));display:inline-block;font-size:var(--nav-bar-text-font-size,16px);margin:0 calc(var(--padding-md, 16px)*-1);padding:0 var(--padding-md,16px);vertical-align:middle}.smart-nav-bar__text--hover{opacity:.3}.smart-nav-bar__text--home{color:var(--nav-bar-home-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-home-font-size,22px);font-weight:var(--nav-bar-home-font-weight,600)}.smart-nav-bar__text--title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600)}.smart-nav-bar__arrow{vertical-align:middle}.smart-nav-bar__arrow>view{background:var(--nav-bar-arrow-color,var(--app-B2-N1,#000))}.smart-nav-bar__icon-wrap{align-items:center;display:flex;height:var(--nav-bar-icon-size,32px);justify-content:center;margin:var(--nav-bar-icon-margin,0);width:var(--nav-bar-icon-size,32px)}.smart-nav-bar__icon>view{background:var(--nav-bar-icon-color,var(--app-B2-N1,#000))}.smart-nav-bar--safe{padding-top:var(--app-device-status-height,20px)}.smart-nav-bar--fixed{left:0;position:fixed;top:0;width:100%}.smart-nav-bar--round{border-radius:var(--nav-bar-round-border-radius,16px 16px 0 0);min-height:var(--nav-bar-round-min-height,56px)}.smart-nav-bar__title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600);margin:0 auto;max-width:60%}.smart-nav-bar__left,.smart-nav-bar__right{align-items:center;bottom:0;display:flex;position:absolute;top:0}.smart-nav-bar__left{left:var(--padding-md,16px)}.smart-nav-bar__right{right:var(--padding-md,16px)}
@@ -1 +1 @@
1
- @import '../common/index.wxss';.smart-nav-bar{background-color:var(--nav-bar-background-color,var(--app-B2,#fff));box-sizing:initial;height:var(--nav-bar-height,46px);line-height:var(--nav-bar-height,46px);position:relative;text-align:center;-webkit-user-select:none;user-select:none}.smart-nav-bar__content{align-items:center;display:flex;height:100%;position:relative}.smart-nav-bar__text{color:var(--nav-bar-text-color,var(--app-B2-N1,#000));display:inline-block;font-size:var(--nav-bar-text-font-size,16px);margin:0 calc(var(--padding-md, 16px)*-1);padding:0 var(--padding-md,16px);vertical-align:middle}.smart-nav-bar__text--hover{opacity:.3}.smart-nav-bar__text--home{color:var(--nav-bar-home-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-home-font-size,22px);font-weight:var(--nav-bar-home-font-weight,600)}.smart-nav-bar__text--title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600)}.smart-nav-bar__arrow{vertical-align:middle}.smart-nav-bar__arrow>view{background:var(--nav-bar-arrow-color,var(--app-B2-N1,#000))}.smart-nav-bar__icon-wrap{align-items:center;display:flex;height:var(--nav-bar-icon-size,32px);justify-content:center;margin:var(--nav-bar-icon-margin,0);width:var(--nav-bar-icon-size,32px)}.smart-nav-bar__icon>view{background:var(--nav-bar-icon-color,var(--app-B2-N1,#000))}.smart-nav-bar--safe{padding-top:var(--app-device-status-height,20px)}.smart-nav-bar--fixed{left:0;position:fixed;top:0;width:100%}.smart-nav-bar--round{border-radius:var(--nav-bar-round-border-radius,16px 16px 0 0);min-height:var(--nav-bar-round-min-height,56px)}.smart-nav-bar__title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600);margin:0 auto;max-width:60%}.smart-nav-bar__left,.smart-nav-bar__right{align-items:center;bottom:0;display:flex;position:absolute;top:0}.smart-nav-bar__left{left:var(--padding-md,16px)}.smart-nav-bar__right{right:var(--padding-md,16px)}
1
+ @import '../common/index.wxss';.smart-nav-bar{background-color:var(--nav-bar-background-color,var(--app-B2,#fff));box-sizing:initial;height:var(--nav-bar-height,var(--app-device-navbar-height,46px));line-height:var(--nav-bar-height,var(--app-device-navbar-height,46px));position:relative;text-align:center;-webkit-user-select:none;user-select:none}.smart-nav-bar__content{align-items:center;display:flex;height:100%;position:relative}.smart-nav-bar__text{color:var(--nav-bar-text-color,var(--app-B2-N1,#000));display:inline-block;font-size:var(--nav-bar-text-font-size,16px);margin:0 calc(var(--padding-md, 16px)*-1);padding:0 var(--padding-md,16px);vertical-align:middle}.smart-nav-bar__text--hover{opacity:.3}.smart-nav-bar__text--home{color:var(--nav-bar-home-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-home-font-size,22px);font-weight:var(--nav-bar-home-font-weight,600)}.smart-nav-bar__text--title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600)}.smart-nav-bar__arrow{vertical-align:middle}.smart-nav-bar__arrow>view{background:var(--nav-bar-arrow-color,var(--app-B2-N1,#000))}.smart-nav-bar__icon-wrap{align-items:center;display:flex;height:var(--nav-bar-icon-size,32px);justify-content:center;margin:var(--nav-bar-icon-margin,0);width:var(--nav-bar-icon-size,32px)}.smart-nav-bar__icon>view{background:var(--nav-bar-icon-color,var(--app-B2-N1,#000))}.smart-nav-bar--safe{padding-top:var(--app-device-status-height,20px)}.smart-nav-bar--fixed{left:0;position:fixed;top:0;width:100%}.smart-nav-bar--round{border-radius:var(--nav-bar-round-border-radius,16px 16px 0 0);min-height:var(--nav-bar-round-min-height,56px)}.smart-nav-bar__title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600);margin:0 auto;max-width:60%}.smart-nav-bar__left,.smart-nav-bar__right{align-items:center;bottom:0;display:flex;position:absolute;top:0}.smart-nav-bar__left{left:var(--padding-md,16px)}.smart-nav-bar__right{right:var(--padding-md,16px)}
@@ -24,7 +24,7 @@
24
24
  active-style="{{ activeStyle }}"
25
25
  font-style="{{computed.style(item.fontStyle)}}"
26
26
  options="{{ item.values }}"
27
- disabled="{{ item.disabled }}"
27
+ disabled="{{ item.disabled || false }}"
28
28
  unit="{{ item.unit || unit }}"
29
29
  changeAnimation="{{ changeAnimation }}"
30
30
  default-index="{{ item.defaultIndex || defaultIndex }}"
@@ -76,4 +76,5 @@
76
76
  readonly="{{readonly}}"
77
77
  />
78
78
  </block>
79
+ <smart-toast wx:if="{{toastId}}" id="{{toastId}}" />
79
80
  </view>
@@ -157,6 +157,10 @@ var getTime = function (date) { return (date instanceof Date ? date.getTime() :
157
157
  dayClassMap: {
158
158
  type: null,
159
159
  },
160
+ toastId: {
161
+ type: String,
162
+ value: 'smart-toast-calendar',
163
+ },
160
164
  },
161
165
  data: {
162
166
  subtitle: '',
@@ -408,8 +412,8 @@ var getTime = function (date) { return (date instanceof Date ? date.getTime() :
408
412
  if (complete && this.data.type === 'range') {
409
413
  var valid = this.checkRange(date);
410
414
  if (!valid) {
411
- // auto selected to max range if showConfirm
412
- if (this.data.showConfirm) {
415
+ // auto selected to max range if type is range
416
+ if (this.data.type === 'range' && this.data.maxRange) {
413
417
  this.emit([date[0], (0, utils_1.getDayByOffset)(date[0], this.data.maxRange - 1)]);
414
418
  }
415
419
  else {
@@ -434,7 +438,7 @@ var getTime = function (date) { return (date instanceof Date ? date.getTime() :
434
438
  if (maxRange && (0, utils_1.calcDateNum)(date) > maxRange) {
435
439
  if (showRangePrompt) {
436
440
  (0, toast_1.default)({
437
- selector: '#smart-toast-calendar',
441
+ selector: '#' + this.data.toastId,
438
442
  context: this,
439
443
  message: rangePrompt || "\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 ".concat(maxRange, " \u5929"),
440
444
  });
@@ -6,6 +6,7 @@
6
6
  "month-list": "../calendar-month-list/index",
7
7
  "year-list": "../calendar-year-list/index",
8
8
  "smart-button": "../button/index",
9
- "smart-popup": "../popup/index"
9
+ "smart-popup": "../popup/index",
10
+ "smart-toast": "../toast/index"
10
11
  }
11
12
  }
@@ -1 +1 @@
1
- @import '../common/index.css';
1
+ @import '../common/index.css';.smart-progress-circle{overflow:hidden}
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  /* eslint-disable guard-for-in */
4
7
  /* eslint-disable no-restricted-syntax */
@@ -7,10 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
10
  /* eslint-disable prettier/prettier */
8
11
  var component_1 = require("../common/component");
9
12
  // @ts-ignore
10
- function percentToDecimal(percent) {
11
- percent = percent.replace('%', '');
12
- return percent / 100;
13
- }
13
+ var index_rjs_1 = __importDefault(require("./index.rjs"));
14
14
  var idListRef = {
15
15
  value: [],
16
16
  };
@@ -45,8 +45,8 @@ var idListRef = {
45
45
  type: Number,
46
46
  value: 0,
47
47
  observer: function (val) {
48
- if (this.data.canvasId) {
49
- this.render(val, this.data.canvasId);
48
+ if (this.render && this.data.dpr) {
49
+ this.render.init(this.data);
50
50
  }
51
51
  },
52
52
  },
@@ -62,14 +62,21 @@ var idListRef = {
62
62
  },
63
63
  data: {
64
64
  canvasId: '',
65
- dpr: 1,
65
+ dpr: 0,
66
+ },
67
+ watch: {
68
+ dpr: function () {
69
+ if (this.render) {
70
+ this.render.init(this.data);
71
+ }
72
+ },
66
73
  },
67
74
  created: function () {
68
75
  this.initId();
69
- this.initRate();
76
+ this.render = new index_rjs_1.default(this);
70
77
  },
71
78
  mounted: function () {
72
- this.render(this.data.percent, this.data.canvasId);
79
+ this.initRate();
73
80
  },
74
81
  destroyed: function () {
75
82
  var _this = this;
@@ -89,123 +96,6 @@ var idListRef = {
89
96
  });
90
97
  idListRef.value.push(id);
91
98
  },
92
- initRate: function () {
93
- var _this = this;
94
- wx.getSystemInfo({
95
- success: function (res) {
96
- var dpr = res.pixelRatio; // 获取设备像素比
97
- _this.setData({
98
- dpr: dpr,
99
- });
100
- },
101
- });
102
- var sizeVal = this.parseSize();
103
- var params = {
104
- canvasWidth: +sizeVal,
105
- canvasHeight: +sizeVal,
106
- width: +sizeVal,
107
- height: +sizeVal,
108
- lineWidth: this.data.trackWidth,
109
- trackColor: this.data.trackColor,
110
- fillColor: this.data.fillColor,
111
- fillColorStops: this.data.fillColorStops,
112
- maskColor: this.data.maskColor,
113
- dpr: this.data.dpr,
114
- };
115
- this.setData(params);
116
- },
117
- renderAll: function (canvas, ctx, progress, ops) {
118
- if (ops === void 0) { ops = {
119
- lineCap: 'round',
120
- }; }
121
- var radius = ((canvas.width - canvas.lineWidth) * 0.9) / 2; // 圆形半径
122
- var lineWidth = canvas.lineWidth; // 进度条宽度
123
- var startAngle = Math.PI; // 起始角度(3点钟方向)
124
- var endAngle = 4 * Math.PI; // 结束角度(360度)
125
- // 绘制环形进度条的函数
126
- function drawProgressBar(progress, color) {
127
- ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
128
- // 绘制灰色背景
129
- ctx.beginPath();
130
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
131
- // 填充颜色
132
- ctx.setFillStyle(canvas.maskColor); // 你想填充的颜色
133
- ctx.fill(); // 填充路径
134
- ctx.setLineWidth(lineWidth);
135
- ctx.setStrokeStyle(canvas.trackColor); // 灰色背景
136
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
137
- ctx.stroke();
138
- // 绘制进度条
139
- var progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
140
- ctx.beginPath();
141
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, startAngle + progressAngle);
142
- ctx.setLineWidth(lineWidth);
143
- if (canvas.fillColorStops) {
144
- // 创建线性渐变(起点x,y 到 终点x,y)
145
- var gradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
146
- for (var stop_1 in canvas.fillColorStops) {
147
- // 添加渐变色
148
- gradient.addColorStop(percentToDecimal(stop_1), canvas.fillColorStops[stop_1]);
149
- }
150
- ctx.setStrokeStyle(gradient); // 自定义颜色
151
- }
152
- else {
153
- ctx.setStrokeStyle(color); // 自定义颜色
154
- }
155
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
156
- ctx.stroke();
157
- ctx.scale(canvas.dpr, canvas.dpr);
158
- ctx.draw();
159
- }
160
- // 示例:绘制不同的进度条
161
- drawProgressBar(progress, canvas.fillColor); // 25%的蓝色进度条
162
- },
163
- renderHalf: function (canvas, ctx, progress, ops) {
164
- if (ops === void 0) { ops = {
165
- lineCap: 'round',
166
- }; }
167
- var radius = ((canvas.width - canvas.lineWidth) * 0.9) / 2; // 圆形半径
168
- var lineWidth = canvas.lineWidth; // 进度条宽度
169
- var startAngle = 1 * Math.PI; // 起始角度(3点钟方向)
170
- var endAngle = 2 * Math.PI; // 结束角度(360度)
171
- // 绘制环形进度条的函数
172
- function drawProgressBar(progress, color) {
173
- ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
174
- // 绘制灰色背景
175
- ctx.beginPath();
176
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
177
- // 填充颜色
178
- ctx.setFillStyle(canvas.maskColor); // 你想填充的颜色
179
- ctx.fill(); // 填充路径
180
- ctx.setLineWidth(lineWidth);
181
- ctx.setStrokeStyle(canvas.trackColor); // 灰色背景
182
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
183
- ctx.stroke();
184
- // 绘制进度条
185
- var progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
186
- ctx.beginPath();
187
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, startAngle + progressAngle);
188
- ctx.setLineWidth(lineWidth);
189
- if (canvas.fillColorStops) {
190
- // 创建线性渐变(起点x,y 到 终点x,y)
191
- var gradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
192
- for (var stop_2 in canvas.fillColorStops) {
193
- // 添加渐变色
194
- gradient.addColorStop(percentToDecimal(stop_2), canvas.fillColorStops[stop_2]);
195
- }
196
- ctx.setStrokeStyle(gradient); // 自定义颜色
197
- }
198
- else {
199
- ctx.setStrokeStyle(color); // 自定义颜色
200
- }
201
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
202
- ctx.stroke();
203
- ctx.scale(canvas.dpr, canvas.dpr);
204
- ctx.draw();
205
- }
206
- // 示例:绘制不同的进度条
207
- drawProgressBar(progress, canvas.fillColor); // 25%的蓝色进度条
208
- },
209
99
  parseSize: function () {
210
100
  if (typeof this.data.size === 'number')
211
101
  return this.data.size;
@@ -217,64 +107,28 @@ var idListRef = {
217
107
  }
218
108
  return this.data.size;
219
109
  },
220
- renderHalf2: function (canvas, ctx, progress, ops) {
221
- if (ops === void 0) { ops = {
222
- lineCap: 'round',
223
- }; }
224
- var radius = ((canvas.width - canvas.lineWidth) * 0.9) / 2; // 圆形半径
225
- var lineWidth = canvas.lineWidth; // 进度条宽度
226
- var startAngle = 0.8 * Math.PI; // 起始角度(3点钟方向)
227
- var endAngle = 2.2 * Math.PI; // 结束角度(360度)
228
- // 绘制环形进度条的函数
229
- function drawProgressBar(progress, color) {
230
- ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
231
- // 绘制灰色背景
232
- ctx.beginPath();
233
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
234
- // 填充颜色
235
- ctx.setFillStyle(canvas.maskColor); // 你想填充的颜色
236
- ctx.fill(); // 填充路径
237
- ctx.setLineWidth(lineWidth);
238
- ctx.setStrokeStyle(canvas.trackColor); // 灰色背景
239
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
240
- ctx.stroke();
241
- // 绘制进度条
242
- var progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
243
- ctx.beginPath();
244
- ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, startAngle + progressAngle);
245
- ctx.setLineWidth(lineWidth);
246
- if (canvas.fillColorStops) {
247
- // 创建线性渐变(起点x,y 到 终点x,y)
248
- var gradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
249
- for (var stop_3 in canvas.fillColorStops) {
250
- // 添加渐变色
251
- gradient.addColorStop(percentToDecimal(stop_3), canvas.fillColorStops[stop_3]);
252
- }
253
- ctx.setStrokeStyle(gradient); // 自定义颜色
254
- }
255
- else {
256
- ctx.setStrokeStyle(color); // 自定义颜色
257
- }
258
- ctx.setLineCap(ops.lineCap); // 设置圆角效果
259
- ctx.stroke();
260
- ctx.scale(canvas.dpr, canvas.dpr);
261
- ctx.draw();
262
- }
263
- // 示例:绘制不同的进度条
264
- drawProgressBar(progress, canvas.fillColor); // 25%的蓝色进度条
265
- },
266
- render: function (val, canvasId) {
267
- // @ts-ignore
268
- var context = ty.createCanvasContext(canvasId);
269
- if (this.data.mode === 'basic') {
270
- this.renderAll(this.data, context, val / 100, this.data.round ? { lineCap: 'round' } : { lineCap: '' });
271
- }
272
- if (this.data.mode === 'angle') {
273
- this.renderHalf(this.data, context, val / 200, this.data.round ? { lineCap: 'round' } : { lineCap: '' });
274
- }
275
- if (this.data.mode === 'angle2') {
276
- this.renderHalf2(this.data, context, val / 150, this.data.round ? { lineCap: 'round' } : { lineCap: '' });
277
- }
110
+ initRate: function () {
111
+ var _this = this;
112
+ wx.getSystemInfo({
113
+ success: function (res) {
114
+ var dpr = res.pixelRatio; // 获取设备像素比
115
+ var sizeVal = _this.parseSize();
116
+ var params = {
117
+ canvasWidth: +sizeVal,
118
+ canvasHeight: +sizeVal,
119
+ width: +sizeVal,
120
+ height: +sizeVal,
121
+ lineWidth: _this.data.trackWidth,
122
+ trackColor: _this.data.trackColor,
123
+ fillColor: _this.data.fillColor,
124
+ fillColorStops: _this.data.fillColorStops,
125
+ maskColor: _this.data.maskColor,
126
+ dpr: dpr,
127
+ canvasId: _this.data.canvasId,
128
+ };
129
+ _this.setData(params);
130
+ },
131
+ });
278
132
  },
279
133
  },
280
134
  });
@@ -0,0 +1,230 @@
1
+ export default Render({
2
+ canvas: null,
3
+ lineWidth: 10,
4
+ maskColor: '#ffffff',
5
+ trackColor: '#d3d3d3',
6
+ fillColorStops: null,
7
+ dpr: 1,
8
+ fillColor: '#007AFF',
9
+
10
+ async init(data) {
11
+ let canvas = this.canvas;
12
+ if (!canvas) {
13
+ canvas = await getCanvasById(data.canvasId);
14
+ this.canvas = canvas;
15
+ }
16
+ if (!canvas) {
17
+ console.error('canvas not found');
18
+ return;
19
+ }
20
+
21
+ const canvaswidth = data.width * data.dpr;
22
+ const canvasheight = data.height * data.dpr;
23
+ canvas.width = canvaswidth;
24
+ canvas.height = canvasheight;
25
+ canvas.style.width = `${data.width}px`;
26
+ canvas.style.height = `${data.height}px`;
27
+
28
+ const ctx = canvas.getContext('2d');
29
+
30
+ this.width = data.width;
31
+ this.height = data.height;
32
+
33
+ this.dpr = data.dpr;
34
+ this.lineWidth = data.trackWidth;
35
+ this.maskColor = data.maskColor;
36
+ this.trackColor = data.trackColor;
37
+ this.fillColorStops = data.fillColorStops;
38
+ this.dpr = data.dpr;
39
+ this.fillColor = data.fillColor;
40
+ this.mode = data.mode;
41
+ this.gradientColor = data.gradientColor;
42
+
43
+ ctx.scale(this.dpr, this.dpr);
44
+ this.render(data.percent);
45
+ },
46
+ percentToDecimal(percent) {
47
+ percent = percent.replace('%', '');
48
+ return percent / 100;
49
+ },
50
+ renderAll(
51
+ progress,
52
+ ops = {
53
+ lineCap: 'round',
54
+ }
55
+ ) {
56
+ const canvas = this.canvas;
57
+ const ctx = canvas.getContext('2d');
58
+
59
+ const lineWidth = this.lineWidth; // 进度条宽度
60
+ const radius = ((this.width - lineWidth) * 0.9) / 2; // 圆形半径
61
+ const startAngle = Math.PI; // 起始角度(3点钟方向)
62
+ const endAngle = 4 * Math.PI; // 结束角度(360度)
63
+
64
+ // 绘制环形进度条的函数
65
+ const drawProgressBar = (progress, color) => {
66
+ ctx.clearRect(0, 0, this.width, this.height); // 清除画布
67
+ // 绘制灰色背景
68
+ ctx.beginPath();
69
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, endAngle);
70
+ ctx.lineWidth = lineWidth;
71
+ // 填充颜色
72
+ ctx.fillStyle = this.maskColor; // 你想填充的颜色
73
+ ctx.fill(); // 填充路径
74
+ ctx.strokeStyle = this.trackColor; // 灰色背景
75
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
76
+ ctx.stroke();
77
+
78
+ // 绘制进度条
79
+ const progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
80
+ ctx.beginPath();
81
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, startAngle + progressAngle);
82
+ ctx.lineWidth = lineWidth;
83
+
84
+ if (this.fillColorStops) {
85
+ // 创建线性渐变(起点x,y 到 终点x,y)
86
+ const gradient = ctx.createLinearGradient(0, 0, this.width, 0);
87
+
88
+ for (const stop in this.fillColorStops) {
89
+ // 添加渐变色
90
+ gradient.addColorStop(this.percentToDecimal(stop), this.fillColorStops[stop]);
91
+ }
92
+
93
+ ctx.strokeStyle = gradient; // 自定义颜色
94
+ } else {
95
+ ctx.strokeStyle = color; // 自定义颜色
96
+ }
97
+
98
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
99
+ ctx.stroke();
100
+ };
101
+
102
+ drawProgressBar(progress, this.fillColor); // 25%的蓝色进度条
103
+ },
104
+
105
+ renderHalf(
106
+ progress,
107
+ ops = {
108
+ lineCap: 'round',
109
+ }
110
+ ) {
111
+ const canvas = this.canvas;
112
+ const ctx = canvas.getContext('2d');
113
+
114
+ const lineWidth = this.lineWidth; // 进度条宽度
115
+ const radius = ((this.width - lineWidth) * 0.9) / 2; // 圆形半径
116
+ const startAngle = 1 * Math.PI; // 起始角度(3点钟方向)
117
+ const endAngle = 2 * Math.PI; // 结束角度(360度)
118
+
119
+ // 绘制环形进度条的函数
120
+ const drawProgressBar = (progress, color) => {
121
+ ctx.clearRect(0, 0, this.width, this.height); // 清除画布
122
+
123
+ // 绘制灰色背景
124
+ ctx.beginPath();
125
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, endAngle);
126
+ // 填充颜色
127
+ ctx.fillStyle = this.maskColor; // 你想填充的颜色
128
+ ctx.fill(); // 填充路径
129
+ ctx.lineWidth = lineWidth;
130
+ ctx.strokeStyle = this.trackColor; // 灰色背景
131
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
132
+ ctx.stroke();
133
+
134
+ // 绘制进度条
135
+ const progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
136
+ ctx.beginPath();
137
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, startAngle + progressAngle);
138
+ ctx.lineWidth = lineWidth;
139
+
140
+ if (this.fillColorStops) {
141
+ // 创建线性渐变(起点x,y 到 终点x,y)
142
+ const gradient = ctx.createLinearGradient(0, 0, this.width, 0);
143
+
144
+ for (const stop in this.fillColorStops) {
145
+ // 添加渐变色
146
+ gradient.addColorStop(this.percentToDecimal(stop), this.fillColorStops[stop]);
147
+ }
148
+
149
+ ctx.strokeStyle = gradient; // 自定义颜色
150
+ } else {
151
+ ctx.strokeStyle = color; // 自定义颜色
152
+ }
153
+
154
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
155
+ ctx.stroke();
156
+ };
157
+
158
+ // 示例:绘制不同的进度条
159
+ drawProgressBar(progress, this.fillColor); // 25%的蓝色进度条
160
+ },
161
+
162
+ renderHalf2(
163
+ progress,
164
+ ops = {
165
+ lineCap: 'round',
166
+ }
167
+ ) {
168
+ const canvas = this.canvas;
169
+ const ctx = canvas.getContext('2d');
170
+
171
+ const radius = ((this.width - lineWidth) * 0.9) / 2; // 圆形半径
172
+ const lineWidth = canvas.lineWidth; // 进度条宽度
173
+
174
+ const startAngle = 0.8 * Math.PI; // 起始角度(3点钟方向)
175
+ const endAngle = 2.2 * Math.PI; // 结束角度(360度)
176
+
177
+ // 绘制环形进度条的函数
178
+ const drawProgressBar = (progress, color) => {
179
+ ctx.clearRect(0, 0, this.width, this.height); // 清除画布
180
+
181
+ // 绘制灰色背景
182
+ ctx.beginPath();
183
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, endAngle);
184
+ // 填充颜色
185
+ ctx.fillStyle = this.maskColor; // 你想填充的颜色
186
+ ctx.fill(); // 填充路径
187
+ ctx.lineWidth = lineWidth;
188
+ ctx.strokeStyle = this.trackColor; // 灰色背景
189
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
190
+ ctx.stroke();
191
+
192
+ // 绘制进度条
193
+ const progressAngle = progress * (Math.PI * 2); // 根据进度计算角度
194
+ ctx.beginPath();
195
+ ctx.arc(this.width / 2, this.height / 2, radius, startAngle, startAngle + progressAngle);
196
+ ctx.lineWidth = lineWidth;
197
+
198
+ if (this.fillColorStops) {
199
+ // 创建线性渐变(起点x,y 到 终点x,y)
200
+ const gradient = ctx.createLinearGradient(0, 0, this.width, 0);
201
+
202
+ for (const stop in this.fillColorStops) {
203
+ // 添加渐变色
204
+ gradient.addColorStop(this.percentToDecimal(stop), this.fillColorStops[stop]);
205
+ }
206
+
207
+ ctx.strokeStyle = gradient; // 自定义颜色
208
+ } else {
209
+ ctx.strokeStyle = color; // 自定义颜色
210
+ }
211
+
212
+ ctx.lineCap = ops.lineCap; // 设置圆角效果
213
+ ctx.stroke();
214
+ };
215
+
216
+ // 示例:绘制不同的进度条
217
+ drawProgressBar(progress, this.fillColor); // 25%的蓝色进度条
218
+ },
219
+ render(val) {
220
+ if (this.mode === 'basic') {
221
+ this.renderAll(val / 100, this.round ? { lineCap: 'round' } : { lineCap: '' });
222
+ }
223
+ if (this.mode === 'angle') {
224
+ this.renderHalf(val / 200, this.round ? { lineCap: 'round' } : { lineCap: '' });
225
+ }
226
+ if (this.mode === 'angle2') {
227
+ this.renderHalf2(val / 150, this.round ? { lineCap: 'round' } : { lineCap: '' });
228
+ }
229
+ },
230
+ });
@@ -1,9 +1,8 @@
1
- <canvas
2
- class="smart-progress-circle"
1
+ <view class="smart-progress-circle" style="width:{{width}}px;height:{{height}}px">
2
+ <canvas
3
3
  type="2d"
4
4
  wx:if="{{canvasId}}"
5
- width="{{ canvasWidth * dpr }}"
6
- height="{{ canvasHeight * dpr }}"
7
5
  canvas-id="{{canvasId}}"
8
- style="width: {{width}}px; height:{{height}}px; {{customStyle}}"
9
- ></canvas>
6
+ style="{{customStyle}}"
7
+ ></canvas>
8
+ </view>
@@ -1 +1 @@
1
- @import '../common/index.wxss';
1
+ @import '../common/index.wxss';.smart-progress-circle{overflow:hidden}
@@ -1 +1 @@
1
- @import '../common/index.css';.smart-nav-bar{background-color:var(--nav-bar-background-color,var(--app-B2,#fff));box-sizing:initial;height:var(--nav-bar-height,46px);line-height:var(--nav-bar-height,46px);position:relative;text-align:center;-webkit-user-select:none;user-select:none}.smart-nav-bar__content{align-items:center;display:flex;height:100%;position:relative}.smart-nav-bar__text{color:var(--nav-bar-text-color,var(--app-B2-N1,#000));display:inline-block;font-size:var(--nav-bar-text-font-size,16px);margin:0 calc(var(--padding-md, 16px)*-1);padding:0 var(--padding-md,16px);vertical-align:middle}.smart-nav-bar__text--hover{opacity:.3}.smart-nav-bar__text--home{color:var(--nav-bar-home-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-home-font-size,22px);font-weight:var(--nav-bar-home-font-weight,600)}.smart-nav-bar__text--title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600)}.smart-nav-bar__arrow{vertical-align:middle}.smart-nav-bar__arrow>view{background:var(--nav-bar-arrow-color,var(--app-B2-N1,#000))}.smart-nav-bar__icon-wrap{align-items:center;display:flex;height:var(--nav-bar-icon-size,32px);justify-content:center;margin:var(--nav-bar-icon-margin,0);width:var(--nav-bar-icon-size,32px)}.smart-nav-bar__icon>view{background:var(--nav-bar-icon-color,var(--app-B2-N1,#000))}.smart-nav-bar--safe{padding-top:var(--app-device-status-height,20px)}.smart-nav-bar--fixed{left:0;position:fixed;top:0;width:100%}.smart-nav-bar--round{border-radius:var(--nav-bar-round-border-radius,16px 16px 0 0);min-height:var(--nav-bar-round-min-height,56px)}.smart-nav-bar__title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600);margin:0 auto;max-width:60%}.smart-nav-bar__left,.smart-nav-bar__right{align-items:center;bottom:0;display:flex;position:absolute;top:0}.smart-nav-bar__left{left:var(--padding-md,16px)}.smart-nav-bar__right{right:var(--padding-md,16px)}
1
+ @import '../common/index.css';.smart-nav-bar{background-color:var(--nav-bar-background-color,var(--app-B2,#fff));box-sizing:initial;height:var(--nav-bar-height,var(--app-device-navbar-height,46px));line-height:var(--nav-bar-height,var(--app-device-navbar-height,46px));position:relative;text-align:center;-webkit-user-select:none;user-select:none}.smart-nav-bar__content{align-items:center;display:flex;height:100%;position:relative}.smart-nav-bar__text{color:var(--nav-bar-text-color,var(--app-B2-N1,#000));display:inline-block;font-size:var(--nav-bar-text-font-size,16px);margin:0 calc(var(--padding-md, 16px)*-1);padding:0 var(--padding-md,16px);vertical-align:middle}.smart-nav-bar__text--hover{opacity:.3}.smart-nav-bar__text--home{color:var(--nav-bar-home-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-home-font-size,22px);font-weight:var(--nav-bar-home-font-weight,600)}.smart-nav-bar__text--title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600)}.smart-nav-bar__arrow{vertical-align:middle}.smart-nav-bar__arrow>view{background:var(--nav-bar-arrow-color,var(--app-B2-N1,#000))}.smart-nav-bar__icon-wrap{align-items:center;display:flex;height:var(--nav-bar-icon-size,32px);justify-content:center;margin:var(--nav-bar-icon-margin,0);width:var(--nav-bar-icon-size,32px)}.smart-nav-bar__icon>view{background:var(--nav-bar-icon-color,var(--app-B2-N1,#000))}.smart-nav-bar--safe{padding-top:var(--app-device-status-height,20px)}.smart-nav-bar--fixed{left:0;position:fixed;top:0;width:100%}.smart-nav-bar--round{border-radius:var(--nav-bar-round-border-radius,16px 16px 0 0);min-height:var(--nav-bar-round-min-height,56px)}.smart-nav-bar__title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600);margin:0 auto;max-width:60%}.smart-nav-bar__left,.smart-nav-bar__right{align-items:center;bottom:0;display:flex;position:absolute;top:0}.smart-nav-bar__left{left:var(--padding-md,16px)}.smart-nav-bar__right{right:var(--padding-md,16px)}
@@ -1 +1 @@
1
- @import '../common/index.wxss';.smart-nav-bar{background-color:var(--nav-bar-background-color,var(--app-B2,#fff));box-sizing:initial;height:var(--nav-bar-height,46px);line-height:var(--nav-bar-height,46px);position:relative;text-align:center;-webkit-user-select:none;user-select:none}.smart-nav-bar__content{align-items:center;display:flex;height:100%;position:relative}.smart-nav-bar__text{color:var(--nav-bar-text-color,var(--app-B2-N1,#000));display:inline-block;font-size:var(--nav-bar-text-font-size,16px);margin:0 calc(var(--padding-md, 16px)*-1);padding:0 var(--padding-md,16px);vertical-align:middle}.smart-nav-bar__text--hover{opacity:.3}.smart-nav-bar__text--home{color:var(--nav-bar-home-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-home-font-size,22px);font-weight:var(--nav-bar-home-font-weight,600)}.smart-nav-bar__text--title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600)}.smart-nav-bar__arrow{vertical-align:middle}.smart-nav-bar__arrow>view{background:var(--nav-bar-arrow-color,var(--app-B2-N1,#000))}.smart-nav-bar__icon-wrap{align-items:center;display:flex;height:var(--nav-bar-icon-size,32px);justify-content:center;margin:var(--nav-bar-icon-margin,0);width:var(--nav-bar-icon-size,32px)}.smart-nav-bar__icon>view{background:var(--nav-bar-icon-color,var(--app-B2-N1,#000))}.smart-nav-bar--safe{padding-top:var(--app-device-status-height,20px)}.smart-nav-bar--fixed{left:0;position:fixed;top:0;width:100%}.smart-nav-bar--round{border-radius:var(--nav-bar-round-border-radius,16px 16px 0 0);min-height:var(--nav-bar-round-min-height,56px)}.smart-nav-bar__title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600);margin:0 auto;max-width:60%}.smart-nav-bar__left,.smart-nav-bar__right{align-items:center;bottom:0;display:flex;position:absolute;top:0}.smart-nav-bar__left{left:var(--padding-md,16px)}.smart-nav-bar__right{right:var(--padding-md,16px)}
1
+ @import '../common/index.wxss';.smart-nav-bar{background-color:var(--nav-bar-background-color,var(--app-B2,#fff));box-sizing:initial;height:var(--nav-bar-height,var(--app-device-navbar-height,46px));line-height:var(--nav-bar-height,var(--app-device-navbar-height,46px));position:relative;text-align:center;-webkit-user-select:none;user-select:none}.smart-nav-bar__content{align-items:center;display:flex;height:100%;position:relative}.smart-nav-bar__text{color:var(--nav-bar-text-color,var(--app-B2-N1,#000));display:inline-block;font-size:var(--nav-bar-text-font-size,16px);margin:0 calc(var(--padding-md, 16px)*-1);padding:0 var(--padding-md,16px);vertical-align:middle}.smart-nav-bar__text--hover{opacity:.3}.smart-nav-bar__text--home{color:var(--nav-bar-home-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-home-font-size,22px);font-weight:var(--nav-bar-home-font-weight,600)}.smart-nav-bar__text--title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600)}.smart-nav-bar__arrow{vertical-align:middle}.smart-nav-bar__arrow>view{background:var(--nav-bar-arrow-color,var(--app-B2-N1,#000))}.smart-nav-bar__icon-wrap{align-items:center;display:flex;height:var(--nav-bar-icon-size,32px);justify-content:center;margin:var(--nav-bar-icon-margin,0);width:var(--nav-bar-icon-size,32px)}.smart-nav-bar__icon>view{background:var(--nav-bar-icon-color,var(--app-B2-N1,#000))}.smart-nav-bar--safe{padding-top:var(--app-device-status-height,20px)}.smart-nav-bar--fixed{left:0;position:fixed;top:0;width:100%}.smart-nav-bar--round{border-radius:var(--nav-bar-round-border-radius,16px 16px 0 0);min-height:var(--nav-bar-round-min-height,56px)}.smart-nav-bar__title{color:var(--nav-bar-title-text-color,var(--app-B2-N1,#000));font-size:var(--nav-bar-title-font-size,16px);font-weight:var(--nav-bar-title-font-weight,600);margin:0 auto;max-width:60%}.smart-nav-bar__left,.smart-nav-bar__right{align-items:center;bottom:0;display:flex;position:absolute;top:0}.smart-nav-bar__left{left:var(--padding-md,16px)}.smart-nav-bar__right{right:var(--padding-md,16px)}
@@ -24,7 +24,7 @@
24
24
  active-style="{{ activeStyle }}"
25
25
  font-style="{{computed.style(item.fontStyle)}}"
26
26
  options="{{ item.values }}"
27
- disabled="{{ item.disabled }}"
27
+ disabled="{{ item.disabled || false }}"
28
28
  unit="{{ item.unit || unit }}"
29
29
  changeAnimation="{{ changeAnimation }}"
30
30
  default-index="{{ item.defaultIndex || defaultIndex }}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "2.3.8",
3
+ "version": "2.3.9-beta-1",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",
@@ -85,7 +85,7 @@
85
85
  "iOS >= 9"
86
86
  ],
87
87
  "dependencies": {
88
- "@ray-js/components-ty-slider": "^0.3.2",
88
+ "@ray-js/components-ty-slider": "^0.3.3",
89
89
  "@tuya-miniapp/icons": "^2.1.7"
90
90
  },
91
91
  "maintainers": [