webApp实现分享功能
首先,在微信的右上角公众号名称->功能设置->js接口安全域名
首先引入:微信接口js,
http://res.wx.qq.com/open/js/jweixin-1.0.0.js
其次,对分享进行一个配置:
wx.config({
debug: true,
appId: 'YOUR_APPID',
timestamp: 1495803333,
nonceStr: 'CvNjcpHIUv755Pcr',
signature: '02f85062d8c1ecd2f66d05b1b988b3b5dffc9da8',
jsApiList: [
'checkJsApi',
'onMenuShareTimeline',
'onMenuShareAppMessage'
]
});
wx.ready(function () {
var shareData = {
title: '这里是分享标题',
desc: '这里是发送给好友的时候的简介',
link: 'http://baidu.com',
imgUrl: 'http://baidu.com/logo.jpg'
};
wx.onMenuShareAppMessage(shareData);
wx.onMenuShareTimeline(shareData);
});
wx.error(function (res) {
alert(res.errMsg);
});