xydata-tools 1.0.48 → 1.0.49
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/README.md +12 -18
- package/dist/components/both/security-layout/index.js +0 -3
- package/dist/components/uni-app/media-picker/media-picker.vue +119 -5
- package/dist/components/uni-app/media-picker/shmily-drag-media.vue +821 -853
- package/dist/components/uploadFile/index.js +2 -1
- package/package.json +7 -2
|
@@ -1,853 +1,821 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="con">
|
|
3
|
-
<template v-if="viewWidth">
|
|
4
|
-
<movable-area class="area" :style="{ height: areaHeight }" @mouseenter="mouseenter"
|
|
5
|
-
@mouseleave="mouseleave">
|
|
6
|
-
<movable-view v-for="(item, index) in imageList" :key="item.id" class="view" direction="all" :y="item.y"
|
|
7
|
-
:x="item.x" :damping="40" :disabled="!draggable" @change="onChange($event, item)"
|
|
8
|
-
@touchstart="touchstart(item)" @mousedown="touchstart(item)" @touchend="touchend($event, item)"
|
|
9
|
-
@
|
|
10
|
-
width: viewWidth + 'px',
|
|
11
|
-
height: viewWidth + 'px',
|
|
12
|
-
'z-index': item.zIndex,
|
|
13
|
-
opacity: item.opacity
|
|
14
|
-
}">
|
|
15
|
-
<view class="area-con" :style="{
|
|
16
|
-
width: childWidth,
|
|
17
|
-
height: childWidth,
|
|
18
|
-
borderRadius: borderRadius + 'rpx',
|
|
19
|
-
transform: 'scale(' + item.scale + ')'
|
|
20
|
-
}">
|
|
21
|
-
<image v-if="moveType === 'image'" class="pre-image" :src="item.src" mode="aspectFill"
|
|
22
|
-
@load="handleMediaLoad(item)" @error="handleMediaError(item)"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
type:
|
|
120
|
-
default:
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (this.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
this.
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return
|
|
295
|
-
},
|
|
296
|
-
|
|
297
|
-
if (!
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}
|
|
509
|
-
//#endif
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
this.
|
|
553
|
-
|
|
554
|
-
//
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
} else {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
this
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
this.
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
.add {
|
|
829
|
-
position: absolute;
|
|
830
|
-
display: flex;
|
|
831
|
-
justify-content: center;
|
|
832
|
-
align-items: center;
|
|
833
|
-
|
|
834
|
-
.add-wrap {
|
|
835
|
-
display: flex;
|
|
836
|
-
justify-content: center;
|
|
837
|
-
align-items: center;
|
|
838
|
-
background-color: #eeeeee;
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
@keyframes spinner-rotate {
|
|
845
|
-
0% {
|
|
846
|
-
transform: rotate(0deg);
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
100% {
|
|
850
|
-
transform: rotate(360deg);
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view class="con">
|
|
3
|
+
<template v-if="viewWidth">
|
|
4
|
+
<movable-area class="area" :style="{ height: areaHeight }" @mouseenter="mouseenter"
|
|
5
|
+
@mouseleave="mouseleave">
|
|
6
|
+
<movable-view v-for="(item, index) in imageList" :key="item.id" class="view" direction="all" :y="item.y"
|
|
7
|
+
:x="item.x" :damping="40" :disabled="!draggable" @change="onChange($event, item)"
|
|
8
|
+
@touchstart="touchstart(item)" @mousedown="touchstart(item)" @touchend="touchend($event, item)"
|
|
9
|
+
@mouseup="touchend($event, item)" :style="{
|
|
10
|
+
width: viewWidth + 'px',
|
|
11
|
+
height: viewWidth + 'px',
|
|
12
|
+
'z-index': item.zIndex,
|
|
13
|
+
opacity: item.opacity
|
|
14
|
+
}">
|
|
15
|
+
<view class="area-con" :style="{
|
|
16
|
+
width: childWidth,
|
|
17
|
+
height: childWidth,
|
|
18
|
+
borderRadius: borderRadius + 'rpx',
|
|
19
|
+
transform: 'scale(' + item.scale + ')'
|
|
20
|
+
}">
|
|
21
|
+
<image v-if="moveType === 'image'" class="pre-image" :src="item.src" mode="aspectFill"
|
|
22
|
+
@load="handleMediaLoad(item)" @error="handleMediaError(item)"
|
|
23
|
+
@click="handleClick(item, 'image')"></image>
|
|
24
|
+
<video v-else-if="moveType === 'video'" :id="'readonlyVideo' + index" class="myVideo"
|
|
25
|
+
:src="item.src" :controls="false" :show-center-play-btn="true" object-fit="cover"
|
|
26
|
+
@loadedmetadata="handleMediaLoad(item)" @error="handleMediaError(item)"
|
|
27
|
+
@click="handleClick(item, 'video')"></video>
|
|
28
|
+
<view class="media-loading-overlay" v-if="item.loading">
|
|
29
|
+
<view class="loading-spinner"></view>
|
|
30
|
+
</view>
|
|
31
|
+
<view class="del-con" @click="delImages(item, index)"
|
|
32
|
+
@touchstart.stop="delImageMp(item, index)" @touchend.stop="nothing()"
|
|
33
|
+
@mousedown.stop="nothing()" @mouseup.stop="nothing()">
|
|
34
|
+
<view class="del-wrap">
|
|
35
|
+
<image class="del-image"
|
|
36
|
+
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAhCAYAAABX5MJvAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAhdEVYdENyZWF0aW9uIFRpbWUAMjAyMDowNzoyNSAyMTo1NDoyOU4TkJAAAADcSURBVFhH7ZfRCoMwDEXLvkjwwVf/bH/emmAyN6glTW9WBjsgwm28OeCLpj81Sil7zvlJ90UiONS/yY5VogsO6XrBg3IEQ5a/s8vRSWUAKmLqp2w5jz5BiNQEGMo3GbloDLtFXJ1IkaEuhAiiY6gEIqB4yqACSk9piIBiKQ8VUFpLviKg3C2rESKgWERCBZSWiEfgIfffYvrrsAgoISJ3Apy3zuTxcSxLQkV6ykNEPKVQkZEyiAiiZKgDIaC4upACSlcn5fM/+WuDCAHF1E/Z/N9AhkMZnPNDPI+UDjPIXgAQIGjNAAAAAElFTkSuQmCC">
|
|
37
|
+
</image>
|
|
38
|
+
</view>
|
|
39
|
+
</view>
|
|
40
|
+
</view>
|
|
41
|
+
</movable-view>
|
|
42
|
+
<!-- 添加按钮或自定义插槽 -->
|
|
43
|
+
<view class="add" v-if="imageList.length < number && showAddButton"
|
|
44
|
+
:style="{ top: add.y, left: add.x, width: viewWidth + 'px', height: viewWidth + 'px' }">
|
|
45
|
+
<view class="add-wrap"
|
|
46
|
+
:style="{ width: childWidth, height: childWidth, borderRadius: borderRadius + 'rpx' }">
|
|
47
|
+
<slot name="add-button" :childWidth="childWidth" :borderRadius="borderRadius"></slot>
|
|
48
|
+
</view>
|
|
49
|
+
</view>
|
|
50
|
+
</movable-area>
|
|
51
|
+
|
|
52
|
+
</template>
|
|
53
|
+
</view>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script>
|
|
57
|
+
export default {
|
|
58
|
+
emits: ['input', 'add-click'],
|
|
59
|
+
props: {
|
|
60
|
+
// 排序图片
|
|
61
|
+
value: {
|
|
62
|
+
type: Array,
|
|
63
|
+
default: function () {
|
|
64
|
+
return []
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
// 从 list 元素对象中读取的键名
|
|
68
|
+
keyName: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: null
|
|
71
|
+
},
|
|
72
|
+
// 选择图片数量限制
|
|
73
|
+
number: {
|
|
74
|
+
type: Number,
|
|
75
|
+
default: 6
|
|
76
|
+
},
|
|
77
|
+
// 图片父容器宽度(实际显示的图片宽度为 imageWidth / 1.1 ),单位 rpx
|
|
78
|
+
// imageWidth > 0 则 cols 无效
|
|
79
|
+
imageWidth: {
|
|
80
|
+
type: Number,
|
|
81
|
+
default: 0
|
|
82
|
+
},
|
|
83
|
+
// 图片列数
|
|
84
|
+
cols: {
|
|
85
|
+
type: Number,
|
|
86
|
+
default: 3
|
|
87
|
+
},
|
|
88
|
+
// 图片圆角,单位 rpx
|
|
89
|
+
borderRadius: {
|
|
90
|
+
type: Number,
|
|
91
|
+
default: 8
|
|
92
|
+
},
|
|
93
|
+
// 图片周围空白填充,单位 rpx
|
|
94
|
+
padding: {
|
|
95
|
+
type: Number,
|
|
96
|
+
default: 10
|
|
97
|
+
},
|
|
98
|
+
// 拖动图片时放大倍数 [0, ∞)
|
|
99
|
+
scale: {
|
|
100
|
+
type: Number,
|
|
101
|
+
default: 1.1
|
|
102
|
+
},
|
|
103
|
+
// 拖动图片时不透明度
|
|
104
|
+
opacity: {
|
|
105
|
+
type: Number,
|
|
106
|
+
default: 0.7
|
|
107
|
+
},
|
|
108
|
+
// 自定义添加
|
|
109
|
+
addImage: {
|
|
110
|
+
type: Function,
|
|
111
|
+
default: null
|
|
112
|
+
},
|
|
113
|
+
// 删除确认
|
|
114
|
+
delImage: {
|
|
115
|
+
type: Function,
|
|
116
|
+
default: null
|
|
117
|
+
},
|
|
118
|
+
moveType: {
|
|
119
|
+
type: String,
|
|
120
|
+
default: 'image', // 'image' 或 'video'
|
|
121
|
+
},
|
|
122
|
+
// 是否启用添加按钮功能(由父组件控制是否需要添加按钮功能)
|
|
123
|
+
enableAddButton: {
|
|
124
|
+
type: Boolean,
|
|
125
|
+
default: false
|
|
126
|
+
},
|
|
127
|
+
// 对齐方式:'left' 从左往右排列,'right' 从右往左排列
|
|
128
|
+
align: {
|
|
129
|
+
type: String,
|
|
130
|
+
default: 'left',
|
|
131
|
+
validator: (value) => ['left', 'right'].includes(value)
|
|
132
|
+
},
|
|
133
|
+
// 是否可以拖拽排序
|
|
134
|
+
draggable: {
|
|
135
|
+
type: Boolean,
|
|
136
|
+
default: true
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
data() {
|
|
140
|
+
return {
|
|
141
|
+
imageList: [],
|
|
142
|
+
width: 0,
|
|
143
|
+
containerWidth: 0,
|
|
144
|
+
add: {
|
|
145
|
+
x: 0,
|
|
146
|
+
y: 0
|
|
147
|
+
},
|
|
148
|
+
colsValue: 0,
|
|
149
|
+
viewWidth: 0,
|
|
150
|
+
rightAlignOffset: 0,
|
|
151
|
+
tempItem: null,
|
|
152
|
+
timer: null,
|
|
153
|
+
changeStatus: true,
|
|
154
|
+
preStatus: true,
|
|
155
|
+
first: true,
|
|
156
|
+
lastTouchEndTime: null, // 记录最后一次 touchend 的时间,用于避免重复触发
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
computed: {
|
|
160
|
+
// 是否显示添加按钮(内部自动判断)
|
|
161
|
+
showAddButton() {
|
|
162
|
+
return this.enableAddButton && this.imageList.length < this.number
|
|
163
|
+
},
|
|
164
|
+
areaHeight() {
|
|
165
|
+
let height = ''
|
|
166
|
+
let totalCount = this.imageList.length
|
|
167
|
+
|
|
168
|
+
// 如果显示添加按钮,需要为按钮预留空间
|
|
169
|
+
if (this.showAddButton) {
|
|
170
|
+
totalCount = this.imageList.length + 1
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 至少显示一行
|
|
174
|
+
const rows = Math.max(1, Math.ceil(totalCount / this.colsValue))
|
|
175
|
+
height = (rows * this.viewWidth).toFixed() + 'px'
|
|
176
|
+
return height
|
|
177
|
+
},
|
|
178
|
+
childWidth() {
|
|
179
|
+
return this.viewWidth - this.rpx2px(this.padding) * 2 + 'px'
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
watch: {
|
|
183
|
+
value: {
|
|
184
|
+
handler(n) {
|
|
185
|
+
if (!this.first && this.changeStatus) {
|
|
186
|
+
let flag = false
|
|
187
|
+
for (let i = 0; i < n.length; i++) {
|
|
188
|
+
if (flag) {
|
|
189
|
+
this.addProperties(this.getSrc(n[i]))
|
|
190
|
+
continue
|
|
191
|
+
}
|
|
192
|
+
if (this.imageList.length === i || this.imageList[i].src !== this.getSrc(n[i])) {
|
|
193
|
+
flag = true
|
|
194
|
+
this.imageList.splice(i)
|
|
195
|
+
this.addProperties(this.getSrc(n[i]))
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
deep: true
|
|
201
|
+
},
|
|
202
|
+
align() {
|
|
203
|
+
this.updateRightAlignOffset()
|
|
204
|
+
if (!this.viewWidth || !this.colsValue) {
|
|
205
|
+
return
|
|
206
|
+
}
|
|
207
|
+
this.recalculateAllPositions()
|
|
208
|
+
this.updateAddButtonPosition()
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
created() {
|
|
212
|
+
this.width = uni.getSystemInfoSync().windowWidth
|
|
213
|
+
},
|
|
214
|
+
mounted() {
|
|
215
|
+
const query = uni.createSelectorQuery().in(this)
|
|
216
|
+
query.select('.con').boundingClientRect(data => {
|
|
217
|
+
this.containerWidth = data.width
|
|
218
|
+
this.colsValue = this.cols
|
|
219
|
+
this.viewWidth = data.width / this.cols
|
|
220
|
+
if (this.imageWidth > 0) {
|
|
221
|
+
this.viewWidth = this.rpx2px(this.imageWidth)
|
|
222
|
+
this.colsValue = Math.floor(data.width / this.viewWidth)
|
|
223
|
+
}
|
|
224
|
+
if (this.colsValue < 1) {
|
|
225
|
+
this.colsValue = 1
|
|
226
|
+
}
|
|
227
|
+
this.updateRightAlignOffset()
|
|
228
|
+
for (let item of this.value) {
|
|
229
|
+
this.addProperties(this.getSrc(item))
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
this.first = false
|
|
233
|
+
|
|
234
|
+
})
|
|
235
|
+
query.exec()
|
|
236
|
+
},
|
|
237
|
+
methods: {
|
|
238
|
+
/**
|
|
239
|
+
* 根据索引和总数计算绝对位置(支持左右对齐)
|
|
240
|
+
* @param {Number} index - 当前图片索引
|
|
241
|
+
* @param {Number} total - 图片总数(如果显示添加按钮,需要包括按钮)
|
|
242
|
+
* @returns {Object} { absX, absY }
|
|
243
|
+
*/
|
|
244
|
+
calculatePosition(index, total) {
|
|
245
|
+
const absY = Math.floor(index / this.colsValue)
|
|
246
|
+
|
|
247
|
+
if (this.align === 'right') {
|
|
248
|
+
// 靠右对齐:计算当前行的元素数量(包括按钮),然后从右往左排列
|
|
249
|
+
const currentRowItemCount = Math.min(total - absY * this.colsValue, this.colsValue)
|
|
250
|
+
const startX = this.colsValue - currentRowItemCount
|
|
251
|
+
const positionInRow = index % this.colsValue
|
|
252
|
+
const absX = startX + positionInRow
|
|
253
|
+
return { absX, absY }
|
|
254
|
+
} else {
|
|
255
|
+
// 靠左对齐(默认)
|
|
256
|
+
const absX = index % this.colsValue
|
|
257
|
+
return { absX, absY }
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
getRightOffset() {
|
|
261
|
+
return this.align === 'right' ? this.rightAlignOffset : 0
|
|
262
|
+
},
|
|
263
|
+
getAlignedX(absX) {
|
|
264
|
+
return this.getRightOffset() + absX * this.viewWidth
|
|
265
|
+
},
|
|
266
|
+
updateRightAlignOffset() {
|
|
267
|
+
if (!this.viewWidth || !this.colsValue || !this.containerWidth) {
|
|
268
|
+
this.rightAlignOffset = 0
|
|
269
|
+
return
|
|
270
|
+
}
|
|
271
|
+
if (this.align !== 'right') {
|
|
272
|
+
this.rightAlignOffset = 0
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
const theoreticalWidth = this.viewWidth * this.colsValue
|
|
276
|
+
this.rightAlignOffset = Math.max(0, this.containerWidth - theoreticalWidth)
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 获取总数(如果显示添加按钮,则包括按钮)
|
|
281
|
+
*/
|
|
282
|
+
getTotalCount() {
|
|
283
|
+
// 如果是右对齐且显示添加按钮,则总数需要包括按钮
|
|
284
|
+
if (this.align === 'right' && this.showAddButton) {
|
|
285
|
+
return this.imageList.length + 1
|
|
286
|
+
}
|
|
287
|
+
return this.imageList.length
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
getSrc(item) {
|
|
291
|
+
if (this.keyName !== null) {
|
|
292
|
+
return item[this.keyName]
|
|
293
|
+
}
|
|
294
|
+
return item
|
|
295
|
+
},
|
|
296
|
+
onChange(e, item) {
|
|
297
|
+
if (!item) return
|
|
298
|
+
item.oldX = e.detail.x
|
|
299
|
+
item.oldY = e.detail.y
|
|
300
|
+
if (e.detail.source === 'touch') {
|
|
301
|
+
if (item.moveEnd) {
|
|
302
|
+
item.offset = Math.sqrt(Math.pow(item.oldX - this.getAlignedX(item.absX), 2) + Math.pow(item.oldY - item
|
|
303
|
+
.absY * this.viewWidth, 2))
|
|
304
|
+
}
|
|
305
|
+
const offsetX = this.getRightOffset()
|
|
306
|
+
let x = Math.floor((e.detail.x - offsetX + this.viewWidth / 2) / this.viewWidth)
|
|
307
|
+
if (x < 0) {
|
|
308
|
+
x = 0
|
|
309
|
+
}
|
|
310
|
+
if (x >= this.colsValue) return
|
|
311
|
+
let y = Math.floor((e.detail.y + this.viewWidth / 2) / this.viewWidth)
|
|
312
|
+
let index = this.colsValue * y + x
|
|
313
|
+
if (item.index != index && index < this.imageList.length) {
|
|
314
|
+
this.changeStatus = false
|
|
315
|
+
for (let obj of this.imageList) {
|
|
316
|
+
if (item.index > index && obj.index >= index && obj.index < item.index) {
|
|
317
|
+
this.change(obj, 1)
|
|
318
|
+
} else if (item.index < index && obj.index <= index && obj.index > item.index) {
|
|
319
|
+
this.change(obj, -1)
|
|
320
|
+
} else if (obj.id != item.id) {
|
|
321
|
+
obj.offset = 0
|
|
322
|
+
obj.x = obj.oldX
|
|
323
|
+
obj.y = obj.oldY
|
|
324
|
+
setTimeout(() => {
|
|
325
|
+
this.$nextTick(() => {
|
|
326
|
+
obj.x = this.getAlignedX(obj.absX)
|
|
327
|
+
obj.y = obj.absY * this.viewWidth
|
|
328
|
+
obj.oldX = obj.x
|
|
329
|
+
obj.oldY = obj.y
|
|
330
|
+
})
|
|
331
|
+
}, 0)
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
item.index = index
|
|
335
|
+
const totalWithButton = this.getTotalCount()
|
|
336
|
+
const pos = this.calculatePosition(index, totalWithButton)
|
|
337
|
+
item.absX = pos.absX
|
|
338
|
+
item.absY = pos.absY
|
|
339
|
+
if (!item.moveEnd) {
|
|
340
|
+
setTimeout(() => {
|
|
341
|
+
this.$nextTick(() => {
|
|
342
|
+
item.x = this.getAlignedX(item.absX)
|
|
343
|
+
item.y = item.absY * this.viewWidth
|
|
344
|
+
item.oldX = item.x
|
|
345
|
+
item.oldY = item.y
|
|
346
|
+
})
|
|
347
|
+
}, 0)
|
|
348
|
+
}
|
|
349
|
+
this.sortList()
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
change(obj, i) {
|
|
354
|
+
obj.index += i
|
|
355
|
+
obj.offset = 0
|
|
356
|
+
obj.x = obj.oldX
|
|
357
|
+
obj.y = obj.oldY
|
|
358
|
+
const totalWithButton = this.getTotalCount()
|
|
359
|
+
const pos = this.calculatePosition(obj.index, totalWithButton)
|
|
360
|
+
obj.absX = pos.absX
|
|
361
|
+
obj.absY = pos.absY
|
|
362
|
+
setTimeout(() => {
|
|
363
|
+
this.$nextTick(() => {
|
|
364
|
+
obj.x = this.getAlignedX(obj.absX)
|
|
365
|
+
obj.y = obj.absY * this.viewWidth
|
|
366
|
+
obj.oldX = obj.x
|
|
367
|
+
obj.oldY = obj.y
|
|
368
|
+
})
|
|
369
|
+
}, 0)
|
|
370
|
+
},
|
|
371
|
+
touchstart(item) {
|
|
372
|
+
// 如果不允许拖拽,则不执行任何操作
|
|
373
|
+
if (!this.draggable) {
|
|
374
|
+
return
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
this.imageList.forEach(v => {
|
|
378
|
+
v.zIndex = v.index + 9
|
|
379
|
+
})
|
|
380
|
+
item.zIndex = 99
|
|
381
|
+
item.moveEnd = true
|
|
382
|
+
this.tempItem = item
|
|
383
|
+
this.timer = setTimeout(() => {
|
|
384
|
+
item.scale = this.scale
|
|
385
|
+
item.opacity = this.opacity
|
|
386
|
+
clearTimeout(this.timer)
|
|
387
|
+
this.timer = null
|
|
388
|
+
}, 200)
|
|
389
|
+
},
|
|
390
|
+
handleClick(item, type) {
|
|
391
|
+
// 设为disable后无法触发touch事件
|
|
392
|
+
if (!this.draggable) {
|
|
393
|
+
if (type === 'video') {
|
|
394
|
+
this.playVideo(item)
|
|
395
|
+
} else {
|
|
396
|
+
this.previewImage(item)
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
touchend(event, item) {
|
|
401
|
+
const eventType = event.type // 'touchend' 或 'mouseup'
|
|
402
|
+
|
|
403
|
+
// 如果是触摸事件,标记时间戳,避免后续的 mouseup 重复触发
|
|
404
|
+
if (eventType === 'touchend') {
|
|
405
|
+
this.lastTouchEndTime = Date.now()
|
|
406
|
+
} else if (eventType === 'mouseup') {
|
|
407
|
+
// 如果 100ms 内已经处理过 touchend,则忽略此 mouseup(避免重复)
|
|
408
|
+
if (this.lastTouchEndTime && Date.now() - this.lastTouchEndTime < 100) {
|
|
409
|
+
if (this.timer) {
|
|
410
|
+
clearTimeout(this.timer)
|
|
411
|
+
this.timer = null
|
|
412
|
+
}
|
|
413
|
+
// 确保 scale 恢复为 1
|
|
414
|
+
item.scale = 1
|
|
415
|
+
item.opacity = 1
|
|
416
|
+
return
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// 判断是否为点击操作(而非拖动)
|
|
421
|
+
if (this.timer && this.preStatus && this.changeStatus && item.offset < 28.28) {
|
|
422
|
+
if (this.moveType === 'video') {
|
|
423
|
+
this.playVideo(item)
|
|
424
|
+
} else {
|
|
425
|
+
this.previewImage(item)
|
|
426
|
+
}
|
|
427
|
+
} else if (this.timer) {
|
|
428
|
+
clearTimeout(this.timer)
|
|
429
|
+
this.timer = null
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
item.scale = 1
|
|
433
|
+
item.opacity = 1
|
|
434
|
+
item.x = item.oldX
|
|
435
|
+
item.y = item.oldY
|
|
436
|
+
item.offset = 0
|
|
437
|
+
item.moveEnd = false
|
|
438
|
+
setTimeout(() => {
|
|
439
|
+
this.$nextTick(() => {
|
|
440
|
+
item.x = this.getAlignedX(item.absX)
|
|
441
|
+
item.y = item.absY * this.viewWidth
|
|
442
|
+
item.oldX = item.x
|
|
443
|
+
item.oldY = item.y
|
|
444
|
+
this.tempItem = null
|
|
445
|
+
this.changeStatus = true
|
|
446
|
+
})
|
|
447
|
+
}, 0)
|
|
448
|
+
},
|
|
449
|
+
playVideo(item) {
|
|
450
|
+
clearTimeout(this.timer)
|
|
451
|
+
this.timer = null
|
|
452
|
+
this.$emit('videoClick', item)
|
|
453
|
+
|
|
454
|
+
},
|
|
455
|
+
previewImage(item) {
|
|
456
|
+
clearTimeout(this.timer)
|
|
457
|
+
this.timer = null
|
|
458
|
+
let srcList = this.value.map(v => this.getSrc(v))
|
|
459
|
+
uni.previewImage({
|
|
460
|
+
urls: srcList,
|
|
461
|
+
current: item.src,
|
|
462
|
+
success: () => {
|
|
463
|
+
this.preStatus = false
|
|
464
|
+
setTimeout(() => {
|
|
465
|
+
this.preStatus = true
|
|
466
|
+
}, 600)
|
|
467
|
+
},
|
|
468
|
+
fail: (e) => {
|
|
469
|
+
console.log(e);
|
|
470
|
+
}
|
|
471
|
+
})
|
|
472
|
+
},
|
|
473
|
+
mouseenter() {
|
|
474
|
+
//#ifdef H5
|
|
475
|
+
this.imageList.forEach(v => {
|
|
476
|
+
v.disable = false
|
|
477
|
+
})
|
|
478
|
+
//#endif
|
|
479
|
+
|
|
480
|
+
},
|
|
481
|
+
mouseleave() {
|
|
482
|
+
//#ifdef H5
|
|
483
|
+
if (this.tempItem) {
|
|
484
|
+
this.imageList.forEach(v => {
|
|
485
|
+
v.disable = true
|
|
486
|
+
v.zIndex = v.index + 9
|
|
487
|
+
v.offset = 0
|
|
488
|
+
v.moveEnd = false
|
|
489
|
+
if (v.id == this.tempItem.id) {
|
|
490
|
+
if (this.timer) {
|
|
491
|
+
clearTimeout(this.timer)
|
|
492
|
+
this.timer = null
|
|
493
|
+
}
|
|
494
|
+
v.scale = 1
|
|
495
|
+
v.opacity = 1
|
|
496
|
+
v.x = v.oldX
|
|
497
|
+
v.y = v.oldY
|
|
498
|
+
this.$nextTick(() => {
|
|
499
|
+
v.x = this.getAlignedX(v.absX)
|
|
500
|
+
v.y = v.absY * this.viewWidth
|
|
501
|
+
v.oldX = v.x
|
|
502
|
+
v.oldY = v.y
|
|
503
|
+
this.tempItem = null
|
|
504
|
+
})
|
|
505
|
+
}
|
|
506
|
+
})
|
|
507
|
+
this.changeStatus = true
|
|
508
|
+
}
|
|
509
|
+
//#endif
|
|
510
|
+
},
|
|
511
|
+
delImages(item, index) {
|
|
512
|
+
if (typeof this.delImage === 'function') {
|
|
513
|
+
this.delImage.bind(this.$parent)(() => {
|
|
514
|
+
this.delImageHandle(item, index)
|
|
515
|
+
})
|
|
516
|
+
} else {
|
|
517
|
+
this.delImageHandle(item, index)
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
delImageHandle(item, index) {
|
|
521
|
+
// 设置标志,防止 watch 触发重新初始化
|
|
522
|
+
this.changeStatus = false
|
|
523
|
+
|
|
524
|
+
// 删除指定图片
|
|
525
|
+
this.imageList.splice(index, 1)
|
|
526
|
+
|
|
527
|
+
// 重新排序:按照当前的 index 排序(保持拖拽后的逻辑顺序)
|
|
528
|
+
this.imageList.sort((a, b) => a.index - b.index)
|
|
529
|
+
|
|
530
|
+
// 更新索引和位置(根据排序后的新位置)
|
|
531
|
+
const totalWithButton = this.getTotalCount()
|
|
532
|
+
this.imageList.forEach((obj, i) => {
|
|
533
|
+
obj.index = i
|
|
534
|
+
const pos = this.calculatePosition(i, totalWithButton)
|
|
535
|
+
obj.absX = pos.absX
|
|
536
|
+
obj.absY = pos.absY
|
|
537
|
+
const newX = this.getAlignedX(obj.absX)
|
|
538
|
+
const newY = obj.absY * this.viewWidth
|
|
539
|
+
|
|
540
|
+
// 平滑过渡到新位置
|
|
541
|
+
obj.x = obj.oldX
|
|
542
|
+
obj.y = obj.oldY
|
|
543
|
+
this.$nextTick(() => {
|
|
544
|
+
obj.x = newX
|
|
545
|
+
obj.y = newY
|
|
546
|
+
obj.oldX = newX
|
|
547
|
+
obj.oldY = newY
|
|
548
|
+
})
|
|
549
|
+
})
|
|
550
|
+
|
|
551
|
+
this.updateAddButtonPosition()
|
|
552
|
+
this.sortList()
|
|
553
|
+
|
|
554
|
+
// 恢复标志
|
|
555
|
+
this.$nextTick(() => {
|
|
556
|
+
this.changeStatus = true
|
|
557
|
+
})
|
|
558
|
+
},
|
|
559
|
+
delImageMp(item, index) {
|
|
560
|
+
//#ifdef MP
|
|
561
|
+
this.delImages(item, index)
|
|
562
|
+
//#endif
|
|
563
|
+
},
|
|
564
|
+
sortList() {
|
|
565
|
+
const result = []
|
|
566
|
+
let list = this.imageList.slice()
|
|
567
|
+
list.sort((a, b) => {
|
|
568
|
+
return a.index - b.index
|
|
569
|
+
})
|
|
570
|
+
for (let s of list) {
|
|
571
|
+
let item = this.value.find(d => this.getSrc(d) == s.src)
|
|
572
|
+
if (item) {
|
|
573
|
+
result.push(item)
|
|
574
|
+
} else {
|
|
575
|
+
if (this.keyName !== null) {
|
|
576
|
+
result.push({
|
|
577
|
+
[this.keyName]: s.src
|
|
578
|
+
})
|
|
579
|
+
} else {
|
|
580
|
+
result.push(s.src)
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
this.$emit("input", result);
|
|
586
|
+
},
|
|
587
|
+
addProperties(item) {
|
|
588
|
+
const newIndex = this.imageList.length
|
|
589
|
+
|
|
590
|
+
// 先添加图片到列表
|
|
591
|
+
this.imageList.push({
|
|
592
|
+
src: item,
|
|
593
|
+
x: 0,
|
|
594
|
+
y: 0,
|
|
595
|
+
oldX: 0,
|
|
596
|
+
oldY: 0,
|
|
597
|
+
absX: 0,
|
|
598
|
+
absY: 0,
|
|
599
|
+
scale: 1,
|
|
600
|
+
zIndex: 9,
|
|
601
|
+
opacity: 1,
|
|
602
|
+
index: newIndex,
|
|
603
|
+
id: this.guid(16),
|
|
604
|
+
disable: false,
|
|
605
|
+
offset: 0,
|
|
606
|
+
moveEnd: false,
|
|
607
|
+
loading: true
|
|
608
|
+
})
|
|
609
|
+
|
|
610
|
+
// 计算图片的位置
|
|
611
|
+
const totalWithButton = this.getTotalCount()
|
|
612
|
+
const pos = this.calculatePosition(newIndex, totalWithButton)
|
|
613
|
+
const obj = this.imageList[newIndex]
|
|
614
|
+
obj.absX = pos.absX
|
|
615
|
+
obj.absY = pos.absY
|
|
616
|
+
obj.x = this.getAlignedX(pos.absX)
|
|
617
|
+
obj.y = pos.absY * this.viewWidth
|
|
618
|
+
obj.oldX = obj.x
|
|
619
|
+
obj.oldY = obj.y
|
|
620
|
+
|
|
621
|
+
this.updateAddButtonPosition()
|
|
622
|
+
if (this.align === 'right') {
|
|
623
|
+
this.recalculateAllPositions()
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* 重新计算所有图片的位置(用于右对齐时添加/删除图片)
|
|
629
|
+
*/
|
|
630
|
+
recalculateAllPositions() {
|
|
631
|
+
const totalWithButton = this.getTotalCount()
|
|
632
|
+
this.imageList.forEach((obj, i) => {
|
|
633
|
+
const pos = this.calculatePosition(i, totalWithButton)
|
|
634
|
+
const newX = this.getAlignedX(pos.absX)
|
|
635
|
+
const newY = pos.absY * this.viewWidth
|
|
636
|
+
|
|
637
|
+
// 如果位置有变化,进行动画过渡
|
|
638
|
+
if (obj.absX !== pos.absX || obj.absY !== pos.absY) {
|
|
639
|
+
obj.x = obj.oldX
|
|
640
|
+
obj.y = obj.oldY
|
|
641
|
+
obj.absX = pos.absX
|
|
642
|
+
obj.absY = pos.absY
|
|
643
|
+
this.$nextTick(() => {
|
|
644
|
+
obj.x = newX
|
|
645
|
+
obj.y = newY
|
|
646
|
+
obj.oldX = newX
|
|
647
|
+
obj.oldY = newY
|
|
648
|
+
})
|
|
649
|
+
} else {
|
|
650
|
+
obj.absX = pos.absX
|
|
651
|
+
obj.absY = pos.absY
|
|
652
|
+
obj.x = newX
|
|
653
|
+
obj.y = newY
|
|
654
|
+
obj.oldX = newX
|
|
655
|
+
obj.oldY = newY
|
|
656
|
+
}
|
|
657
|
+
})
|
|
658
|
+
},
|
|
659
|
+
nothing() { },
|
|
660
|
+
rpx2px(v) {
|
|
661
|
+
return this.width * v / 750
|
|
662
|
+
},
|
|
663
|
+
guid(len = 32) {
|
|
664
|
+
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')
|
|
665
|
+
const uuid = []
|
|
666
|
+
const radix = chars.length
|
|
667
|
+
for (let i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]
|
|
668
|
+
uuid.shift()
|
|
669
|
+
return `u${uuid.join('')}`
|
|
670
|
+
},
|
|
671
|
+
// 更新添加按钮的位置
|
|
672
|
+
updateAddButtonPosition() {
|
|
673
|
+
if (!this.viewWidth || !this.colsValue) {
|
|
674
|
+
console.warn('updateAddButtonPosition called before initialization')
|
|
675
|
+
return
|
|
676
|
+
}
|
|
677
|
+
const length = this.imageList.length
|
|
678
|
+
|
|
679
|
+
if (this.align === 'right' && this.showAddButton) {
|
|
680
|
+
// 右对齐且显示按钮:按钮的位置就是"虚拟的第 length 个元素"的位置
|
|
681
|
+
// 总数包括按钮本身
|
|
682
|
+
const totalWithButton = length + 1
|
|
683
|
+
const pos = this.calculatePosition(length, totalWithButton)
|
|
684
|
+
this.add.x = this.getAlignedX(pos.absX) + 'px'
|
|
685
|
+
this.add.y = pos.absY * this.viewWidth + 'px'
|
|
686
|
+
} else {
|
|
687
|
+
// 左对齐或不显示按钮:按钮直接跟在最后一个元素后面
|
|
688
|
+
const absX = length % this.colsValue
|
|
689
|
+
const absY = Math.floor(length / this.colsValue)
|
|
690
|
+
this.add.x = this.getAlignedX(absX) + 'px'
|
|
691
|
+
this.add.y = absY * this.viewWidth + 'px'
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
handleMediaLoad(item) {
|
|
695
|
+
if (!item) return
|
|
696
|
+
item.loading = false
|
|
697
|
+
},
|
|
698
|
+
handleMediaError(item) {
|
|
699
|
+
if (!item) return
|
|
700
|
+
item.loading = false
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
</script>
|
|
705
|
+
|
|
706
|
+
<style lang="scss" scoped>
|
|
707
|
+
.con {
|
|
708
|
+
// padding: 30rpx;
|
|
709
|
+
|
|
710
|
+
.area {
|
|
711
|
+
width: 100%;
|
|
712
|
+
|
|
713
|
+
.view {
|
|
714
|
+
display: flex;
|
|
715
|
+
justify-content: center;
|
|
716
|
+
align-items: center;
|
|
717
|
+
|
|
718
|
+
.area-con {
|
|
719
|
+
position: relative;
|
|
720
|
+
overflow: hidden;
|
|
721
|
+
|
|
722
|
+
.pre-image {
|
|
723
|
+
width: 100%;
|
|
724
|
+
height: 100%;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
.myVideo {
|
|
728
|
+
width: 100%;
|
|
729
|
+
height: 100%;
|
|
730
|
+
border-radius: 8rpx;
|
|
731
|
+
position: relative;
|
|
732
|
+
z-index: 0 !important;
|
|
733
|
+
|
|
734
|
+
&::after {
|
|
735
|
+
content: "";
|
|
736
|
+
position: absolute;
|
|
737
|
+
/* background: url('../../static/oxygen/icon_play1.png') no-repeat; */
|
|
738
|
+
background-size: 100% 100%;
|
|
739
|
+
top: 50%;
|
|
740
|
+
left: 50%;
|
|
741
|
+
transform: translate(-50%, -50%);
|
|
742
|
+
width: 60%;
|
|
743
|
+
height: 60%;
|
|
744
|
+
opacity: 0.9;
|
|
745
|
+
z-index: 1;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
.media-loading-overlay {
|
|
750
|
+
position: absolute;
|
|
751
|
+
top: 0;
|
|
752
|
+
left: 0;
|
|
753
|
+
right: 0;
|
|
754
|
+
bottom: 0;
|
|
755
|
+
display: flex;
|
|
756
|
+
align-items: center;
|
|
757
|
+
justify-content: center;
|
|
758
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
759
|
+
border-radius: inherit;
|
|
760
|
+
z-index: 5;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
.loading-spinner {
|
|
764
|
+
width: 40rpx;
|
|
765
|
+
height: 40rpx;
|
|
766
|
+
border: 4rpx solid rgba(0, 0, 0, 0.1);
|
|
767
|
+
border-top-color: #007aff;
|
|
768
|
+
border-radius: 50%;
|
|
769
|
+
animation: spinner-rotate 0.8s linear infinite;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
.del-con {
|
|
773
|
+
position: absolute;
|
|
774
|
+
top: 0rpx;
|
|
775
|
+
right: 0rpx;
|
|
776
|
+
padding: 0 0 12rpx 12rpx;
|
|
777
|
+
|
|
778
|
+
.del-wrap {
|
|
779
|
+
width: 36rpx;
|
|
780
|
+
height: 36rpx;
|
|
781
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
782
|
+
border-radius: 0 0 0 10rpx;
|
|
783
|
+
display: flex;
|
|
784
|
+
justify-content: center;
|
|
785
|
+
align-items: center;
|
|
786
|
+
|
|
787
|
+
.del-image {
|
|
788
|
+
width: 20rpx;
|
|
789
|
+
height: 20rpx;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
.add {
|
|
797
|
+
position: absolute;
|
|
798
|
+
display: flex;
|
|
799
|
+
justify-content: center;
|
|
800
|
+
align-items: center;
|
|
801
|
+
|
|
802
|
+
.add-wrap {
|
|
803
|
+
display: flex;
|
|
804
|
+
justify-content: center;
|
|
805
|
+
align-items: center;
|
|
806
|
+
background-color: #eeeeee;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
@keyframes spinner-rotate {
|
|
813
|
+
0% {
|
|
814
|
+
transform: rotate(0deg);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
100% {
|
|
818
|
+
transform: rotate(360deg);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
</style>
|