小程序-分享到群或好友
客户提出这个需求我也是焦急的,我没有操作过的呀。好吧最后的最后我还是解决了
onShareAppMessage:function(){
var that=this;
return{
title:"活动名称",
path:"/pages/index/index",
success:function(res){
var shareTickets = res.shareTickets;
if( shareTickets == null ){
wx.showToast({
title:"未分享到群",
duration:1500,
icon:"none",
})
};
if(shareTickets.length == 0){
return false;
}else{
//分享群成功后的操作
};
wx.getShareInfo({
shareTicket:shareTickets[0],
success:function(res){
var encryptedData = res.encryptedData;
var iv = res.iv;
}
})
},
fail:function(res2){ },
complete:function(res3){},
}
}
重要的是,需要在onLoad处添加:
onLoad:function(){
//获取转发后的群消息
wx.showShareMenu({
withShareTicket : true,
success:function(){},
fail:function(){}
})
}