|
|
@@ -83,15 +83,16 @@
|
|
83
|
83
|
<view class="detail-image-content">
|
|
84
|
84
|
<view class="detail-image-list">
|
|
85
|
85
|
<view
|
|
86
|
|
- v-for="(item, index) in detailImages.slice(0, 6)"
|
|
87
|
|
- :key="`detail-${index}`"
|
|
|
86
|
+ v-for="(item, index) in displayImages"
|
|
|
87
|
+ :key="item.id || `detail-${index}`"
|
|
88
|
88
|
class="detail-image-item"
|
|
89
|
89
|
:class="{
|
|
90
|
90
|
'dragging': draggingIndex === index,
|
|
91
|
|
- 'can-drop': canDropIndex === index
|
|
|
91
|
+ 'can-drop': canDropIndex === index && draggingIndex !== index
|
|
92
|
92
|
}"
|
|
|
93
|
+ :style="draggingIndex === index ? draggingStyle : ''"
|
|
93
|
94
|
@touchstart.stop="onTouchStart($event, index)"
|
|
94
|
|
- @touchmove.stop="onTouchMove($event)"
|
|
|
95
|
+ @touchmove.stop="onTouchMove($event, index)"
|
|
95
|
96
|
@touchend.stop="onTouchEnd"
|
|
96
|
97
|
>
|
|
97
|
98
|
<PicComp
|
|
|
@@ -282,6 +283,8 @@ export default {
|
|
282
|
283
|
canDropIndex: -1,
|
|
283
|
284
|
startX: 0,
|
|
284
|
285
|
startY: 0,
|
|
|
286
|
+ currentX: 0,
|
|
|
287
|
+ currentY: 0,
|
|
285
|
288
|
// 模态窗
|
|
286
|
289
|
unpaidModalVisible: false,
|
|
287
|
290
|
followUpModalVisible: false,
|
|
|
@@ -290,6 +293,20 @@ export default {
|
|
290
|
293
|
followUpNotes: ''
|
|
291
|
294
|
}
|
|
292
|
295
|
},
|
|
|
296
|
+ computed: {
|
|
|
297
|
+ // 显示前6个图片用于拖拽
|
|
|
298
|
+ displayImages() {
|
|
|
299
|
+ return this.detailImages.slice(0, 6)
|
|
|
300
|
+ },
|
|
|
301
|
+ // 拖拽时的样式
|
|
|
302
|
+ draggingStyle() {
|
|
|
303
|
+ if (this.draggingIndex === -1) return ''
|
|
|
304
|
+ return {
|
|
|
305
|
+ transform: `translate(${this.currentX - this.startX}px, ${this.currentY - this.startY}px)`,
|
|
|
306
|
+ zIndex: 1000
|
|
|
307
|
+ }
|
|
|
308
|
+ }
|
|
|
309
|
+ },
|
|
293
|
310
|
watch: {
|
|
294
|
311
|
orderDetail: {
|
|
295
|
312
|
handler(newVal) {
|
|
|
@@ -417,18 +434,22 @@ export default {
|
|
417
|
434
|
onTouchStart(event, index) {
|
|
418
|
435
|
if (this.draggingIndex !== -1) return
|
|
419
|
436
|
this.draggingIndex = index
|
|
420
|
|
- this.startX = event.touches[0].clientX
|
|
421
|
|
- this.startY = event.touches[0].clientY
|
|
|
437
|
+ const touch = event.touches[0]
|
|
|
438
|
+ this.startX = touch.clientX
|
|
|
439
|
+ this.startY = touch.clientY
|
|
|
440
|
+ this.currentX = touch.clientX
|
|
|
441
|
+ this.currentY = touch.clientY
|
|
422
|
442
|
},
|
|
423
|
443
|
|
|
424
|
444
|
/**
|
|
425
|
445
|
* 触摸移动
|
|
426
|
446
|
*/
|
|
427
|
|
- onTouchMove(event) {
|
|
428
|
|
- if (this.draggingIndex === -1) return
|
|
429
|
|
- const moveX = event.touches[0].clientX
|
|
430
|
|
- const moveY = event.touches[0].clientY
|
|
431
|
|
- this.findTargetIndex(moveX, moveY)
|
|
|
447
|
+ onTouchMove(event, index) {
|
|
|
448
|
+ if (this.draggingIndex === -1 || this.draggingIndex !== index) return
|
|
|
449
|
+ const touch = event.touches[0]
|
|
|
450
|
+ this.currentX = touch.clientX
|
|
|
451
|
+ this.currentY = touch.clientY
|
|
|
452
|
+ this.findTargetIndex(touch.clientX, touch.clientY)
|
|
432
|
453
|
},
|
|
433
|
454
|
|
|
434
|
455
|
/**
|
|
|
@@ -438,9 +459,12 @@ export default {
|
|
438
|
459
|
if (this.draggingIndex === -1) return
|
|
439
|
460
|
|
|
440
|
461
|
if (this.canDropIndex !== -1 && this.canDropIndex !== this.draggingIndex) {
|
|
441
|
|
- const temp = this.detailImages[this.draggingIndex]
|
|
442
|
|
- this.detailImages[this.draggingIndex] = this.detailImages[this.canDropIndex]
|
|
443
|
|
- this.detailImages[this.canDropIndex] = temp
|
|
|
462
|
+ // 交换位置
|
|
|
463
|
+ const images = [...this.detailImages]
|
|
|
464
|
+ const temp = images[this.draggingIndex]
|
|
|
465
|
+ images[this.draggingIndex] = images[this.canDropIndex]
|
|
|
466
|
+ images[this.canDropIndex] = temp
|
|
|
467
|
+ this.detailImages = images
|
|
444
|
468
|
}
|
|
445
|
469
|
|
|
446
|
470
|
this.resetDragState()
|
|
|
@@ -451,7 +475,8 @@ export default {
|
|
451
|
475
|
*/
|
|
452
|
476
|
findTargetIndex(x, y) {
|
|
453
|
477
|
const query = uni.createSelectorQuery().in(this)
|
|
454
|
|
- query.selectAll('.detail-image-item').boundingClientRect(rects => {
|
|
|
478
|
+ query.selectAll('.detail-image-item').boundingClientRect((rects) => {
|
|
|
479
|
+ if (!rects || rects.length === 0) return
|
|
455
|
480
|
let targetIndex = -1
|
|
456
|
481
|
for (let i = 0; i < rects.length; i++) {
|
|
457
|
482
|
if (i === this.draggingIndex) continue
|
|
|
@@ -473,6 +498,8 @@ export default {
|
|
473
|
498
|
this.canDropIndex = -1
|
|
474
|
499
|
this.startX = 0
|
|
475
|
500
|
this.startY = 0
|
|
|
501
|
+ this.currentX = 0
|
|
|
502
|
+ this.currentY = 0
|
|
476
|
503
|
},
|
|
477
|
504
|
|
|
478
|
505
|
/**
|
|
|
@@ -498,7 +525,7 @@ export default {
|
|
498
|
525
|
* 隐藏图片
|
|
499
|
526
|
*/
|
|
500
|
527
|
handleHideImage(item, index) {
|
|
501
|
|
- const itemIndex = this.detailImages.findIndex(img => img.fileUrl === item.fileUrl)
|
|
|
528
|
+ const itemIndex = this.detailImages.findIndex(img => img.id === item.id || img.fileUrl === item.fileUrl)
|
|
502
|
529
|
if (itemIndex !== -1) {
|
|
503
|
530
|
this.detailImages.splice(itemIndex, 1)
|
|
504
|
531
|
uni.$u.toast('图片已隐藏')
|
|
|
@@ -718,19 +745,22 @@ export default {
|
|
718
|
745
|
width: 200rpx;
|
|
719
|
746
|
height: 200rpx;
|
|
720
|
747
|
touch-action: none;
|
|
721
|
|
- transition: all 0.2s ease;
|
|
|
748
|
+ transition: transform 0.2s ease, opacity 0.2s ease;
|
|
722
|
749
|
z-index: 1;
|
|
723
|
|
- cursor: move;
|
|
|
750
|
+ box-sizing: border-box;
|
|
724
|
751
|
|
|
725
|
752
|
&.dragging {
|
|
726
|
|
- opacity: 0.5;
|
|
|
753
|
+ opacity: 0.6;
|
|
727
|
754
|
transform: scale(1.05);
|
|
728
|
|
- z-index: 100;
|
|
|
755
|
+ z-index: 999;
|
|
|
756
|
+ box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.2);
|
|
729
|
757
|
}
|
|
730
|
758
|
|
|
731
|
759
|
&.can-drop {
|
|
732
|
|
- border: 2rpx dashed #108cff;
|
|
|
760
|
+ outline: 2rpx dashed #108cff;
|
|
|
761
|
+ outline-offset: -2rpx;
|
|
733
|
762
|
background-color: rgba(16, 140, 255, 0.1);
|
|
|
763
|
+ border-radius: 8rpx;
|
|
734
|
764
|
}
|
|
735
|
765
|
}
|
|
736
|
766
|
|
|
|
@@ -896,5 +926,6 @@ export default {
|
|
896
|
926
|
line-height: 80rpx;
|
|
897
|
927
|
text-align: center;
|
|
898
|
928
|
border-radius: 20rpx;
|
|
|
929
|
+ z-index: 1000;
|
|
899
|
930
|
}
|
|
900
|
931
|
</style>
|