diff --git a/pages/plugins/live/pull/components/like-effect/like-effect.vue b/pages/plugins/live/pull/components/like-effect/like-effect.vue index 8cb6d386..9a6bfc4e 100644 --- a/pages/plugins/live/pull/components/like-effect/like-effect.vue +++ b/pages/plugins/live/pull/components/like-effect/like-effect.vue @@ -1,43 +1,45 @@ @@ -75,7 +77,8 @@ likeCountScale: 1, lastLikeTime: 0, likeCountTimer: null, - resetTimer: null // 重置计数的定时器 + resetTimer: null, // 重置计数的定时器 + lastClickTime: 0 // 防止双击添加多个图标 } }, computed: { @@ -90,6 +93,13 @@ }, methods: { addLike(event, options = {}) { + // 防抖处理,防止双击添加多个图标 + const now = Date.now(); + if (now - this.lastClickTime < 200) { + return; + } + this.lastClickTime = now; + // 获取点击坐标 let x, y; // 尝试多种方式获取坐标 @@ -106,13 +116,13 @@ console.log('Click coordinates:', x, y); - // 添加随机偏差 (-20px 到 20px) - const offsetX = Math.floor(Math.random() * 41) - 20; - const offsetY = Math.floor(Math.random() * 41) - 20; + // 添加随机偏差 (-10px 到 10px) + const offsetX = Math.floor(Math.random() * 41) - 10; + const offsetY = Math.floor(Math.random() * 41) - 10; // 确保图标位置不超过点击位置20px范围 - const clampedOffsetX = Math.max(-20, Math.min(20, offsetX)); - const clampedOffsetY = Math.max(-20, Math.min(20, offsetY)); + const clampedOffsetX = Math.max(-10, Math.min(10, offsetX)); + const clampedOffsetY = Math.max(-10, Math.min(10, offsetY)); // 调整后的坐标 const adjustedX = x + clampedOffsetX - 10; @@ -157,7 +167,7 @@ icon: icon, imageSrc: imageSrc }; - + console.log(newLike, '111'); // 添加到列表 this.likeList.push(newLike); console.log('Added like item:', newLike); @@ -186,6 +196,12 @@ this.resetTimer = null; } + // 清除之前的隐藏定时器 + if (this.likeCountTimer) { + clearTimeout(this.likeCountTimer); + this.likeCountTimer = null; + } + // 如果距离上次点赞超过1秒,重置计数 if (currentTime - this.lastLikeTime > 1000) { this.likeCount = 1; @@ -217,22 +233,18 @@ }); } - // 清除之前的定时器 - if (this.likeCountTimer) { - clearTimeout(this.likeCountTimer); - } - - // 设置隐藏定时器(1000ms后隐藏,但不重置计数) + // 设置隐藏定时器(200ms后隐藏,但不重置计数) if (this.likeCount >= 3) { this.likeCountTimer = setTimeout(() => { this.hideLikeCount(); - - // 设置重置计数的定时器(在隐藏后1秒重置) - this.resetTimer = setTimeout(() => { - this.likeCount = 0; - }, 1000); - }, 1000); // 200ms后隐藏 + }, 200); } + + // 设置重置计数的定时器(在隐藏后1秒重置) + this.resetTimer = setTimeout(() => { + this.likeCount = 0; + this.showLikeCount = false; + }, 1200); }, // 隐藏数量提示 @@ -343,9 +355,11 @@ position: absolute; top: 0; left: 0; + /* #ifndef-nvue */ width: 100%; height: 100%; pointer-events: none; + /* #endif */ z-index: 9999; } @@ -374,7 +388,7 @@ .like-count { opacity: 1; - animation: shrinkUp 0.2s ease-out forwards; + animation: shrinkUp 1s ease-out forwards; } @keyframes zoomInOut { diff --git a/pages/plugins/live/pull/components/live-content/live-content.vue b/pages/plugins/live/pull/components/live-content/live-content.vue index a0ade794..adb173ee 100644 --- a/pages/plugins/live/pull/components/live-content/live-content.vue +++ b/pages/plugins/live/pull/components/live-content/live-content.vue @@ -7,14 +7,14 @@ - + {{ live_data && live_data.title ? live_data.title : '直播' }} 9999本场点赞 - + @@ -28,7 +28,7 @@ - + @@ -99,7 +99,7 @@ {{ message_num }}条新消息 - + {{ explain_goods.goods_name }} @@ -108,14 +108,14 @@ - + {{ commons_name }} 来了 - + @@ -134,17 +134,17 @@ - + - + - + @@ -576,6 +576,12 @@ }); } }, + handle_touch_end(event) { + this.$emit("handleTouchEnd", event); + }, + handle_double_click(event) { + this.$emit("handleDoubleClick", event); + } } } diff --git a/pages/plugins/live/pull/mixins/mixins.js b/pages/plugins/live/pull/mixins/mixins.js index b46d02c5..58175493 100644 --- a/pages/plugins/live/pull/mixins/mixins.js +++ b/pages/plugins/live/pull/mixins/mixins.js @@ -93,9 +93,12 @@ export default { }, // 处理鼠标双击事件 handleDoubleClick(event) { - // 防抖处理,100ms内只能触发一次 + if (event.target.dataset.ignore) { + return; + } + // 防抖处理,200ms内只能触发一次 const currentTime = Date.now(); - if (currentTime - this.lastLikeTime < 100) { + if (currentTime - this.lastLikeTime < 200) { return; } @@ -108,14 +111,17 @@ export default { // 处理触屏双击事件 handleTouchEnd(event) { + if (event.target.dataset.ignore) { + return; + } // 获取当前位置 let x, y; if (event.changedTouches && event.changedTouches.length > 0) { - x = event.changedTouches[0].clientX; - y = event.changedTouches[0].clientY; + x = event.changedTouches[0].screenX; + y = event.changedTouches[0].screenY; } else { - x = event.clientX || 0; - y = event.clientY || 0; + x = event.screenX || 0; + y = event.screenY || 0; } const currentTime = new Date().getTime(); @@ -124,12 +130,11 @@ export default { Math.pow(x - this.lastTapPosition.x, 2) + Math.pow(y - this.lastTapPosition.y, 2) ); - // 判断是否为双击 (300ms内且距离较近) if (tapLength < 300 && tapLength > 0 && distance < 50) { - // 防抖处理,100ms内只能触发一次 - if (currentTime - this.lastLikeTime < 100) { + // 防抖处理,200ms内只能触发一次 + if (currentTime - this.lastLikeTime < 200) { this.lastTapTime = currentTime; this.lastTapPosition = { x, y }; return; diff --git a/pages/plugins/live/pull/pull.nvue b/pages/plugins/live/pull/pull.nvue index c4fa48bf..23e6da71 100644 --- a/pages/plugins/live/pull/pull.nvue +++ b/pages/plugins/live/pull/pull.nvue @@ -1,16 +1,16 @@