微信小程序分享到朋友圈
截止到目前最新,安卓与iOS均可以分享到朋友圈了,其中iOS是8.0.24版本开始,今天2024-12-24最新的iOS是8.0.54。
import { ref, } from 'vue'
import { onLoad, onShareAppMessage, onShow, onShareTimeline } from '@dcloudio/uni-app'
onShareAppMessage(() => {
return {
title: '自由挪车,让沟通零距离',
path: '/pages/index/index'
}
})
onShareTimeline(() => {
return {
title: '自由挪车,让沟通零距离'
}
})
onLoad((options) => {
const launchOptions = wx.getLaunchOptionsSync()
if(launchOptions.scene === 1155) {
// 通过单页模式打开小程序到达这个页面
return uni.reLaunch({
url: '/pages/index/index'
})
}
if(launchOptions.scene === 1154) {
// 朋友圈打开
isTimelineRef.value = true
} else {
uni.showModal({
title: '提示',
content: '本页面为分享至朋友圈专用页,仅展示无交互。分享时选择朋友圈即可。',
showCancel: false,
success: res => {},
fail: () => {},
complete: () => {}
})
}
// 业务处理
// ...
})
我们的处理方案是单独提供一个分享页面,然后里面做一下处理。
这里主要区分一下场景值,获取方式是wx.getLaunchOptionsSync,相关的场景值是1154与1155。
1154场景值是在朋友圈点击打开的场景,1155是1154后点击打开小程序的场景,因为1155和1154打开的都是同一个页面,我们的业务需要踢到首页去,所以有1155处理,如果你们不需要,则无视1155即可。
另外,说明一下1154的问题。
1154场景值下,无法使用最基础的wx.login,导致鉴权无法正常使用,继而影响到我们的业务后续,所以我们需要区分1155场景来处理。
微信小程序分享到朋友圈处理方案
201

被折叠的 条评论
为什么被折叠?



