微信小程序的分享功能,在最新版库的ide上已经不能拿到分享回调了,官方api也删除了对应的回调函数,看样子是砍掉了,不过真机测试还是可以的,话不多说,上代码:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | onLoad: function(options) {    wx.showShareMenu({            //只有拥有 shareTicket 才能拿到群信息,用户每次转发都会生成对应唯一的shareTicket 。            withShareTicket: true        });},onShareAppMessage: function(res) {        var_this = this;        console.log(res);        if(res.from === ‘button‘) {            // 来自页面内转发按钮            _this.data.shareBtn = true;        } else{            //来自右上角转发            _this.data.shareBtn = false;        }        return{            title: ‘自定义转发标题‘,            path: ‘pages/index/index‘,            complete: function(res) {                console.log(res);                if(res.errMsg == ‘shareAppMessage:ok‘) {                    //分享为按钮转发                    if(_this.data.shareBtn) {                        //判断是否分享到群                        if(res.hasOwnProperty(‘shareTickets‘)) {                            console.log(res.shareTickets[0]);                            //分享到群                            _this.data.isshare = 1;                        } else{                            // 分享到个人                            _this.data.isshare = 0;                        }                    }                } else{                    wx.showToast({                        title: ‘分享失败‘,                    })                    _this.data.isshare = 0;                }            },        }    } | 
原文:https://www.cnblogs.com/cqlb/p/9494897.html