From 788f4e6b5e13a3fd4280835dab44e0954976985b Mon Sep 17 00:00:00 2001 From: tangxinyue <524779910@qq.com> Date: Sat, 30 May 2026 15:35:53 +0800 Subject: [PATCH] 1 --- .../pdd/components/list-card/list-card.vue | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pages/shopping/pdd/components/list-card/list-card.vue b/pages/shopping/pdd/components/list-card/list-card.vue index 555bf53..761213a 100644 --- a/pages/shopping/pdd/components/list-card/list-card.vue +++ b/pages/shopping/pdd/components/list-card/list-card.vue @@ -123,9 +123,16 @@ const emit = defineEmits(['longpress']); let longPressTimer = null; let isLongPressTriggered = false; +let startX = 0; +let startY = 0; const handleTouchStart = (e) => { isLongPressTriggered = false; + const touch = e.touches[0] || e.changedTouches[0]; + if (touch) { + startX = touch.clientX; + startY = touch.clientY; + } longPressTimer = setTimeout(() => { isLongPressTriggered = true; uni.vibrateShort(); @@ -133,10 +140,18 @@ const handleTouchStart = (e) => { }, 1200); // 长按时间 1200ms }; -const handleTouchMove = () => { +const handleTouchMove = (e) => { if (longPressTimer) { - clearTimeout(longPressTimer); - longPressTimer = null; + const touch = e.touches[0] || e.changedTouches[0]; + if (touch) { + const moveX = touch.clientX; + const moveY = touch.clientY; + // 增加 15px 容错,防止微小抖动取消长按 + if (Math.abs(moveX - startX) > 15 || Math.abs(moveY - startY) > 15) { + clearTimeout(longPressTimer); + longPressTimer = null; + } + } } };