From 781ceb7ab021d0ed46c0eee7cbe1a19256099830 Mon Sep 17 00:00:00 2001 From: ylj20011123 Date: Fri, 5 Sep 2025 18:37:20 +0800 Subject: [PATCH] update --- App.vue | 6 + components/shopTabbar.vue | 24 +- pages/index/index.vue | 22 +- pages/shopMallPage/index/index.vue | 250 +++++-- pages/shopMallPage/shopCar/index.vue | 86 ++- pages/shopMallPage/shopType/index.vue | 34 +- pages/shopMallPage/user/newIndex.vue | 114 ++-- pages/user/index.vue | 38 +- .../.sourcemap/mp-weixin/common/main.js.map | 2 +- .../.sourcemap/mp-weixin/common/vendor.js.map | 2 +- .../mp-weixin/components/shopTabbar.js.map | 2 +- .../mp-weixin/pages/index/index.js.map | 2 +- .../pages/shopMallPage/index/index.js.map | 2 +- .../pages/shopMallPage/shopCar/index.js.map | 2 +- .../pages/shopMallPage/shopType/index.js.map | 2 +- .../mp-weixin/pages/user/index.js.map | 2 +- unpackage/dist/dev/mp-weixin/common/main.js | 8 +- unpackage/dist/dev/mp-weixin/common/vendor.js | 188 +++++ .../dev/mp-weixin/components/shopTabbar.js | 24 +- .../dist/dev/mp-weixin/pages/index/index.js | 62 +- .../pages/shopMallPage/index/index.js | 646 ++++++++++++------ .../pages/shopMallPage/index/index.wxml | 2 +- .../pages/shopMallPage/shopCar/index.js | 164 +++-- .../pages/shopMallPage/shopCar/index.wxml | 2 +- .../pages/shopMallPage/shopType/index.js | 140 ++-- .../dist/dev/mp-weixin/pages/user/index.js | 204 +++--- utils/skeletonManager.js | 146 ++++ 27 files changed, 1566 insertions(+), 610 deletions(-) create mode 100644 utils/skeletonManager.js 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 @@