uview-plus 3.4.83 → 3.4.84

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/changelog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 3.4.84(2025-08-11)
2
+ feat: 新增cropper图片裁剪组件
3
+
4
+
1
5
  ## 3.4.83(2025-08-11)
2
6
  feat: 新增barcode无三方依赖条码组
3
7
 
@@ -0,0 +1,1199 @@
1
+ <template name="u-cropper">
2
+ <view>
3
+ <image :src="imgSrc.imgSrc" @click="select" :style="[ imgStyle ]" class="my-avatar"></image>
4
+ <canvas canvas-id="avatar-canvas" id="avatar-canvas" class="my-canvas"
5
+ :style="{top: styleTop, height: cvsStyleHeight}" disable-scroll="false"></canvas>
6
+ <canvas canvas-id="oper-canvas" id="oper-canvas" class="oper-canvas"
7
+ :style="{top: styleTop, height: cvsStyleHeight}"
8
+ disable-scroll="false" @touchstart="start" @touchmove="move" @touchend="end"></canvas>
9
+ <canvas canvas-id="prv-canvas" id="prv-canvas" class="prv-canvas"disable-scroll="false"
10
+ @touchstart="hideImg":style="{ height: cvsStyleHeight, top: prvTop }"></canvas>
11
+ <view class="oper-wrapper" :style="{display: styleDisplay}">
12
+ <view class="oper">
13
+ <view class="btn-wrapper" v-if="showOper">
14
+ <view @click="select" hover-class="hover" :style="{width: btnWidth}"><text>重选</text></view>
15
+ <view @click="close" hover-class="hover" :style="{width: btnWidth}"><text>关闭</text></view>
16
+ <view @click="rotate" hover-class="hover" :style="{width: btnWidth, display: btnDsp}"><text>旋转</text></view>
17
+ <view @click="preview" hover-class="hover" :style="{width: btnWidth}"><text>预览</text></view>
18
+ <view @click="confirm" hover-class="hover" :style="{width: btnWidth}"><text>确认</text></view>
19
+ </view>
20
+ <view class="clr-wrapper" v-else>
21
+ <slider class="my-slider" @change="colorChange"
22
+ block-size="25" value="0" min="-100" max="100" activeColor="red" backgroundColor="green" block-color="grey" show-value></slider>
23
+ <view @click="prvUpload" hover-class="hover" :style="{width: btnWidth}"><text>确认</text></view>
24
+ </view>
25
+ </view>
26
+ </view>
27
+ </view>
28
+ </template>
29
+
30
+ <script>
31
+ const tabHeight = 50;
32
+ export default {
33
+ name: "u-cropper",
34
+ data() {
35
+ return {
36
+ cvsStyleHeight: '0px',
37
+ styleDisplay: 'none',
38
+ styleTop: '-10000px',
39
+ prvTop: '-10000px',
40
+ imgStyle: {},
41
+ selStyle: {},
42
+ showOper: true,
43
+ imgSrc: {
44
+ imgSrc: ''
45
+ },
46
+ btnWidth: '19%',
47
+ btnDsp: 'flex',
48
+ };
49
+ },
50
+ watch: {
51
+ avatarSrc() {
52
+ this.imgSrc.imgSrc = this.avatarSrc;
53
+ }
54
+ },
55
+ emits: ['avtinit', 'confirm'],
56
+ props:{
57
+ // 裁剪区域宽度,用于设置选择区域的宽度
58
+ areaWidth: '',
59
+ // 裁剪区域高度,用于设置选择区域的高度
60
+ areaHeight: '',
61
+ // 导出图片宽度,用于设置最终导出图片的宽度
62
+ exportWidth: '',
63
+ // 导出图片高度,用于设置最终导出图片的高度
64
+ exportHeight: '',
65
+ // 是否允许调整裁剪框大小
66
+ canChangeSize: false,
67
+ minScale: '',
68
+ maxScale: '',
69
+ canScale: true,
70
+ canRotate: true,
71
+ lockWidth: '',
72
+ lockHeight: '',
73
+ stretch: '',
74
+ lock: '',
75
+ noTab: true,
76
+ inner: false,
77
+ quality: '',
78
+ index: '',
79
+ },
80
+ created() {
81
+ this.ctxCanvas = uni.createCanvasContext('avatar-canvas', this);
82
+ this.ctxCanvasOper = uni.createCanvasContext('oper-canvas', this);
83
+ this.ctxCanvasPrv = uni.createCanvasContext('prv-canvas', this);
84
+ this.qlty = parseInt(this.quality) || 0.9;
85
+ this.imgSrc.imgSrc = this.avatarSrc;
86
+ this.letRotate = (this.canRotate === false || this.inner === true) ? 0 : 1;
87
+ this.letScale = this.canScale === false ? 0 : 1;
88
+ // 是否允许调整裁剪框大小,false表示不允许,其他值表示允许
89
+ this.letChangeSize = this.canChangeSize === false ? 0 : 1;
90
+ this.isin = this.inner === true ? 1 : 0;
91
+ this.indx = this.index || undefined;
92
+ this.mnScale = this.minScale || 0.3;
93
+ this.mxScale = this.maxScale || 4;
94
+ this.noBar = this.noTab === true ? 1 : 0;
95
+ this.stc = this.stretch;
96
+ this.lck = this.lock;
97
+ if(this.isin) {
98
+ this.btnWidth = '24%';
99
+ this.btnDsp = 'none';
100
+ } else {
101
+ this.btnWidth = '19%';
102
+ this.btnDsp = 'flex';
103
+ }
104
+
105
+ if(this.noBar) {
106
+ this.moreHeight = 0;
107
+ this.windowResize();
108
+ } else {
109
+ uni.showTabBar({
110
+ complete:(res) => {
111
+ this.moreHeight = (res.errMsg === 'showTabBar:ok') ? 50 : 0;
112
+ this.windowResize();
113
+ }
114
+ });
115
+ }
116
+ },
117
+ methods: {
118
+ windowResize() {
119
+ let sysInfo = uni.getSystemInfoSync();
120
+ this.platform = sysInfo.platform;
121
+ this.pixelRatio = sysInfo.pixelRatio;
122
+ this.windowWidth = sysInfo.windowWidth;
123
+ // #ifdef H5
124
+ this.drawTop = sysInfo.windowTop;
125
+ this.windowHeight = sysInfo.windowHeight + sysInfo.windowBottom;
126
+ this.cvsStyleHeight = this.windowHeight - tabHeight + 'px';
127
+ // #endif
128
+ // #ifdef APP-PLUS
129
+ if(this.platform === 'android') {
130
+ this.windowHeight = sysInfo.screenHeight + sysInfo.statusBarHeight;
131
+ this.cvsStyleHeight = this.windowHeight - tabHeight + 'px';
132
+ } else {
133
+ this.windowHeight = sysInfo.windowHeight + this.moreHeight;
134
+ this.cvsStyleHeight = this.windowHeight - tabHeight + 6 + 'px';
135
+ }
136
+ // #endif
137
+ // #ifdef MP
138
+ this.windowHeight = sysInfo.windowHeight + this.moreHeight;
139
+ this.cvsStyleHeight = this.windowHeight - tabHeight - 2 + 'px';
140
+ // #endif
141
+ this.pxRatio = this.windowWidth/750;
142
+
143
+ let style = this.avatarStyle;
144
+ if(style && style !== true && (style=style.trim()) ) {
145
+ style = style.split(';');
146
+ let obj = {};
147
+ for( let v of style ) {
148
+ if(!v) continue;
149
+ v = v.trim().split(':');
150
+ if(v[1].indexOf('rpx') >= 0) {
151
+ let arr = v[1].trim().split(' ');
152
+ for( let k in arr ) {
153
+ if(!arr[k]) continue;
154
+ if(arr[k].indexOf('rpx') >= 0) {
155
+ arr[k] = parseFloat(arr[k]) * this.pxRatio + 'px';
156
+ }
157
+ }
158
+ v[1] = arr.join(' ');
159
+ }
160
+ obj[v[0].trim()] = v[1].trim();
161
+ }
162
+ this.imgStyle = obj;
163
+ }
164
+
165
+ this.exportWidth && (this.exportWidth = this.exportWidth.indexOf('rpx') >= 0 ? parseInt(this.exportWidth)*this.pxRatio : parseInt(this.exportWidth));
166
+ this.exportHeight && (this.exportHeight = this.exportHeight.indexOf('rpx') >= 0 ? parseInt(this.exportHeight)*this.pxRatio : parseInt(this.exportHeight));
167
+
168
+ if(this.styleDisplay === 'flex') {
169
+ this.drawInit(true);
170
+ }
171
+ this.hideImg();
172
+ },
173
+ select() {
174
+ if(this.fSelecting) return;
175
+ this.fSelecting = true;
176
+ setTimeout(()=>{ this.fSelecting = false; }, 500);
177
+
178
+ uni.chooseImage({
179
+ count: 1,
180
+ sizeType: ['original', 'compressed'],
181
+ sourceType: ['album', 'camera'],
182
+ success: (r)=>{
183
+ uni.showLoading({ mask: true });
184
+ let path = this.imgPath = r.tempFilePaths[0];
185
+ uni.getImageInfo({
186
+ src: path,
187
+ success: r => {
188
+ this.imgWidth = r.width;
189
+ this.imgHeight = r.height;
190
+ this.path = path;
191
+ if( !this.hasSel ) {
192
+ let style = this.selStyle || {};
193
+ if( this.areaWidth && this.areaHeight ) {
194
+ let areaWidth = this.areaWidth.indexOf('rpx') >= 0 ? parseInt(this.areaWidth) * this.pxRatio: parseInt(this.areaWidth),
195
+ areaHeight = this.areaHeight.indexOf('rpx') >= 0 ? parseInt(this.areaHeight) * this.pxRatio: parseInt(this.areaHeight);
196
+ style.width = areaWidth + 'px';
197
+ style.height = areaHeight + 'px';
198
+ style.top = (this.windowHeight - areaHeight - tabHeight)/2 + 'px';
199
+ style.left = (this.windowWidth - areaWidth)/2 + 'px';
200
+ } else {
201
+ uni.showModal({
202
+ title: '裁剪框的宽或高没有设置',
203
+ showCancel: false
204
+ })
205
+ return;
206
+ }
207
+ this.selStyle = style;
208
+ }
209
+
210
+ if( this.noBar ) {
211
+ this.drawInit(true);
212
+ } else {
213
+ uni.hideTabBar({
214
+ complete: () => {
215
+ this.drawInit(true);
216
+ }
217
+ });
218
+ }
219
+ },
220
+ fail: ()=>{
221
+ uni.showToast({
222
+ title: "error3",
223
+ duration: 2000,
224
+ })
225
+ },
226
+ complete() {
227
+ uni.hideLoading();
228
+ }
229
+ });
230
+ }
231
+ })
232
+ },
233
+ confirm() {
234
+ if(this.fUploading) return;
235
+ this.fUploading = true;
236
+ setTimeout(()=>{ this.fUploading = false; }, 1000)
237
+
238
+ let style = this.selStyle,
239
+ x = parseInt(style.left),
240
+ y = parseInt(style.top),
241
+ width = parseInt(style.width),
242
+ height = parseInt(style.height),
243
+ expWidth = this.exportWidth || width,
244
+ expHeight = this.exportHeight || height;
245
+
246
+ // #ifdef H5
247
+ x *= this.pixelRatio;
248
+ y *= this.pixelRatio;
249
+ expWidth = width;
250
+ expHeight = height;
251
+ // #endif
252
+
253
+ uni.showLoading({ mask: true });
254
+ this.styleDisplay = 'none';
255
+ this.styleTop = '-10000px';
256
+ this.hasSel = false;
257
+ this.hideImg();
258
+ uni.canvasToTempFilePath({
259
+ x: x,
260
+ y: y,
261
+ width: width,
262
+ height: height,
263
+ destWidth: expWidth,
264
+ destHeight: expHeight,
265
+ canvasId: 'avatar-canvas',
266
+ fileType: 'png',
267
+ quality: this.qlty,
268
+ success: (r)=>{
269
+ r = r.tempFilePath;
270
+ // #ifdef H5
271
+ alert()
272
+ this.btop(r).then((r)=> {
273
+ if(this.exportWidth && this.exportHeight) {
274
+ let ctxCanvas = this.ctxCanvas;
275
+ expWidth = this.exportWidth,
276
+ expHeight = this.exportHeight;
277
+
278
+ ctxCanvas.drawImage(r, 0, 0, expWidth, expHeight);
279
+ ctxCanvas.draw(false,()=>{
280
+ uni.canvasToTempFilePath({
281
+ x: 0,
282
+ y: 0,
283
+ width: expWidth,
284
+ height: expHeight,
285
+ destWidth: expWidth,
286
+ destHeight: expHeight,
287
+ canvasId: 'avatar-canvas',
288
+ fileType: 'png',
289
+ quality: this.qlty,
290
+ success: (r)=>{
291
+ r = r.tempFilePath;
292
+ this.btop(r).then((r)=> {
293
+ this.$emit("confirm", {avatar: this.imgSrc, path: r, index: this.indx, data: this.rtn});
294
+ });
295
+ },
296
+ fail: ()=>{
297
+ uni.showToast({
298
+ title: "error0",
299
+ duration: 2000,
300
+ })
301
+ }
302
+ });
303
+ });
304
+ } else {
305
+ this.$emit("confirm", {avatar: this.imgSrc, path: r, index: this.indx, data: this.rtn});
306
+ }
307
+ })
308
+ // #endif
309
+ // #ifndef H5
310
+ this.$emit("confirm", {avatar: this.imgSrc, path: r, index: this.indx, data: this.rtn});
311
+ // #endif
312
+ },
313
+ fail: (res)=>{
314
+ uni.showToast({
315
+ title: "error1",
316
+ duration: 2000,
317
+ })
318
+ },
319
+ complete: () => {
320
+ uni.hideLoading();
321
+ this.noBar || uni.showTabBar();
322
+ }
323
+ }, this);
324
+ },
325
+ // 用户点击"预览"模式下的"确认"按钮时被调用,用于将预览的裁剪结果上传
326
+ prvUpload() {
327
+ if(this.fPrvUploading) return;
328
+ this.fPrvUploading = true;
329
+ setTimeout(()=>{ this.fPrvUploading = false; }, 1000)
330
+
331
+ let style = this.selStyle,
332
+ destWidth = parseInt(style.width),
333
+ destHeight = parseInt(style.height),
334
+ prvX = this.prvX,
335
+ prvY = this.prvY,
336
+ prvWidth = this.prvWidth,
337
+ prvHeight = this.prvHeight,
338
+ expWidth = this.exportWidth || prvWidth,
339
+ expHeight = this.exportHeight || prvHeight;
340
+
341
+ // #ifdef H5
342
+ prvX *= this.pixelRatio;
343
+ prvY *= this.pixelRatio;
344
+ expWidth = prvWidth;
345
+ expHeight = prvHeight;
346
+ // #endif
347
+
348
+ uni.showLoading({ mask: true });
349
+
350
+ this.styleDisplay = 'none';
351
+ this.styleTop = '-10000px';
352
+ this.hasSel = false;
353
+ this.hideImg();
354
+ uni.canvasToTempFilePath({
355
+ x: prvX,
356
+ y: prvY,
357
+ width: prvWidth,
358
+ height: prvHeight,
359
+ destWidth: expWidth,
360
+ destHeight: expHeight,
361
+ canvasId: 'prv-canvas',
362
+ fileType: 'png',
363
+ quality: this.qlty,
364
+ success: (r)=>{
365
+ r = r.tempFilePath;
366
+ // #ifdef H5
367
+ this.btop(r).then((r)=> {
368
+ if(this.exportWidth && this.exportHeight) {
369
+ let ctxCanvas = this.ctxCanvas;
370
+ expWidth = this.exportWidth,
371
+ expHeight = this.exportHeight;
372
+
373
+ ctxCanvas.drawImage(r, 0, 0, expWidth, expHeight);
374
+ ctxCanvas.draw(false, ()=>{
375
+ uni.canvasToTempFilePath({
376
+ x: 0,
377
+ y: 0,
378
+ width: expWidth,
379
+ height: expHeight,
380
+ destWidth: expWidth,
381
+ destHeight: expHeight,
382
+ canvasId: 'avatar-canvas',
383
+ fileType: 'png',
384
+ quality: this.qlty,
385
+ success: (r)=>{
386
+ r = r.tempFilePath;
387
+ this.btop(r).then((r)=> {
388
+ this.$emit("confirm", {avatar: this.imgSrc, path: r, index: this.indx, data: this.rtn});
389
+ });
390
+ },
391
+ fail: ()=>{
392
+ uni.showToast({
393
+ title: "error0",
394
+ duration: 2000,
395
+ })
396
+ }
397
+ });
398
+ });
399
+ } else {
400
+ this.$emit("confirm", {avatar: this.imgSrc, path: r, index: this.indx, data: this.rtn});
401
+ }
402
+ })
403
+ // #endif
404
+ // #ifndef H5
405
+ this.$emit("confirm", {avatar: this.imgSrc, path: r, index: this.indx, data: this.rtn});
406
+ // #endif
407
+ },
408
+ fail: ()=>{
409
+ uni.showToast({
410
+ title: "error_prv",
411
+ duration: 2000,
412
+ })
413
+ },
414
+ complete: () => {
415
+ uni.hideLoading();
416
+ this.noBar || uni.showTabBar();
417
+ }
418
+ }, this);
419
+ },
420
+ drawInit(ini=false) {
421
+ let allWidth = this.windowWidth,
422
+ allHeight = this.windowHeight,
423
+ imgWidth = this.imgWidth,
424
+ imgHeight = this.imgHeight,
425
+ imgRadio = imgWidth/imgHeight,
426
+ useWidth = allWidth - 40,
427
+ useHeight = allHeight - tabHeight - 80,
428
+ pixelRatio = this.pixelRatio,
429
+ selWidth = parseInt(this.selStyle.width),
430
+ selHeight = parseInt(this.selStyle.height);
431
+
432
+ this.fixWidth = 0;
433
+ this.fixHeight = 0;
434
+ this.lckWidth = 0;
435
+ this.lckHeight = 0;
436
+ switch(this.stc) {
437
+ case 'x': this.fixWidth = 1; break;
438
+ case 'y': this.fixHeight = 1; break;
439
+ case 'long': if(imgRadio > 1) this.fixWidth = 1; else this.fixHeight = 1; break;
440
+ case 'short': if(imgRadio > 1) this.fixHeight = 1; else this.fixWidth = 1; break;
441
+ case 'longSel': if(selWidth > selHeight) this.fixWidth = 1; else this.fixHeight = 1; break;
442
+ case 'shortSel': if(selWidth > selHeight) this.fixHeight = 1; else this.fixWidth = 1; break;
443
+ }
444
+ // lck 用于控制裁剪框的宽度和高度锁定行为
445
+ // 'x': 锁定宽度,不允许水平方向调整
446
+ // 'y': 锁定高度,不允许垂直方向调整
447
+ // 'long': 根据图片长边锁定,如果图片横向较长则锁定宽度,否则锁定高度
448
+ // 'short': 根据图片短边锁定,如果图片横向较长则锁定高度,否则锁定宽度
449
+ // 'longSel': 根据选择框的长边锁定,如果选择框宽度大于高度则锁定宽度,否则锁定高度
450
+ // 'shortSel': 根据选择框的短边锁定,如果选择框宽度大于高度则锁定高度,否则锁定宽度
451
+ switch(this.lck) {
452
+ case 'x': this.lckWidth = 1; break;
453
+ case 'y': this.lckHeight = 1; break;
454
+ case 'long': if(imgRadio > 1) this.lckWidth = 1; else this.lckHeight = 1; break;
455
+ case 'short': if(imgRadio > 1) this.lckHeight = 1; else this.lckWidth = 1; break;
456
+ case 'longSel': if(selWidth > selHeight) this.lckWidth = 1; else this.lckHeight = 1; break;
457
+ case 'shortSel': if(selWidth > selHeight) this.lckHeight = 1; else this.lckWidth = 1; break;
458
+ }
459
+ if( this.fixWidth ) {
460
+ useWidth = selWidth;
461
+ useHeight = useWidth/imgRadio;
462
+ } else if( this.fixHeight ) {
463
+ useHeight = selHeight;
464
+ useWidth = useHeight*imgRadio;
465
+ } else if( imgRadio < 1 ) {
466
+ if( imgHeight < useHeight ) {
467
+ useWidth = imgWidth;
468
+ useHeight = imgHeight;
469
+ } else {
470
+ useHeight = useHeight;
471
+ useWidth = useHeight*imgRadio;
472
+ }
473
+ } else {
474
+ if( imgWidth < useWidth ) {
475
+ useWidth = imgWidth;
476
+ useHeight = imgHeight;
477
+ } else {
478
+ useWidth = useWidth;
479
+ useHeight = useWidth/imgRadio;
480
+ }
481
+ }
482
+ if( this.isin ) {
483
+ this.scaleWidth = 0;
484
+ this.scaleHeight = 0;
485
+ if(useWidth < selWidth) {
486
+ useWidth = selWidth;
487
+ useHeight = useWidth/imgRadio;
488
+ this.lckHeight = 0;
489
+ }
490
+ if(useHeight < selHeight) {
491
+ useHeight = selHeight;
492
+ useWidth = useHeight*imgRadio;
493
+ this.lckWidth = 0;
494
+ }
495
+ }
496
+
497
+ this.scaleSize = 1;
498
+ this.rotateDeg = 0;
499
+ this.posWidth = (allWidth-useWidth)/2;
500
+ this.posHeight = (allHeight-useHeight-tabHeight)/2;
501
+ this.useWidth = useWidth;
502
+ this.useHeight = useHeight;
503
+
504
+ let style = this.selStyle,
505
+ left = parseInt(style.left),
506
+ top = parseInt(style.top),
507
+ width = parseInt(style.width),
508
+ height = parseInt(style.height),
509
+ canvas = this.canvas,
510
+ canvasOper = this.canvasOper,
511
+ ctxCanvas = this.ctxCanvas,
512
+ ctxCanvasOper = this.ctxCanvasOper;
513
+
514
+ ctxCanvasOper.setLineWidth(3);
515
+ ctxCanvasOper.setStrokeStyle('grey');
516
+ ctxCanvasOper.setGlobalAlpha(0.4);
517
+ ctxCanvasOper.setFillStyle('black');
518
+ ctxCanvasOper.strokeRect( left, top, width, height );
519
+ ctxCanvasOper.fillRect(0, 0, this.windowWidth, top);
520
+ ctxCanvasOper.fillRect(0, top, left, height);
521
+ ctxCanvasOper.fillRect(0, top+height, this.windowWidth, this.windowHeight-height-top-tabHeight);
522
+ ctxCanvasOper.fillRect(left+width, top,this.windowWidth-width-left, height);
523
+ ctxCanvasOper.setStrokeStyle('red');
524
+ ctxCanvasOper.moveTo(left+20, top);ctxCanvasOper.lineTo(left, top);ctxCanvasOper.lineTo(left, top+20);
525
+ ctxCanvasOper.moveTo(left+width-20, top);ctxCanvasOper.lineTo(left+width, top);ctxCanvasOper.lineTo(left+width, top+20);
526
+ ctxCanvasOper.moveTo(left+20, top+height);ctxCanvasOper.lineTo(left, top+height);ctxCanvasOper.lineTo(left, top+height-20);
527
+ ctxCanvasOper.moveTo(left+width-20, top+height);ctxCanvasOper.lineTo(left+width, top+height);ctxCanvasOper.lineTo(left+width, top+height-20);
528
+
529
+ // 绘制控制点(四个角)
530
+ const controlPointSize = 10;
531
+ ctxCanvasOper.setFillStyle('white');
532
+ ctxCanvasOper.setStrokeStyle('grey');
533
+ ctxCanvasOper.setLineWidth(1);
534
+ // 左上角
535
+ ctxCanvasOper.fillRect(left - controlPointSize/2, top - controlPointSize/2, controlPointSize, controlPointSize);
536
+ ctxCanvasOper.strokeRect(left - controlPointSize/2, top - controlPointSize/2, controlPointSize, controlPointSize);
537
+ // 右上角
538
+ ctxCanvasOper.fillRect(left + width - controlPointSize/2, top - controlPointSize/2, controlPointSize, controlPointSize);
539
+ ctxCanvasOper.strokeRect(left + width - controlPointSize/2, top - controlPointSize/2, controlPointSize, controlPointSize);
540
+ // 左下角
541
+ ctxCanvasOper.fillRect(left - controlPointSize/2, top + height - controlPointSize/2, controlPointSize, controlPointSize);
542
+ ctxCanvasOper.strokeRect(left - controlPointSize/2, top + height - controlPointSize/2, controlPointSize, controlPointSize);
543
+ // 右下角
544
+ ctxCanvasOper.fillRect(left + width - controlPointSize/2, top + height - controlPointSize/2, controlPointSize, controlPointSize);
545
+ ctxCanvasOper.strokeRect(left + width - controlPointSize/2, top + height - controlPointSize/2, controlPointSize, controlPointSize);
546
+
547
+ ctxCanvasOper.stroke();
548
+
549
+ ctxCanvasOper.draw(false, ()=>{
550
+ if( ini ) {
551
+ this.styleDisplay = 'flex';
552
+ // #ifdef H5
553
+ this.styleTop = this.drawTop + 'px';
554
+ // #endif
555
+ // #ifndef H5
556
+ this.styleTop = '0';
557
+ // #endif
558
+ ctxCanvas.setFillStyle('black');
559
+ this.drawImage();
560
+ }
561
+ });
562
+
563
+ this.$emit("avtinit");
564
+ },
565
+ drawImage() {
566
+ let tm_now = Date.now();
567
+ if(tm_now - this.drawTm < 20) return;
568
+ this.drawTm = tm_now;
569
+ let ctxCanvas = this.ctxCanvas;
570
+ ctxCanvas.fillRect(0, 0, this.windowWidth, this.windowHeight-tabHeight);
571
+ ctxCanvas.translate(this.posWidth+this.useWidth/2, this.posHeight+this.useHeight/2);
572
+ ctxCanvas.scale(this.scaleSize, this.scaleSize);
573
+ ctxCanvas.rotate(this.rotateDeg * Math.PI/180);
574
+ ctxCanvas.drawImage(this.imgPath, -this.useWidth/2, -this.useHeight/2, this.useWidth, this.useHeight);
575
+ ctxCanvas.draw(false);
576
+ },
577
+ hideImg() {
578
+ this.prvImg = '';
579
+ this.prvTop = '-10000px';
580
+ this.showOper = true;
581
+ this.prvImgData = null;
582
+ this.target = null;
583
+ },
584
+ close() {
585
+ this.styleDisplay = 'none';
586
+ this.styleTop = '-10000px';
587
+ this.hasSel = false;
588
+ this.hideImg();
589
+ this.noBar || uni.showTabBar();
590
+ },
591
+ preview() {
592
+ if(this.fPreviewing) return;
593
+ this.fPreviewing = true;
594
+ setTimeout(()=>{ this.fPreviewing = false; }, 1000);
595
+
596
+ let style = this.selStyle,
597
+ x = parseInt(style.left),
598
+ y = parseInt(style.top),
599
+ width = parseInt(style.width),
600
+ height = parseInt(style.height);
601
+
602
+ // #ifdef H5
603
+ x *= this.pixelRatio;
604
+ y *= this.pixelRatio;
605
+ // #endif
606
+
607
+ uni.showLoading({ mask: true });
608
+ console.log('size', x, y, width, height)
609
+ uni.canvasToTempFilePath({
610
+ x: x,
611
+ y: y,
612
+ width: width,
613
+ height: height,
614
+ canvasId: 'avatar-canvas',
615
+ fileType: 'png',
616
+ quality: this.qlty,
617
+ success: (r)=>{
618
+ console.log(r)
619
+ this.prvImgTmp = r = r.tempFilePath;
620
+
621
+ let ctxCanvasPrv = this.ctxCanvasPrv,
622
+ prvX = this.windowWidth,
623
+ prvY = parseInt(this.cvsStyleHeight),
624
+ prvWidth = parseInt(this.selStyle.width),
625
+ prvHeight = parseInt(this.selStyle.height),
626
+ useWidth = prvX - 40,
627
+ useHeight = prvY - 80,
628
+ radio = useWidth/prvWidth,
629
+ rHeight = prvHeight*radio;
630
+ if(rHeight < useHeight) {
631
+ prvWidth = useWidth;
632
+ prvHeight = rHeight;
633
+ } else {
634
+ radio = useHeight/prvHeight;
635
+ prvWidth *= radio;
636
+ prvHeight = useHeight;
637
+ }
638
+ // ctxCanvasPrv.setFillStyle('black');
639
+ ctxCanvasPrv.fillRect(0, 0, prvX, prvY);
640
+ ctxCanvasPrv.fillRect(x, y, width, height);
641
+ this.prvX = prvX = (prvX-prvWidth)/2;
642
+ this.prvY = prvY = (prvY-prvHeight)/2;
643
+ this.prvWidth = prvWidth;
644
+ this.prvHeight = prvHeight;
645
+ ctxCanvasPrv.drawImage(r, prvX, prvY, prvWidth, prvHeight);
646
+ ctxCanvasPrv.draw(false, () => {alert()
647
+ // #ifdef H5
648
+ this.btop(this.prvImgTmp).then((r)=> {
649
+ this.showOper = false;
650
+ this.prvTop = this.drawTop + 'px';
651
+ })
652
+ // #endif
653
+ // #ifndef H5
654
+ if( this.platform != 'android' ) {
655
+ this.showOper = false;
656
+ }
657
+ this.prvTop = '0';
658
+ // #endif
659
+ });
660
+ },
661
+ fail: ()=>{
662
+ uni.showToast({
663
+ title: "error2",
664
+ duration: 2000,
665
+ })
666
+ },
667
+ complete: () => {
668
+ uni.hideLoading();
669
+ }
670
+ }, this);
671
+ },
672
+ chooseImage(index=undefined, params=undefined, data=undefined) {
673
+ if(params) {
674
+ let areaWidth = params.areaWidth,
675
+ areaHeight = params.areaHeight,
676
+ expWidth = params.expWidth,
677
+ expHeight = params.expHeight,
678
+ quality = params.quality,
679
+ canRotate = params.canRotate,
680
+ canScale = params.canScale,
681
+ canChangeSize = params.canChangeSize || false,
682
+ minScale = params.minScale,
683
+ maxScale = params.maxScale,
684
+ stretch = params.stretch,
685
+ inner = params.inner,
686
+ lock = params.lock;
687
+
688
+ expWidth && (this.exportWidth = expWidth.indexOf('rpx') >= 0 ? parseInt(expWidth)*this.pxRatio : parseInt(expWidth));
689
+ expHeight && (this.exportHeight = expHeight.indexOf('rpx') >= 0 ? parseInt(expHeight)*this.pxRatio : parseInt(expHeight));
690
+ this.letRotate = canRotate === false ? 0 : 1;
691
+ this.letScale = canScale === false ? 0 : 1;
692
+ // 设置是否允许调整裁剪框大小
693
+ this.letChangeSize = canChangeSize === false ? 0 : 1;
694
+ this.qlty = parseInt(quality) || 0.9;
695
+ this.mnScale = minScale || 0.3;
696
+ this.mxScale = maxScale || 4;
697
+ this.stc = stretch;
698
+ this.isin = inner === true ? 1 : 0;
699
+ this.lck = lock;
700
+ if(this.isin) {
701
+ this.btnWidth = '24%';
702
+ this.btnDsp = 'none';
703
+ } else {
704
+ this.btnWidth = '19%';
705
+ this.btnDsp = 'flex';
706
+ }
707
+
708
+ if( areaWidth && areaHeight) {
709
+ areaWidth = areaWidth.indexOf('rpx') >= 0 ? parseInt(areaWidth) * this.pxRatio: parseInt(areaWidth);
710
+ areaHeight = areaHeight.indexOf('rpx') >= 0 ? parseInt(areaHeight) * this.pxRatio: parseInt(areaHeight);
711
+ this.selStyle.width = areaWidth + 'px';
712
+ this.selStyle.height = areaHeight + 'px';
713
+ this.selStyle.top = (this.windowHeight - areaHeight - tabHeight)/2 + 'px';
714
+ this.selStyle.left = (this.windowWidth - areaWidth)/2 + 'px';
715
+ this.hasSel = true;
716
+ }
717
+ }
718
+ this.rtn = data;
719
+ this.indx = index;
720
+ this.select();
721
+ },
722
+ rotate() {
723
+ // #ifdef APP-PLUS
724
+ if(this.platform === 'android') {
725
+ if(this.fRotateing) return;
726
+ this.fRotateing = true;
727
+ setTimeout(()=>{ this.fRotateing = false; }, 500);
728
+ }
729
+ // #endif
730
+
731
+ // if(this.letRotate) {
732
+ this.rotateDeg += 90 - this.rotateDeg%90;
733
+ this.drawImage();
734
+ // }
735
+ },
736
+ start(e) {
737
+ let touches = e.touches,
738
+ touch0 = touches[0],
739
+ touch1 = touches[1];
740
+
741
+ this.touch0 = touch0;
742
+ this.touch1 = touch1;
743
+
744
+ if( touch1 ) {
745
+ let x = touch1.x - touch0.x,
746
+ y = touch1.y - touch0.y;
747
+ this.fgDistance = Math.sqrt(x * x + y * y);
748
+ } else {
749
+ // 只有在允许调整大小时才检查控制点
750
+ if (this.letChangeSize) {
751
+ // 检查是否点击在控制点上
752
+ const controlPointSize = 20;
753
+ const x = touch0.x;
754
+ const y = touch0.y;
755
+ const style = this.selStyle;
756
+ const left = parseInt(style.left);
757
+ const top = parseInt(style.top);
758
+ const width = parseInt(style.width);
759
+ const height = parseInt(style.height);
760
+
761
+ // 检查四个控制点
762
+ if (Math.abs(x - left) < controlPointSize && Math.abs(y - top) < controlPointSize) {
763
+ this.resizeHandle = 'top-left';
764
+ } else if (Math.abs(x - (left + width)) < controlPointSize && Math.abs(y - top) < controlPointSize) {
765
+ this.resizeHandle = 'top-right';
766
+ } else if (Math.abs(x - left) < controlPointSize && Math.abs(y - (top + height)) < controlPointSize) {
767
+ this.resizeHandle = 'bottom-left';
768
+ } else if (Math.abs(x - (left + width)) < controlPointSize && Math.abs(y - (top + height)) < controlPointSize) {
769
+ this.resizeHandle = 'bottom-right';
770
+ } else {
771
+ this.resizeHandle = null;
772
+ }
773
+ } else {
774
+ this.resizeHandle = null;
775
+ }
776
+ }
777
+ },
778
+ move(e) {
779
+ let touches = e.touches,
780
+ touch0 = touches[0],
781
+ touch1 = touches[1];
782
+
783
+ if( touch1 ) {
784
+ let x = touch1.x - touch0.x,
785
+ y = touch1.y - touch0.y,
786
+ fgDistance = Math.sqrt(x * x + y * y),
787
+ scaleSize = 0.005 * (fgDistance - this.fgDistance),
788
+ beScaleSize = this.scaleSize + scaleSize;
789
+
790
+ do {
791
+ if( !this.letScale ) break;
792
+ if( beScaleSize < this.mnScale) break;
793
+ if( beScaleSize > this.mxScale) break;
794
+ if(this.isin) {
795
+ let imgWidth = this.useWidth*beScaleSize,
796
+ imgHeight = this.useHeight*beScaleSize,
797
+ rx0 = this.posWidth+this.useWidth/2,
798
+ ry0 = this.posHeight+this.useHeight/2,
799
+ l = rx0-imgWidth/2, t = ry0-imgHeight/2,
800
+ r = l+imgWidth, b = t+imgHeight,
801
+ left = parseInt(this.selStyle.left),
802
+ top = parseInt(this.selStyle.top),
803
+ width = parseInt(this.selStyle.width),
804
+ height = parseInt(this.selStyle.height);
805
+ if(left < l || left+width > r || top < t || top+height > b) break;
806
+ this.scaleWidth = (this.useWidth-imgWidth)/2;
807
+ this.scaleHeight = (this.useHeight-imgHeight)/2;
808
+ }
809
+
810
+ this.scaleSize = beScaleSize;
811
+ } while(0);
812
+ this.fgDistance = fgDistance;
813
+
814
+ if(touch1.x !== touch0.x && this.letRotate) {
815
+ x = (this.touch1.y - this.touch0.y)/(this.touch1.x - this.touch0.x);
816
+ y = (touch1.y - touch0.y)/(touch1.x - touch0.x);
817
+ this.rotateDeg += Math.atan((y-x)/(1+x*y)) * 180/Math.PI;
818
+ this.touch0 = touch0;
819
+ this.touch1 = touch1;
820
+ }
821
+
822
+ this.drawImage();
823
+ } else if( this.touch0 ) {
824
+ // 只有在允许调整大小时才处理裁剪框大小调整
825
+ if (this.resizeHandle && this.letChangeSize) {
826
+ const style = {...this.selStyle};
827
+ const left = parseInt(style.left);
828
+ const top = parseInt(style.top);
829
+ const width = parseInt(style.width);
830
+ const height = parseInt(style.height);
831
+ const minWidth = 50;
832
+ const minHeight = 50;
833
+
834
+ switch (this.resizeHandle) {
835
+ case 'top-left':
836
+ style.left = touch0.x + 'px';
837
+ style.top = touch0.y + 'px';
838
+ style.width = (left + width - touch0.x) + 'px';
839
+ style.height = (top + height - touch0.y) + 'px';
840
+ break;
841
+ case 'top-right':
842
+ style.top = touch0.y + 'px';
843
+ style.width = (touch0.x - left) + 'px';
844
+ style.height = (top + height - touch0.y) + 'px';
845
+ break;
846
+ case 'bottom-left':
847
+ style.left = touch0.x + 'px';
848
+ style.width = (left + width - touch0.x) + 'px';
849
+ style.height = (touch0.y - top) + 'px';
850
+ break;
851
+ case 'bottom-right':
852
+ style.width = (touch0.x - left) + 'px';
853
+ style.height = (touch0.y - top) + 'px';
854
+ break;
855
+ }
856
+
857
+ // 确保最小尺寸
858
+ if (parseInt(style.width) >= minWidth && parseInt(style.height) >= minHeight) {
859
+ // 确保裁剪框不超出屏幕边界
860
+ if (parseInt(style.left) >= 0 &&
861
+ parseInt(style.top) >= 0 &&
862
+ (parseInt(style.left) + parseInt(style.width)) <= this.windowWidth &&
863
+ (parseInt(style.top) + parseInt(style.height)) <= (this.windowHeight - tabHeight)) {
864
+ this.selStyle = style;
865
+ // 重新绘制操作层
866
+ this.drawInit();
867
+ }
868
+ }
869
+ } else {
870
+ // 原有的移动图片逻辑
871
+ let x = touch0.x - this.touch0.x,
872
+ y = touch0.y - this.touch0.y,
873
+ beX = this.posWidth + x,
874
+ beY = this.posHeight + y;
875
+ if(this.isin) {
876
+ let imgWidth = this.useWidth*this.scaleSize,
877
+ imgHeight = this.useHeight*this.scaleSize,
878
+ rx0 = beX+this.useWidth/2,
879
+ ry0 = beY+this.useHeight/2,
880
+ l = rx0-imgWidth/2, t = ry0-imgHeight/2,
881
+ r = l+imgWidth, b = t+imgHeight,
882
+ left = parseInt(this.selStyle.left),
883
+ top = parseInt(this.selStyle.top),
884
+ width = parseInt(this.selStyle.width),
885
+ height = parseInt(this.selStyle.height);
886
+ if(!this.lckWidth && Math.abs(x) < 100) {
887
+ if(left >= l && left+width <= r) {
888
+ this.posWidth = beX;
889
+ } else if(left < l){
890
+ this.posWidth = left - this.scaleWidth;
891
+ } else if(left+width > r) {
892
+ this.posWidth = left-(imgWidth-width) - this.scaleWidth;
893
+ }
894
+ }
895
+ if(!this.lckHeight && Math.abs(y) < 100) {
896
+ if(top >= t && top+height <= b) {
897
+ this.posHeight = beY;
898
+ } else if(top < t) {
899
+ this.posHeight = top - this.scaleHeight;
900
+ } else if(top+height > b) {
901
+ this.posHeight = top-(imgHeight-height) - this.scaleHeight;
902
+ }
903
+ }
904
+ } else {
905
+ if( Math.abs(x) < 100 && !this.lckWidth) this.posWidth = beX;
906
+ if( Math.abs(y) < 100 && !this.lckHeight) this.posHeight = beY;
907
+ }
908
+
909
+ this.touch0 = touch0;
910
+ this.drawImage();
911
+ }
912
+ }
913
+ },
914
+ end(e) {
915
+ let touches = e.touches,
916
+ touch0 = touches && touches[0],
917
+ touch1 = touches && touches[1];
918
+ if(touch0) {
919
+ this.touch0 = touch0;
920
+ } else {
921
+ this.touch0 = null;
922
+ this.touch1 = null;
923
+ this.resizeHandle = null; // 重置调整手柄
924
+ }
925
+ },
926
+ getImgData() {
927
+ return new Promise((resolve, reject)=>{
928
+ let prvX = this.prvX,
929
+ prvY = this.prvY,
930
+ prvWidth = this.prvWidth,
931
+ prvHeight = this.prvHeight;
932
+ // #ifdef APP-PLUS||H5
933
+ prvX *= this.pixelRatio;
934
+ prvY *= this.pixelRatio;
935
+ prvWidth *= this.pixelRatio;
936
+ prvHeight *= this.pixelRatio;
937
+ // #endif
938
+ uni.canvasGetImageData({
939
+ canvasId: 'prv-canvas',
940
+ x: prvX,
941
+ y: prvY,
942
+ width: prvWidth,
943
+ height: prvHeight,
944
+ success(res) {
945
+ resolve(res.data);
946
+ },
947
+ fail(err) {
948
+ reject(err);
949
+ }
950
+ }, this);
951
+ });
952
+ },
953
+ async colorChange(e) {
954
+ let tm_now = Date.now();
955
+ if(tm_now - this.prvTm < 100) return;
956
+ this.prvTm = tm_now;
957
+
958
+ uni.showLoading({ mask: true });
959
+
960
+ if( !this.prvImgData ) {
961
+ if( !(this.prvImgData = await this.getImgData().catch((res)=>{
962
+ uni.showToast({
963
+ title: "error_read",
964
+ duration: 2000,
965
+ })
966
+ }))) return;
967
+ this.target = new Uint8ClampedArray(this.prvImgData.length);
968
+ }
969
+
970
+ let data = this.prvImgData,
971
+ target = this.target,
972
+ i = e.detail.value,
973
+ r,g,b,a,h,s,l,d,p,q,t,min,max,hK,tR,tG,tB;
974
+
975
+ if( i === 0 ) {
976
+ target = data;
977
+ } else {
978
+ i = (i+100)/200;
979
+ if( i < 0.005 ) i = 0;
980
+ if( i > 0.995 ) i = 1;
981
+ for( let n = data.length-1; n >= 0; n-=4 ) {
982
+ r = data[n-3] / 255;
983
+ g = data[n-2] / 255;
984
+ b = data[n-1] / 255;
985
+ max = Math.max(r,g,b);
986
+ min = Math.min(r,g,b);
987
+ d = max-min;
988
+ if ( max === min ){
989
+ h = 0 ;
990
+ }else if( max === r && g>=b ){
991
+ h = 60*( (g-b)/d ) ;
992
+ }else if( max === r && g<b ){
993
+ h = 60*( (g-b)/d ) + 360 ;
994
+ }else if( max === g ){
995
+ h = 60*( (b-r)/d ) + 120 ;
996
+ }else if( max === b ){
997
+ h = 60*( (r-g)/d ) + 240 ;
998
+ }
999
+ l = (max+min)/2 ;
1000
+ if ( l===0 || max===min ){
1001
+ s = 0 ;
1002
+ }else if( 0<l && l<=0.5 ){
1003
+ s = d/(2*l) ;
1004
+ }else if( l>0.5 ){
1005
+ s = d/(2-2*l) ;
1006
+ }
1007
+ data[n] && (a = data[n]);
1008
+
1009
+ if ( i < 0.5 ){
1010
+ s = s*i/0.5 ;
1011
+ }else if ( i > 0.5 ){
1012
+ s = 2*s + 2*i - (s*i/0.5) - 1 ;
1013
+ }
1014
+
1015
+ if ( s === 0 ){
1016
+ r = g = b = Math.round( l*255 ) ;
1017
+ }else{
1018
+ if ( l<0.5 ){
1019
+ q = l * ( 1 + s ) ;
1020
+ }else if( l>=0.5 ){
1021
+ q = l + s - ( l * s ) ;
1022
+ }
1023
+ p = 2*l-q ;
1024
+ hK = h/360 ;
1025
+ tR = hK + 1/3 ;
1026
+ tG = hK ;
1027
+ tB = hK - 1/3 ;
1028
+ let correctRGB = (t)=>{
1029
+ if( t<0 ){
1030
+ return t + 1.0 ;
1031
+ }
1032
+ if( t>1 ){
1033
+ return t - 1.0 ;
1034
+ }
1035
+ return t ;
1036
+ } ;
1037
+ let createRGB = (t)=>{
1038
+ if ( t<(1/6) ){
1039
+ return p+((q-p)*6*t) ;
1040
+ }else if( t>=(1/6) && t<(1/2) ){
1041
+ return q ;
1042
+ }else if( t>=(1/2) && t<(2/3) ){
1043
+ return p+((q-p)*6*((2/3)-t)) ;
1044
+ }
1045
+ return p ;
1046
+ } ;
1047
+ r = tR = Math.round( createRGB( correctRGB( tR ) )*255 ) ;
1048
+ g = tG = Math.round( createRGB( correctRGB( tG ) )*255 ) ;
1049
+ b = tB = Math.round( createRGB( correctRGB( tB ) )*255 ) ;
1050
+ }
1051
+ a && ( target[n] = a ) ;
1052
+ target[n-3] = r;
1053
+ target[n-2] = g;
1054
+ target[n-1] = b;
1055
+ }
1056
+ }
1057
+ let prvX = this.prvX,
1058
+ prvY = this.prvY,
1059
+ prvWidth = this.prvWidth,
1060
+ prvHeight = this.prvHeight;
1061
+
1062
+ this.ctxCanvasPrv.setFillStyle('black');
1063
+ this.ctxCanvasPrv.fillRect(prvX, prvY, prvWidth, prvHeight);
1064
+ this.ctxCanvasPrv.draw(true);
1065
+
1066
+ // #ifdef APP-PLUS||H5
1067
+ prvX *= this.pixelRatio;
1068
+ prvY *= this.pixelRatio;
1069
+ prvWidth *= this.pixelRatio;
1070
+ prvHeight *= this.pixelRatio;
1071
+ // #endif
1072
+ uni.canvasPutImageData({
1073
+ canvasId: 'prv-canvas',
1074
+ x: prvX,
1075
+ y: prvY,
1076
+ width: prvWidth,
1077
+ height: prvHeight,
1078
+ data: target,
1079
+ fail() {
1080
+ uni.showToast({
1081
+ title: 'error_put',
1082
+ duration: 2000
1083
+ })
1084
+ },
1085
+ complete() {
1086
+ uni.hideLoading();
1087
+ }
1088
+ }, this);
1089
+ },
1090
+ btop(base64) {
1091
+ return new Promise(function(resolve, reject) {
1092
+ var arr = base64.split(','),
1093
+ mime = arr[0].match(/:(.*?);/)[1],
1094
+ bstr = atob(arr[1]),
1095
+ n = bstr.length,
1096
+ u8arr = new Uint8Array(n);
1097
+ while (n--) {
1098
+ u8arr[n] = bstr.charCodeAt(n);
1099
+ }
1100
+ return resolve((window.URL || window.webkitURL).createObjectURL(new Blob([u8arr], { type: mime })));
1101
+ });
1102
+ },
1103
+ }
1104
+ }
1105
+ </script>
1106
+
1107
+ <style>
1108
+ .my-canvas{
1109
+ display: flex;
1110
+ position: fixed !important;
1111
+ background: #000000;
1112
+ left: 0;
1113
+ z-index: 100000;
1114
+ width: 100%;
1115
+ }
1116
+ .my-avatar {
1117
+ width: 150rpx;
1118
+ height: 150rpx;
1119
+ border-radius: 100%;
1120
+ }
1121
+ .oper-canvas {
1122
+ display: flex;
1123
+ position: fixed !important;
1124
+ left: 0;
1125
+ z-index: 100001;
1126
+ width: 100%;
1127
+ }
1128
+ .prv-canvas {
1129
+ display: flex;
1130
+ position: fixed !important;
1131
+ background: #000000;
1132
+ left: 0;
1133
+ z-index: 200000;
1134
+ width: 100%;
1135
+ }
1136
+ .oper-wrapper {
1137
+ height: 50px;
1138
+ position: fixed !important;
1139
+ box-sizing: border-box;
1140
+ border: 1px solid #F1F1F1;
1141
+ background: #ffffff;
1142
+ width: 100%;
1143
+ left: 0;
1144
+ bottom: 0;
1145
+ z-index: 100009;
1146
+ flex-direction: row;
1147
+ }
1148
+ .oper {
1149
+ display: flex;
1150
+ flex-direction: column;
1151
+ justify-content: center;
1152
+ padding: 10rpx 20rpx;
1153
+ width: 100%;
1154
+ height: 100%;
1155
+ box-sizing: border-box;
1156
+ align-self: center;
1157
+ }
1158
+ .btn-wrapper {
1159
+ display: flex;
1160
+ flex-direction: row;
1161
+ /* #ifndef H5 */
1162
+ flex-grow: 1;
1163
+ /* #endif */
1164
+ /* #ifdef H5 */
1165
+ height: 50px;
1166
+ /* #endif */
1167
+ justify-content: space-between;
1168
+ }
1169
+ .btn-wrapper view {
1170
+ display: flex;
1171
+ align-items: center;
1172
+ justify-content: center;
1173
+ font-size: 16px;
1174
+ color: #333;
1175
+ border: 1px solid #f1f1f1;
1176
+ border-radius: 6%;
1177
+ }
1178
+ .hover {
1179
+ background: #f1f1f1;
1180
+ border-radius: 6%;
1181
+ }
1182
+ .clr-wrapper {
1183
+ display: flex;
1184
+ flex-direction: row;
1185
+ flex-grow: 1;
1186
+ }
1187
+ .clr-wrapper view {
1188
+ display: flex;
1189
+ align-items: center;
1190
+ justify-content: center;
1191
+ font-size: 16px;
1192
+ color: #333;
1193
+ border: 1px solid #f1f1f1;
1194
+ border-radius: 6%;
1195
+ }
1196
+ .my-slider {
1197
+ flex-grow: 1;
1198
+ }
1199
+ </style>
@@ -161,7 +161,7 @@
161
161
  $u-icon-error: $u-error !default;
162
162
  $u-icon-label-line-height:1 !default;
163
163
 
164
- /* #ifdef MP-QQ || MP-TOUTIAO || MP-BAIDU || MP-KUAISHOU || MP-XHS */
164
+ /* #ifdef APP || MP-QQ || MP-TOUTIAO || MP-BAIDU || MP-KUAISHOU || MP-XHS */
165
165
  // 2025/04/09在App/微信/支付宝/鸿蒙元服务已改用uni.loadFontFace加载字体
166
166
  @font-face {
167
167
  font-family: 'uicon-iconfont';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙跨端移动组件库,组件丰富维护更新稳定。",
5
- "version": "3.4.83",
5
+ "version": "3.4.84",
6
6
  "description": "零云®uview-plus已兼容vue3,100+全面的组件和便捷的工具会让您信手拈来,如鱼得水。",
7
7
  "keywords": [
8
8
  "uview",