hejianhao
2026-08-21 9ec88c0ef18f91489b757bf9f23267beb8324339
fix0806: APP项目中心没有传参导致数据异常
2个文件已修改
49 ■■■■■ 已修改文件
traditionalApp/pages/good/projectDetail.vue 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
traditionalApp/pages/good/projectList.vue 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
traditionalApp/pages/good/projectDetail.vue
@@ -52,7 +52,8 @@
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app'
import { getProjectIntroductionDetail } from './service'
interface ProjectIntroductionDetail {
@@ -73,21 +74,17 @@
const projectId = ref('')
/**
 * 页面加载时初始化。
 * 页面加载时通过 onLoad 接收跳转参数并拉取详情。
 * onLoad 的 options 由框架跨端保证一致,避免打包后 getCurrentPages().options 取不到 id 导致不请求接口。
 */
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 || {}
    projectId.value = options.id || ''
    projectId.value = options?.id || ''
    if (projectId.value) {
        loadProjectIntroductionDetail()
traditionalApp/pages/good/projectList.vue
@@ -27,8 +27,8 @@
</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 {
@@ -46,24 +46,22 @@
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()
});
@@ -106,13 +104,23 @@
}
/**
 * 跳转项目介绍详情页。
 * 跳转项目介绍详情页,加跳转锁避免连续点击触发导航节流告警。
 */
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>