微信转发朋友圈功能,目前处于测试阶段,先放个官方文档地址
官方文档地址
先上代码,这是本人实测可以使用的。ps:这个算是特别版的,因为我的项目是vue编译后的代码,用正常的写法不起效,最终测试了这个可行。
onLoad: function(t) {
console.log('option', t)
wx.showShareMenu({
withShareTicket: true,
menus: ["shareAppMessage", "shareTimeline"]
}), this.isLogin && this.$store.dispatch("user/info")
},
onShareAppMessage: function() {
var user_id = this.$store.state.user.info.options.user_id;
return this.$shareAppMessage({
title: this.card.name,
path: "/plugins/vip_card/index/index?user_id=" + user_id ,
})
},
onShareTimeline: function() {
let user_id = this.$store.state.user.info.options.user_id;
let data = {
query: 'user_id='+user_id+'&scene=1155'
}
return data
},
效果图
网上也查询了很多资料,也遇到很多问题。
1,自定义的标题和参数不起作用。
本人使用的是HbuilderX,项目也是有些老旧,在配置文件中,没有配置onShareTimeline选项,所以自定义标题不生效。可以在项目中全局搜索onShareAppMessage,这是分享到朋友,一般都会配置。
2,开发者工具调试
在编译里面,自定义编译条件。我自己是使用真机调试,然后在手机上找到分享页面,分享到朋友圈。退出真机调试,点击朋友圈分享的链接,打开手机的调试,可以在onload位置看打印出来的数据
这是我参考的一些链接
https://www.eoway.cn/article/1607917397.html
https://blog.csdn.net/wm_wu/article/details/107320096
https://blog.csdn.net/usernotdefined/article/details/112464357
https://www.jianshu.com/p/8df132d6f530
https://blog.csdn.net/yang_xin__/article/details/107250107
https://blog.csdn.net/qq_41228789/article/details/107361532
https://www.freesion.com/article/18721179781/
https://developers.weixin.qq.com/community/develop/article/doc/000246d81bc35025e19a814735a413