From 9090c571d40536210505f73d34cb85651ee96b4f Mon Sep 17 00:00:00 2001 From: Burt <1020103647@qq.com> Date: Mon, 22 Jan 2024 11:18:04 +0800 Subject: [PATCH] chore: chore update --- src/App.vue | 1 - src/hooks/useWeixinShare.ts | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/hooks/useWeixinShare.ts diff --git a/src/App.vue b/src/App.vue index 944e6de..a38b1f7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,6 +9,5 @@ onShow(() => { }) onHide(() => { console.log('App Hide') - console.log('App Hide') }) diff --git a/src/hooks/useWeixinShare.ts b/src/hooks/useWeixinShare.ts new file mode 100644 index 0000000..47880c2 --- /dev/null +++ b/src/hooks/useWeixinShare.ts @@ -0,0 +1,25 @@ +import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app' + +export default () => { + return { + /** 激活“分享给好友” */ + onShareAppMessage: onShareAppMessage( + (options: Page.ShareAppMessageOption): Page.CustomShareContent => { + console.log('options:', options) + return { + title: '自定义分享标题', + path: '/pages/index/index?id=xxx', + imageUrl: + 'https://cip-shopping-page-0eysug01066a9e-1302818703.tcloudbaseapp.com/pretty-girl.png', + } + }, + ), + /** 激活“分享到朋友圈”, 注意:需要先激活“分享给好友” */ + onShareTimeline: onShareTimeline((): Page.ShareTimelineContent => { + return { + title: '自定义分享标题', + query: 'a=1&b=2', + } + }), + } +}