var getAppid=function(){$.ajax({url: "http://bos.foreverlynn.com/weixin/getWXUrl",dataType: "jsonp",data: {url: window.location.href},success: function (res) {if (res.code != '200') {}wx.config({debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。appId: res.data.result.appId, // 必填,公众号的唯一标识timestamp: res.data.result.timestamp, // 必填,生成签名的时间戳nonceStr: res.data.result.nonceStr, // 必填,生成签名的随机串signature: res.data.result.signature,// 必填,签名jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage','startRecord','stopRecord','onVoiceRecordEnd','playVoice','pauseVoice','stopVoice','onVoicePlayEnd','uploadVoice','downloadVoice','chooseImage','previewImage','uploadImage','downloadImage'] // 必填,需要使用的JS接口列表});}, error: function (error) {console.log(error)}});}getAppid();wx.ready(function () {// 在这里调用 APIwx.onMenuShareAppMessage({title: "寻找杭州50位最具品位的人", // 分享标题desc: "第六空间搞设计了!严选50位大咖级设计师,为你打造杭州50座醉美私宅。", // 分享描述imgUrl: "http://ovfllimsi.bkt.clouddn.com/logo.png", // 分享图标success: function () {// 用户确认分享后执行的回调函数},cancel: function () {// 用户取消分享后执行的回调函数}});wx.onMenuShareTimeline({title: "寻找杭州50位最具品位的人", // 分享标题desc: "第六空间搞设计了!严选50位大咖级设计师,为你打造杭州50座醉美私宅。", // 分享描述imgUrl: "http://ovfllimsi.bkt.clouddn.com/logo.png", // 分享图标success: function () {// 用户确认分享后执行的回调函数},cancel: function () {// 用户取消分享后执行的回调函数}});wx.error(function(res){console.log(res);});});
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115
微信官方文档