From f869a09c2f0aab34c99ac4888c6ef58e329407bc Mon Sep 17 00:00:00 2001 From: Lj <1095098147@qq.com> Date: Wed, 2 Jul 2025 22:25:40 +0800 Subject: [PATCH] =?UTF-8?q?'=E5=88=86=E4=BA=AB=E5=8A=9F=E8=83=BD'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 7 +++---- pages/component/home.vue | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index d039039..fb1ea58 100644 --- a/main.js +++ b/main.js @@ -27,21 +27,20 @@ export function createApp() { // 全局混入分享 app.mixin({ + //分享给好友 onShareAppMessage() { const userInfo = uni.getStorageSync('userInfo') || {}; - console.log('分享到朋友圈的 shareId:', userInfo); // 打印 shareId const logoName = uni.getStorageSync('logoName') || '' - console.log('logoName',logoName) const logoImage = uni.getStorageSync('logoImage') || '' return { title: '欢迎体验'+(logoName), - path: '/pages/index/index?shareId=' + (userInfo.shareId || ''), + path: '/pages/component/home?shareId=' + (userInfo.shareId || ''), imageUrl: logoImage } }, + //分享到朋友圈 onShareTimeline() { const userInfo = uni.getStorageSync('userInfo') || {}; - console.log('分享到朋友圈的 shareId:', userInfo.shareId); // 打印 shareId return { title: '欢迎体验'+(logoName), query: 'shareId=' + (userInfo.shareId || ''), diff --git a/pages/component/home.vue b/pages/component/home.vue index 0a239d7..4bd4ea8 100644 --- a/pages/component/home.vue +++ b/pages/component/home.vue @@ -584,11 +584,6 @@ }, // 初始化页面数据的方法 initializePageData() { - const query = this.queryParams || {} - - if (query.shareId) { - uni.setStorageSync('shareId', query.shareId) - } // 先设置数据,再调用处理方法 this.pricePreviewList = getApp().globalData.pricePreviewList || [] @@ -612,6 +607,9 @@ onLoad(query) { // 保存query参数 this.queryParams = query + if (query.shareId) { + uni.setStorageSync('shareId', query.shareId) + } // 检查App数据是否已经准备好 if (!getApp().globalData.isAppDataReady) {