feat: 微信分享,全局生效

This commit is contained in:
Burt 2024-01-22 11:01:41 +08:00
parent 70990288c4
commit 15bb8d02f5
3 changed files with 22 additions and 20 deletions

View File

@ -40,6 +40,7 @@
- [x] 导航栏渐变(微信+h5) - [x] 导航栏渐变(微信+h5)
- [x] 自定义导航栏顶部机型适配 - [x] 自定义导航栏顶部机型适配
- [x] 微信小程序分享(好友+朋友圈) - [x] 微信小程序分享(好友+朋友圈)
- [x] 微信小程序分享 - 全局分享
- [ ] 微信登录 - [ ] 微信登录
- [ ] 微信一键登录(基于手机号) - [ ] 微信一键登录(基于手机号)
- [ ] 仿BOSS直聘-个人中心 - [ ] 仿BOSS直聘-个人中心

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app' import { onLaunch, onShow, onHide, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
onLaunch(() => { onLaunch(() => {
console.log('App Launch') console.log('App Launch')
@ -9,6 +9,25 @@ onShow(() => {
}) })
onHide(() => { onHide(() => {
console.log('App Hide') console.log('App Hide')
console.log('App Hide') })
// App.vueTODO: url
/** 激活“分享给好友” */
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((): Page.ShareTimelineContent => {
return {
title: '自定义分享标题',
query: 'a=1&b=2',
}
}) })
</script> </script>

View File

@ -16,24 +16,6 @@
<script setup lang="ts" name="TestIndex"> <script setup lang="ts" name="TestIndex">
import { ref } from 'vue' import { ref } from 'vue'
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
/** 激活“分享给好友” */
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((): Page.ShareTimelineContent => {
return {
title: '自定义分享标题',
query: 'a=1&b=2',
}
})
const list = ref([ const list = ref([
{ {