在要分享的界面加上这段代码
onShareAppMessage: function (options) { var that = this; // var return_url = that.data.shareWeb; var return_url = \'https://testapi.zhenaicx.com/activityH5/invite.html?1=1\' var ol1 = return_url.split("?")[0] var ol2 = return_url.split("?")[1]; // return_url = ol1 + \'#\' + ol2; var srr = [{ ol1: ol1, ol2: ol2 }] return_url = JSON.stringify(srr) var path = \'pages/My/ShareUrl/shareUrl?shareUrl=\' + return_url //小程序存放分享页面的内嵌网页路径 console.log(path, options) return { title: \'朕爱出行\', path: path, success: function (res) { // 转发成功 wx.showToast({ title: "转发成功", icon: \'success\', duration: 2000 }) }, fail: function (res) { // 转发失败 } } },
在分享的界面接受代码如下
onLoad: function (options) { console.log(options) var str2 = options.shareUrl; var str = JSON.parse(options.shareUrl) let that = this; that.setData({ shareH5Url: str[0].ol1 + "?" + str[0].ol2, }) },