In the js page of the applet, if you write the method, click the three "···" in the upper right corner and there will be a corresponding sharing menu. If you don't write it, it is actually equivalent to disabling the sharing of the page. If it’s just a method without configuration, the default style will be shared. Here’s how to configure it:
onShareAppMessage: function (ops) {
//转发事件来源。
//button:页面内转发按钮;
//menu:右上角转发菜单
if (ops.from === 'button') {
var title = ops.target.dataset.title;
};
return {
title: title, //转发的标题。当前小程序名称
path: `pages/ordinaryDetails/ordinaryDetails?isShare=0`, //转发的路径
imageUrl: '',//自定义图片路径 支持PNG及JPG。显示图片长宽比是 5:4。
// success: function (res) {
// // 转发成功
// var shareTickets = res.shareTickets;
// api.showToast('转发成功');
// },
// fail: function (res) {
// // 转发失败
// api.showToast("转发失败:" + JSON.stringify(res));
// }
//由于版本更新,现在不能监听回调成功还是失败。
//分享的内容是都会被成功发出
//如果一定要回调的话可根据需求自定,目前小编还没有更好的办法。
}
},