feat(分享): 开发微信小程序分享功能

This commit is contained in:
Burt 2024-01-03 14:34:31 +08:00
parent 524f82063d
commit f8f1139dcf
2 changed files with 10 additions and 2 deletions

View File

@ -34,7 +34,7 @@
- [ ] 页面悬浮球 - [ ] 页面悬浮球
- [ ] 导航栏返回or去首页 - [ ] 导航栏返回or去首页
- [ ] 自定义导航栏顶部机型适配 - [ ] 自定义导航栏顶部机型适配
- [ ] 微信小程序分享(好友+朋友圈) - [x] 微信小程序分享(好友+朋友圈)
- [ ] 多tab列表功能 - [ ] 多tab列表功能
- [ ] 抽奖转盘 - [ ] 抽奖转盘

View File

@ -25,7 +25,7 @@ import { ref } from 'vue'
import { useCountStore, useUserStore } from '@/store' import { useCountStore, useUserStore } from '@/store'
import { http } from '@/utils/http' import { http } from '@/utils/http'
import { UserItem } from '@/typings' import { UserItem } from '@/typings'
import { onShareAppMessage } from '@dcloudio/uni-app' import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
const countStore = useCountStore() const countStore = useCountStore()
const title = ref('Hello') const title = ref('Hello')
@ -48,6 +48,7 @@ const handleRequest = () => {
}) })
console.log(res) console.log(res)
} }
/** 激活“分享给好友” */
onShareAppMessage((options: Page.ShareAppMessageOption): Page.CustomShareContent => { onShareAppMessage((options: Page.ShareAppMessageOption): Page.CustomShareContent => {
console.log('options:', options) console.log('options:', options)
return { return {
@ -57,6 +58,13 @@ onShareAppMessage((options: Page.ShareAppMessageOption): Page.CustomShareContent
'https://cip-shopping-page-0eysug01066a9e-1302818703.tcloudbaseapp.com/pretty-girl.png', 'https://cip-shopping-page-0eysug01066a9e-1302818703.tcloudbaseapp.com/pretty-girl.png',
} }
}) })
/** 激活“分享到朋友圈”, 注意:需要先激活“分享给好友” */
onShareTimeline((): Page.ShareTimelineContent => {
return {
title: '自定义分享标题',
query: 'a=1&b=2',
}
})
</script> </script>
<style> <style>