fix:图片上传拖拽排序,在h5下保持和小程序一致体验,禁用长按菜单

This commit is contained in:
aisen
2024-11-26 15:34:11 +08:00
parent 43c99c1fd9
commit f3471b2646
@@ -300,7 +300,9 @@
}, },
timer: null, timer: null,
dragging: false, dragging: false,
show:true show:true,
h5LongPress:false,
h5StarDragging:false
} }
}, },
watch: { watch: {
@@ -329,7 +331,10 @@
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
this.updateDragInfo() this.updateDragInfo()
}) });
// #ifdef H5
this.h5LongPress = true;
// #endif
}, },
methods: { methods: {
// 清除列表 // 清除列表
@@ -737,7 +742,12 @@
} }
// #endif // #endif
}, },
movableLongPress(item) { movableLongPress(item,e) {
// #ifdef H5
//h5必须长按后才允许拖拽
this.h5StarDragging = true;
this.movableStart(item);
// #endif
// #ifndef H5 // #ifndef H5
uni.vibrateShort() uni.vibrateShort()
// console.log("LongPress--------------------------------------------------------------"); // console.log("LongPress--------------------------------------------------------------");
@@ -804,7 +814,10 @@
} }
}, },
movableStart (item) { movableStart (item) {
// console.log("movableStart"); if (this.h5LongPress && !this.h5StarDragging){
return
}
//console.log("movableStart");
this.lists.forEach(item => { this.lists.forEach(item => {
item.zIndex = 1 item.zIndex = 1
// #ifdef H5 // #ifdef H5
@@ -825,8 +838,9 @@
// #endif // #endif
}, },
movableEnd (item) { movableEnd (item) {
this.h5StarDragging = false;
if (!this.dragging) return if (!this.dragging) return
// console.log("movableEnd"); //console.log("movableEnd");
const index = this.lists.findIndex(obj => { const index = this.lists.findIndex(obj => {
return obj.id === item.id return obj.id === item.id
}) })
@@ -892,6 +906,9 @@
.tn-image-upload { .tn-image-upload {
position: relative; position: relative;
/* #ifdef H5 */
-webkit-touch-callout:none;
/* #endif */
&__movable-area { &__movable-area {
width: 100%; width: 100%;