微信分享
<script type="text/javascript"> // var params = location.href.substring(location.href.indexOf('?')+1).split('='); //var userId = params[1] || '0'; function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } //二次分享时,微信会自动在url后加上&from=singlemessage&isappinstalled=0 var from = getQueryString('from'); var appinstall = getQueryString('appinstall'); var sec = getQueryString('sec'); var timekey = getQueryString('timekey'); if(from || appinstall || sec || timekey) { var tender_id = getQueryString('id'); window.location.href = "/activity/breakbillion/index.html"; } function goWXShare() { //二次分享时,微信会自动在url后加上&from=singlemessage&isappinstalled=0 var wechatUrl = "/wechat/jssdk/config"; var callBackUrl="/activity/breakbillion/index.html"; $.ajax({ url: wechatUrl, type: "POST", data: {acturl: encodeURI(callBackUrl)}, cache: false, success: function (msg) { if (msg.code == '200') { wx.config({ debug: false, // 关闭调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: msg.data.appId, // 必填,公众号的唯一标识 timestamp: msg.data.timestamp, // 必填,生成签名的时间戳 nonceStr: msg.data.nonceStr, // 必填,生成签名的随机串 signature: msg.data.signature, // 必填,签名,见附录1 jsApiList: [ // 所有要调用的 API 都要加到这个列表中 'onMenuShareTimeline', 'onMenuShareAppMessage' ] }); wx.ready(function () { wx.onMenuShareTimeline({ title: '交易额破亿,重磅谢礼', // 分享标题 desc: '惊喜16.3%预期收益+3000元京东E卡,抱金放大招啦!交易额破亿,重磅谢礼。限时一周,速速来抢!', // 分享说明 link: window.location.href, // 分享链接 imgUrl: 'http://image.baojinjinfu.com/data/mbaojin/images/activity/poyi.png', // 分享图标 success: function (msg) { $.ajax({ url: callBackUrl, type: "get", data: {}, cache: false, success: function (data) { } }); } }); wx.onMenuShareAppMessage({ title: '交易额破亿,重磅谢礼', // 分享标题 desc: '惊喜16.3%预期收益+3000元京东E卡,抱金放大招啦!交易额破亿,重磅谢礼。限时一周,速速来抢!', // 分享说明 link: window.location.href, // 分享链接 imgUrl: 'http://image.baojinjinfu.com/data/mbaojin/images/activity/poyi.png', // 分享图标 type: '', // 分享类型,music、video或link,不填默认为link dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 success: function (msg) { $.ajax({ url: callBackUrl, type: "get", data: {}, cache: false, success: function (data) { } }); } }); }); } } }); } goWXShare()