| | |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { ref, onMounted } from 'vue'; |
| | | import { onPullDownRefresh } from '@dcloudio/uni-app' |
| | | import { ref } from 'vue'; |
| | | import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app' |
| | | import { getProjectIntroductionList } from './service' |
| | | |
| | | interface ProjectIntroductionItem { |
| | |
| | | const defaultCoverImage = '/static/image/home/zixun.png' |
| | | const title = ref('') |
| | | const category = ref('') |
| | | // 跳转锁,防止连续点击触发 uni.navigateTo 节流告警。 |
| | | const navigating = ref(false) |
| | | |
| | | /** |
| | | * 页面加载时初始化状态栏高度并拉取项目介绍列表。 |
| | | * 页面加载时通过 onLoad 接收跳转参数并拉取项目介绍列表。 |
| | | * onLoad 的 options 由框架跨端保证一致,避免打包后 getCurrentPages().options 取不到参数。 |
| | | */ |
| | | onMounted(() => { |
| | | onLoad((options) => { |
| | | uni.getSystemInfo({ |
| | | success: (res) => { |
| | | statusBarHeight.value = res.statusBarHeight || 0; |
| | | } |
| | | }); |
| | | |
| | | // 获取页面参数 |
| | | const pages = getCurrentPages() |
| | | const currentPage = pages[pages.length - 1] as any |
| | | const options = currentPage?.options || {} |
| | | |
| | | title.value = decodeURIComponent(options.title || '项目介绍') |
| | | category.value = options.type || '' |
| | | title.value = decodeURIComponent(options?.title || '项目介绍') |
| | | category.value = options?.type || '' |
| | | |
| | | loadProjectIntroductionList() |
| | | }); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 跳转项目介绍详情页。 |
| | | * 跳转项目介绍详情页,加跳转锁避免连续点击触发导航节流告警。 |
| | | */ |
| | | const goToDetail = (id?: number | string | null) => { |
| | | if (navigating.value) { |
| | | return |
| | | } |
| | | navigating.value = true |
| | | uni.navigateTo({ |
| | | url: id |
| | | ? `/pages/good/projectDetail?id=${id}` |
| | | : '/pages/good/projectDetail' |
| | | : '/pages/good/projectDetail', |
| | | complete: () => { |
| | | // 跳转动画结束后再解锁,覆盖 navigateTo 的节流窗口。 |
| | | setTimeout(() => { |
| | | navigating.value = false |
| | | }, 500) |
| | | } |
| | | }); |
| | | }; |
| | | </script> |