refactor(Dashboard): 使用更简洁的Taro.getWindowInfo替换getSystemInfo
简化滚动触发逻辑,直接获取窗口高度信息,移除不必要的回调嵌套
Showing
1 changed file
with
9 additions
and
16 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-08-27 17:43:45 | 2 | * @Date: 2025-08-27 17:43:45 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-10-25 20:05:09 | 4 | + * @LastEditTime: 2025-10-26 20:16:05 |
| 5 | * @FilePath: /lls_program/src/pages/Dashboard/index.vue | 5 | * @FilePath: /lls_program/src/pages/Dashboard/index.vue |
| 6 | * @Description: 首页 | 6 | * @Description: 首页 |
| 7 | --> | 7 | --> |
| ... | @@ -657,21 +657,14 @@ const handlePageScroll = (scrollTop) => { | ... | @@ -657,21 +657,14 @@ const handlePageScroll = (scrollTop) => { |
| 657 | if (rect) { | 657 | if (rect) { |
| 658 | // console.log('RankingCard 位置信息:', rect) | 658 | // console.log('RankingCard 位置信息:', rect) |
| 659 | // 获取系统信息 | 659 | // 获取系统信息 |
| 660 | - Taro.getSystemInfo({ | 660 | + const { windowHeight } = Taro.getWindowInfo(); |
| 661 | - success: (res) => { | 661 | + // 当组件顶部进入视窗下方80%位置时触发 |
| 662 | - const windowHeight = res.windowHeight | 662 | + const triggerPoint = windowHeight * 0.8; |
| 663 | - // 当组件顶部进入视窗下方80%位置时触发 | 663 | + if (rect.top <= triggerPoint && rect.bottom >= 0) { |
| 664 | - const triggerPoint = windowHeight * 0.8 | 664 | + // console.log('触发数字滚动动画!') |
| 665 | - | 665 | + // 触发数字滚动动画 |
| 666 | - // console.log('窗口高度:', windowHeight, '触发点:', triggerPoint, 'rect.top:', rect.top) | 666 | + triggerNumberRoll() |
| 667 | - | 667 | + } |
| 668 | - if (rect.top <= triggerPoint && rect.bottom >= 0) { | ||
| 669 | - // console.log('触发数字滚动动画!') | ||
| 670 | - // 触发数字滚动动画 | ||
| 671 | - triggerNumberRoll() | ||
| 672 | - } | ||
| 673 | - } | ||
| 674 | - }) | ||
| 675 | } else { | 668 | } else { |
| 676 | console.log('未找到 RankingCard 容器元素') | 669 | console.log('未找到 RankingCard 容器元素') |
| 677 | } | 670 | } | ... | ... |
-
Please register or login to post a comment