var wx_title, wx_desc, wx_link, wx_img; $(document).ready(function(){ if(typeof(wx_title) == "undefined"){ wx_title = document.title; } if(wx_title == "" || typeof(wx_title) == "undefined"){ wx_title = "非特网"; } //title和自定义都未设定时,默认 if(typeof(wx_desc) == "undefined"){ wx_desc = $('meta[name="description"]').attr("content"); } //未设定时,自动取description if(wx_desc == "" || typeof(wx_desc) == "undefined"){ wx_desc = wx_title } //description和自定义都未设定时,默认为title if(typeof(wx_link) == "undefined"){ wx_link = location.href.split('#')[0]; } //链接都未设定时,自动取本页地址 if(wx_link == "" || typeof(wx_link) == "undefined"){ wx_link = "http://www.zzfeite.com" } if(typeof(wx_img) == "undefined"){ wx_img = $(".content img").attr("src"); } //未设定时,取新闻第1张图 if(wx_img == "" || typeof(wx_img) == "undefined"){ wx_img = $("body img").attr("src"); } //没有新闻,取body第1张图 try{if(wx_img.substr(0,4) != "http"){ wx_img=""; }}catch(e){} //取消非全路径 if(wx_img == "" || typeof(wx_img) == "undefined"){ wx_img = "http://www.zzfeite.com/images/wxlogo.png" } //空时默认图 $.getScript("http://res.wx.qq.com/open/js/jweixin-1.6.0.js", function(){runwx();}); }); //document.write(''); function runwx(){ wx.config({ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: 'wx0e20759ae2bea3a6', // 必填,公众号的唯一标识 timestamp: '1773915278', // 必填,生成签名的时间戳 nonceStr: '400698', // 必填,生成签名的随机串 signature: '9620f16874cbf18505b7ce10dde64e1701b3697e', // 必填,签名,见附录1 jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'chooseWXPay', 'getLocation' ,'updateAppMessageShareData', 'updateTimelineShareData', 'openLocation'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); wx.ready(function () { wx.onMenuShareTimeline({ title: wx_title, // 分享标题 link: wx_link, // 分享链接 imgUrl: wx_img, // 分享图标 success: function () { if(typeof(shareok) != "undefined"){ shareok(); } }, cancel: function () {}, fail: function (res) {} }); wx.onMenuShareAppMessage({ title: wx_title, // 分享标题 desc: wx_desc, // 分享描述 link: wx_link, // 分享链接 imgUrl: wx_img, // 分享图标 type: '', // 分享类型,music、video或link,不填默认为link dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 success: function () { if(typeof(shareok) != "undefined"){ shareok(); } }, cancel: function () {}, fail: function (res) {} }); wx.onMenuShareQQ({ title: wx_title, // 分享标题 desc: wx_desc, // 分享描述 link: wx_link, // 分享链接 imgUrl: wx_img, // 分享图标 success: function () { if(typeof(shareok) != "undefined"){ shareok(); } }, cancel: function () {} }); wx.onMenuShareWeibo({ title: wx_title, // 分享标题 desc: wx_desc, // 分享描述 link: wx_link, // 分享链接 imgUrl: wx_img, // 分享图标 success: function () { if(typeof(shareok) != "undefined"){ shareok(); } }, cancel: function () {} }); wx.onMenuShareQZone({ title: wx_title, // 分享标题 desc: wx_desc, // 分享描述 link: wx_link, // 分享链接 imgUrl: wx_img, // 分享图标 success: function () { if(typeof(shareok) != "undefined"){ shareok(); } }, cancel: function () {} }); //分享到朋友圈”及“分享到 QQ 空间” wx.updateTimelineShareData({ title: wx_title, // 分享标题 link: wx_link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: wx_img, },function(res) { //这里是回调函数 }) //“分享给朋友”及“分享到QQ” wx.updateAppMessageShareData({ title: wx_title, // 分享标题 desc: wx_desc, // 分享描述 link: wx_link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: wx_img, // 分享图标 },function(res) { //这里是回调函数 }); if(typeof(getLocation) != "undefined"){ getLocation(); } }); }