From 0c8ca980d6558334b99b9c4e4a5692e342ea4224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Wed, 11 Mar 2026 18:43:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9C=80=E5=90=8E=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=92=8C=E7=AC=AC=E4=B8=80=E4=B8=AA=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/plugins/video/detail/detail.vue | 77 ++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/pages/plugins/video/detail/detail.vue b/pages/plugins/video/detail/detail.vue index a6811af1..a5ee9d2f 100644 --- a/pages/plugins/video/detail/detail.vue +++ b/pages/plugins/video/detail/detail.vue @@ -18,7 +18,7 @@ - + @@ -317,6 +317,11 @@ comments_reply_data: {}, editor_path_type: 'video', is_manual_pause: false, // 是否手动暂停 + // 视频滚动 + swiper_start_y: 0, + swiper_current_y: 0, + swiper_move_distance: 0, + swiper_move_throttle_timer: null, }; }, components: { @@ -786,7 +791,75 @@ this.video_play_event(videoContext); } }, - + // 视频拖拽开始 + handle_swiper_touch_start(e) { + try { + // 如果是滚动区域内滚动到顶部才可以拖拽,如果是头部拖拽的话,一直都可以 + this.swiper_start_y = e?.touches[0]?.pageY || 0; + this.swiper_current_y = this.swiper_start_y; + this.swiper_move_distance = 0; + } catch (error) { + console.error('handle_swiper_touch_start error:', error); + } + }, + // 视频拖拽中 + handle_swiper_touch_move(e) { + try { + const current_y = e?.touches[0]?.pageY || 0; + const distance = current_y - this.swiper_start_y; + + // 只有向下移动且距离超过阈值(10px)才开始拖拽,避免误触和抖动 + if (Math.abs(distance) > 10) { + this.swiper_current_y = current_y; + + // 使用节流控制 move_distance 的更新频率,避免计算属性频繁触发导致抖动 + if (this.swiper_move_throttle_timer) { + return; + } + + this.move_distance = distance; + + // 设置节流定时器,16ms 约等于 60fps,保证流畅度同时避免过度更新 + this.swiper_move_throttle_timer = setTimeout(() => { + this.swiper_move_throttle_timer = null; + }, 80); + } + } catch(error) { + console.error('handle_swiper_touch_move error:', error); + } + }, + // 视频拖拽结束 + handle_swiper_touch_end(e) { + try { + const move_distance = this.swiper_current_y - this.swiper_start_y; + // 只有滑动距离超过屏幕高度的 15% 才触发切换 + if (move_distance > 0) { + // 向下滑动,切换到上一个 + if (this.current_video_index <= 0) { + app.globalData.showToast('已经是第一个视频了'); + return; + } + } else { + // 向上滑动,切换到下一个 + if (this.current_video_index >= this.video_data_list.length - 1) { + app.globalData.showToast('已经是最后一个视频了'); + return; + } + } + + // 清理节流定时器 + if (this.swiper_move_throttle_timer) { + clearTimeout(this.swiper_move_throttle_timer); + this.swiper_move_throttle_timer = null; + } + + // 重置拖拽状态 + this.swiper_start_y = 0; + this.swiper_current_y = 0; + } catch (error) { + console.error('handle_swiper_touch_end error:', error); + } + }, // 更新分享信息 update_share_info(data) { const info = {