diff --git a/miniprogram/app.ts b/miniprogram/app.ts index 86b4dce..1b89bc3 100644 --- a/miniprogram/app.ts +++ b/miniprogram/app.ts @@ -1,6 +1,17 @@ // app.ts +// import { BASE_URL, appId } from './env' + +// const DEFAULT_SHARE_CONFIG = { +// title: '吉林敖东控糖胶囊 辅助降血糖', +// imageUrl: '/pages/index/assets/test.jpg', +// } + App({ - globalData: {}, + globalData: { + // shareConfig: { ...DEFAULT_SHARE_CONFIG }, + }, + + onLaunch() { const updateManager = wx.getUpdateManager() @@ -35,7 +46,28 @@ App({ const envVersion = wx.getAccountInfoSync().miniProgram.envVersion if (envVersion !== 'release') { wx.reLaunch({ url: '/pages/tools/index' }) + return } + // this.fetchShareConfig() + }, + // fetchShareConfig() { + // wx.request({ + // url: `${BASE_URL}/api/ad/ww-join-fans/share/${appId}`, + // method: 'GET', + // success: (res: any) => { + // const data = res.data?.data ?? res.data + // if (data?.title || data?.imageUrl) { + // this.globalData.shareConfig = { + // title: data.title || DEFAULT_SHARE_CONFIG.title, + // imageUrl: data.imageUrl || DEFAULT_SHARE_CONFIG.imageUrl, + // } + // } + // }, + // fail: () => { + // // 请求失败时继续使用默认分享文案和背景图 + // }, + // }) + // }, }) diff --git a/miniprogram/pages/index/index.ts b/miniprogram/pages/index/index.ts index 64e4f49..ce8678a 100644 --- a/miniprogram/pages/index/index.ts +++ b/miniprogram/pages/index/index.ts @@ -1,6 +1,7 @@ // index.ts import { BASE_URL, appId } from '../../env' + Component({ data: { showPopup: false, @@ -17,16 +18,18 @@ Component({ methods: { // 转发给好友 onShareAppMessage() { + return { - title: '吉林敖东控糖胶囊 辅助降血糖 ¥89.22起', - path: '/pages/index/index', + title: '吉林敖东控糖胶囊 辅助降血糖', + imageUrl: '/pages/index/assets/test.jpg', } }, // 分享到朋友圈 onShareTimeline() { + return { - title: '吉林敖东控糖胶囊 辅助降血糖 ¥89.22起', + title: '吉林敖东控糖胶囊 辅助降血糖', imageUrl: '/pages/index/assets/test.jpg', } }, diff --git a/typings/index.d.ts b/typings/index.d.ts index 3ee60c8..6261029 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3,6 +3,11 @@ interface IAppOption { globalData: { userInfo?: WechatMiniprogram.UserInfo, + // shareConfig: { + // title: string, + // imageUrl: string, + // } } + // fetchShareConfig:any, userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback, } \ No newline at end of file