<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
$.ajax({
url: '//XX网址接口/v2/jsapi_ticket/?url=' + encodeURIComponent(location.href.split('#')[0]),
type: 'get',
dataType: 'json',
success: function (resp) {
wx.config({
debug: false,
appId: resp.appId,
timestamp: resp.timestamp,
nonceStr: resp.nonceStr,
signature: resp.signature,
jsApiList: [
'onMenuShareTimeline',
'onMenuShareAppMessage'
]
});
wx.ready(function () {
var shareData = {
title: 'XXX', // 标题
desc: 'XXX', // 描述
link: location.href, // 分享的URL,必须和当前打开的网页的URL是一样的
imgUrl: 'XXX' // 缩略图地址
};
wx.onMenuShareAppMessage(shareData);
wx.onMenuShareTimeline(shareData);
});
}
})
</script>