diff --git a/App.vue b/App.vue index e455bba3..d0560cf8 100644 --- a/App.vue +++ b/App.vue @@ -16,6 +16,11 @@ export default { }, onLaunch: function (options) { console.log("onLaunch", options); + + // 设置应用启动时间戳,用于骨架屏管理 + this.globalData.appLaunchTime = Date.now() + console.log('应用启动时间:', this.globalData.appLaunchTime) + this.setVisitChannels(options.scene); this.handleGetUserInfo(); let _this = this; @@ -181,6 +186,7 @@ export default { }, globalData: { initReady: null, // 用于页面等待初始化完成 + appLaunchTime: null, // 应用启动时间戳,用于骨架屏管理 }, }; diff --git a/components/shopTabbar.vue b/components/shopTabbar.vue index b80c9331..62ed969d 100644 --- a/components/shopTabbar.vue +++ b/components/shopTabbar.vue @@ -116,15 +116,19 @@ export default { } if (pageIndex === '/pages/shopMallPage/index/index') { - if (this.comeForm === 'index') { - uni.redirectTo({ - url: '/pages/shopMallPage/index/index', - }); - } else { - uni.navigateBack({ - delta: 1, - }); - } + // console.log('this.comeFormthis.comeFormthis.comeForm', this.comeForm); + uni.redirectTo({ + url: `/pages/shopMallPage/index/index?pageType=${this.pageType}`, + }); + // if (this.comeForm === 'index') { + // uni.redirectTo({ + // url: '/pages/shopMallPage/index/index', + // }); + // } else { + // uni.navigateBack({ + // delta: 1, + // }); + // } } else if (pageIndex === "/pages/shopMallPage/shopCar/index") { if (!this.user && !this.user.MEMBERSHIP_ID) { @@ -151,7 +155,7 @@ export default { // 判断是不是在购物车里面 2 表示工会商城 1 表示精选商城 uni.setStorageSync("inShop", this.pageType ? 2 : 1) uni.navigateTo({ - url: "/pages/shopMallPage/user/newIndex", + url: `/pages/shopMallPage/user/newIndex?pageType=${this.pageType}`, }) } else { if (this.selectIndex === '/pages/shopMallPage/index/index') { diff --git a/pages/index/index.vue b/pages/index/index.vue index 612f17ad..fdbda155 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -448,11 +448,13 @@ import { getDistanceBetweenCoordinates } from '../../utils/publicMethods' import { encryptAES, decryptAES } from '../../utils/handleAes' +import { useSkeletonControl } from '../../utils/skeletonManager.js' export default { components: { tabbar }, data() { return { isPageLoading: true, + skeletonControl: null, // 骨架屏控制器 menu: {}, funList: [ { @@ -615,7 +617,11 @@ export default { everyWeekShopData: [],// 每周特惠数据 }; }, - async onLoad() { + async onLoad(options) { + // 初始化骨架屏控制 + this.skeletonControl = useSkeletonControl('/pages/index/index', options.pageType) + this.isPageLoading = this.skeletonControl.showSkeleton + // if (!this.user.MEMBERSHIP_ID) { // uni.navigateTo({ url: `/pages/register/index?backTo=index` }); // } @@ -689,7 +695,14 @@ export default { }); // 所有数据加载完成,隐藏骨架屏 - this.isPageLoading = false; + if (this.skeletonControl && this.skeletonControl.showSkeleton) { + // 如果是首次访问,延迟隐藏骨架屏并标记已访问 + await this.skeletonControl.showContentAfterLoading(500) + this.isPageLoading = false + } else { + // 非首次访问直接显示内容 + this.isPageLoading = false + } // 骨架屏结束后显示广告弹窗 this.$nextTick(() => { @@ -710,6 +723,11 @@ export default { }); }, async onShow() { + // onShow 中不控制骨架屏,骨架屏只在 onLoad 中控制一次 + // 如果不是首次加载,直接显示内容 + if (!this.isPageLoading && this.skeletonControl && !this.skeletonControl.showSkeleton) { + // 非首次访问,确保内容显示 + } let currentService = uni.getStorageSync("currentService"); if (currentService) { await this.handleGetServiceDetail(currentService.SERVERPART_ID); diff --git a/pages/shopMallPage/index/index.vue b/pages/shopMallPage/index/index.vue index db7aefb6..81773f23 100644 --- a/pages/shopMallPage/index/index.vue +++ b/pages/shopMallPage/index/index.vue @@ -1,6 +1,7 @@