weixin js接口

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="blog.anchen8.net" />

<title>无标题 1</title>
</head>

<body>

<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
///////////微信分享
$(document).ready(function() {
var title='事实证明:多彩人生值得加入!我们在拉勾招牛人!';
var desc='我们公司正在拉勾上招募小伙伴,感兴趣的就戳进来看看吧!';
var url = 'http://c.lagou.com/cs/march/show/37401.html';
var img = 'http://c.lagou.com/upload/sharelogo/37401.jpg';
var companyId = '37401';

wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: "wxbffbd15772cd6152", // 必填,公众号的唯一标识
timestamp:"1432287821", // 必填,生成签名的时间戳
nonceStr: "14d72a31-760f-4a01-955c-9e8feac39c6b", // 必填,生成签名的随机串
signature: "081764e6f982bc40408617881690bf3a5f8e28fb",// 必填,签名,见附录1
jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
});
wx.ready(function(){
wx.checkJsApi({
jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
success: function(res) {
}
});

wx.error(function(res){
//alert(res);
//config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
});

wx.onMenuShareTimeline({ // 分享到朋友圈
title: title, // 分享标题
desc: desc, // 分享描述
link: url, // 分享链接
imgUrl:img, // 分享图标
success: function () {
// 用户确认分享后执行的回调函数
window.location.href="http://www.lagou.com/center/company_"+companyId+".html";
},
cancel: function () {
// 用户取消分享后执行的回调函数
//alert('cancel');
}
});

wx.onMenuShareAppMessage({// 分享给好友
title: title, // 分享标题
desc: desc, // 分享描述
link: url, // 分享链接
imgUrl:img, // 分享图标
success: function () {
// 用户确认分享后执行的回调函数
window.location.href="http://www.lagou.com/center/company_"+companyId+".html";
},
cancel: function () {
// 用户取消分享后执行的回调函数
}
});
});
});
</script>

</body>
</html>

原文地址:https://www.cnblogs.com/liuwenbohhh/p/4523000.html