安卓H5分享可以显示自定义标题,简介,图片,iso H5分享自定义的简介和图片怎么不生效了?
jsapi updateAppMessageShareData
$(document).ready(function () {
// var url = window.location.href.split('#')[0];
// var url = encodeUIRComponent(window.location.href);
var url = window.location.href;
// var url = encodeUIRComponent(window.location.href.split('#')[0]);
var formData = new FormData();
formData.append("url", url);
var opts = {
method: "POST", //请求方法
body: formData, //请求体
headers: {
'Accept': 'application/json'
}
}
fetch('https://xxxx/get-jssdk', opts).then((res) => res.json()).then((result) => {
wx.config({
debug: false, //
appId: result.appId, //
timestamp: result.timestamp, //
nonceStr: result.nonceStr, //
signature: result.signature, //
jsApiList: ["updateAppMessageShareData", "updateTimelineShareData", "onMenuShareTimeline", "onMenuShareAppMessage"] //
});
window.share_config = {
"share": {
title: '图怪兽会打字就能用', // 分享标题
desc: '图怪兽作图神器,不会ps也能做海报,限时190天免费会员随便送,任你体验', // 分享描述
// link: "https://818ps.com/invites.html?shareType=5", // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: 'https://js.tuguaishou.com/img/invitePerson/share_icon.jpg', // 分享图标
success: function() {
// 设置成功
console.log('成功')
}
}
};
wx.ready(function() {
wx.checkJsApi({
jsApiList: ["updateAppMessageShareData", "updateTimelineShareData", "onMenuShareTimeline", "onMenuShareAppMessage"], // 需要检测的JS接口列表,所有JS接口列表见附录2,
success: function(res) {
console.log('check', res);
console.log('成功');
}
});
wx.updateAppMessageShareData(share_config.share);
});
})
})