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) {