微信小程序的转发分两张情况
1.自定义的转发按钮
2.小程序自带的右上角的转发按钮
小程序 API https://developers.weixin.qq.com/miniprogram/dev/api/share.html
下图是自定义的转发按钮


xml
<view class='fl' style='width:55rpx;height:55rpx;margin-left:50%; margin-top:-10rpx;'><button class='form_button' open-type="share"><image src='/images/icon/share.png'style='width:55rpx;height:55rpx;'></image></button>
</view> 
js
onShareAppMessage: function (res) {var that = this;console.log("openid" + wx.getStorageSync("openid"))if (res.from === "button") {console.log("来自页面内转发按钮");console.log(res.target);} else {console.log("来自右上角转发菜单")}return {title: '嘿,装修',path: '/pages/activity/userDetail / userDetail?articleid=' + that.data.articleid + '&shareid=' + wx.getStorageSync("openid"),success: (res) => {console.log("转发成功", res);},fail: (res) => {console.log("转发失败", res);}}}, 
js中做了两种转发的判断,仅供参考,以后有机会会补上更全面的代码段











