diff --git a/README.md b/README.md index cea05b4..3039aa0 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ - [ ] 页面悬浮球 - [ ] 导航栏返回or去首页 - [ ] 自定义导航栏顶部机型适配 -- [ ] 微信小程序分享(好友+朋友圈) +- [x] 微信小程序分享(好友+朋友圈) - [ ] 多tab列表功能 - [ ] 抽奖转盘 diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index f0407b7..10a3640 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -25,7 +25,7 @@ import { ref } from 'vue' import { useCountStore, useUserStore } from '@/store' import { http } from '@/utils/http' import { UserItem } from '@/typings' -import { onShareAppMessage } from '@dcloudio/uni-app' +import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app' const countStore = useCountStore() const title = ref('Hello') @@ -48,6 +48,7 @@ const handleRequest = () => { }) console.log(res) } +/** 激活“分享给好友” */ onShareAppMessage((options: Page.ShareAppMessageOption): Page.CustomShareContent => { console.log('options:', options) return { @@ -57,6 +58,13 @@ onShareAppMessage((options: Page.ShareAppMessageOption): Page.CustomShareContent 'https://cip-shopping-page-0eysug01066a9e-1302818703.tcloudbaseapp.com/pretty-girl.png', } }) +/** 激活“分享到朋友圈”, 注意:需要先激活“分享给好友” */ +onShareTimeline((): Page.ShareTimelineContent => { + return { + title: '自定义分享标题', + query: 'a=1&b=2', + } +})