1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-07-27 04:20:43 +08:00

feat: 新增返回顶部功能与优化首页横幅样式

1.  给useListData的下拉刷新添加调试日志
2.  首页横幅替换固定图片为随机资源图,调整渐变背景层级
3.  新增tabbar滚动监听与返回顶部按钮功能
This commit is contained in:
小莫唐尼
2026-06-12 00:12:43 +08:00
parent 862d176593
commit c847dfb1c4
3 changed files with 36 additions and 8 deletions
+29 -3
View File
@@ -4,6 +4,7 @@ import { customTabbarEnable, needHideNativeTabbar } from './config'
import { setTabbarItem } from './i18n'
import { tabbarList, tabbarStore } from './store'
import { sleep } from '@/utils/common'
import { debounce } from '@/utils/base/debounce'
import TabbarItem from './TabbarItem.vue'
// #ifdef MP-WEIXIN
@@ -55,6 +56,12 @@ onMounted(() => {
})
// #endif
const backTopActive = reactive({
show: false,
beforeScrollTop: 0,
currentScrollTop: 0,
})
const tabbarRect = ref<Array<{ left: number, width: number }>>([])
const activeDomStyle = reactive({
@@ -105,6 +112,25 @@ onMounted(() => {
console.log('onMounted')
getTabBarRect()
})
const triggerPageScrollDebounceFn = debounce((scrollTop: number) => {
backTopActive.beforeScrollTop = backTopActive.currentScrollTop
setTimeout(() => {
backTopActive.currentScrollTop = scrollTop
backTopActive.show = backTopActive.currentScrollTop > backTopActive.beforeScrollTop
}, 60)
}, 60)
onPageScroll(({ scrollTop }) => {
triggerPageScrollDebounceFn(scrollTop)
})
function handleScrollToTop() {
uni.pageScrollTo({
scrollTop: 0,
duration: 300,
})
}
</script>
<template>
@@ -115,8 +141,7 @@ onMounted(() => {
>
<TabbarItem
v-for="(item, index) in tabbarList" :key="index" :item="item" :count="tabbarList.length"
:index="index" :global-active-slider-bar="tabBarConfig.useGlobalActiveSliderBar"
class="tabbar-item h-full"
:index="index" :global-active-slider-bar="tabBarConfig.useGlobalActiveSliderBar" class="tabbar-item h-full"
:class="[isActiveByIndex(index) ? 'shrink-0' : 'flex-1']"
/>
<!-- 激活滑块 -->
@@ -132,7 +157,8 @@ onMounted(() => {
<view
class="uh-shadow-sm box-border h-54px w-54px flex items-center justify-center border border-white rounded-full border-solid bg-white/95 text-2xl backdrop-blur-[3px]"
>
+
<wd-icon v-if="backTopActive.show" name="arrow-up" :size="22" @click="handleScrollToTop" />
<wd-icon v-else name="search-line" :size="22" />
</view>
<view v-if="!tabBarConfig.useFloat" class="pb-safe" />