微信小程序7月7日的时候悄悄上线了分享到朋友圈功能,目前还是beta版本。
点击右上角图标弹出分享对话框如下图:
朋友圈中展示效果如下图:
目前小程序分享到朋友圈有以下2个限制:
a.仅支持Android平台,ios平台暂不支持
b.微信基础库限制2.11.3及以上
开发者设置分享小程序到朋友圈,有2种方式:
wx.showShareMenu(),支持快速分享到朋友圈使用默认小程序标题,分享图为小程序logo,不可自定义参数。(uni-app已支持)
wx.showShareMenu({ menus: ['shareAppMessage', 'shareTimeline'] //shareAppMessage必须得有 })
onShareTimeline(),支持自定义分享到朋友圈的小程序标题、分享图,自定义query参数。(uni-app截止发文暂不支持)
//注意必须得设置允许“发送给朋友”onShareAppMessage,是设置onShareTimeline的前提,否则不支持分享到朋友圈
onShareAppMessage: function () { return { title: "测试小程序朋友圈分享", path: "/pages/article/article?id="+id, imageUrl: "https://example.cn/test.png" } }, onShareTimeline: function () { return { title: "测试小程序朋友圈分享", query: "/pages/article/article?id="+id, imageUrl: "https://example.cn/test.png" } },