1、进页面需要先加载wx.config,并添加需要使用的 JS接口列表:
wx.config({
debug: false,
appId: '${app_id}',
timestamp: "${timestamp}",
nonceStr: "${nonceStr}",
signature: "${signature}",
jsApiList: ['previewImage', 'downloadImage', 'checkJsApi',
'onMenuShareTimeline',
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo',
'onMenuShareQZone',
]
});
2、实现分享参数信息设置:
wx.ready(function() {
wxShare(initTitle, inviteLink, initStartUnix);
});
function wxShare(title, link, time) {
var ibt = UnixToDate(time);
wx.onMenuShareTimeline({
title: title,
link: link,
imgUrl: basePath + "image/share_icon_event.png",
success: onShareSuccess(),
cancel:onShareCancel(),
});
wx.onMenuShareAppMessage({
title: title,
link: link,
imgUrl: basePath + "image/share_icon_event.png",
desc: "来自:" + $("#invite_nickname").val() + "\n" + "时间:" + ibt.mo + "月" + ibt.d + "日 " + ibt.h + ":" + ibt.mi + "\n" + "点击查看详情",
type: 'link',
success: onShareSuccess(),
cancel:onShareCancel(),
});
}
function onShareSuccess() {
}
function onShareCancel() {
}