function shareConfig(title, desc, link, imgUrl) {
if(!window.wx) return;
// 分享给朋友
wx.onMenuShareAppMessage({
title: title,
desc: desc,
link: link,
imgUrl: imgUrl,
success: function(res) {
if(isCanChouJiang)
{console.log("分享成功");}
},
fail: function(res) {
}
});
// 分享到朋友圈
wx.onMenuShareTimeline({
title: desc,
desc: desc,
link: link,
imgUrl: imgUrl,
success: function(res) {
if(isCanChouJiang)
{console.log("分享成功");}
},
fail: function(res) {
}
});
// 分享到QQ
wx.onMenuShareQQ({
title: title,
desc: desc,
link: link,
imgUrl: imgUrl,
success: function(res) {
if(isCanChouJiang)
{console.log("分享成功");}
},
fail: function(res) {
}
});
// 分享到微博
wx.onMenuShareWeibo({
title: title,
desc: desc,
link: link,
imgUrl: imgUrl,
success: function(res) {
if(isCanChouJiang)
{console.log("分享成功");}
},
fail: function(res) {
}
});
}
function wxInit() {
if (http.readyState == 4 && http.status == 200) {
var d = http.responseText;
var obj = JSON.parse(d);
wx.config({
debug: false,
appId: 'wx8923c424f092e0af',
timestamp: obj.timestamp,
nonceStr: obj.nonceStr,
signature: obj.signature,
jsApiList: [
'checkJsApi',
'onMenuShareTimeline',
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo'
]
});
wx.ready(function() {
playMusic();
shareConfig(title, desc, link, imgUrl);
});
}
}
window.onload = function() {
if (!http) {
alert('您的浏览器不支持AJAX!');
return;
}
var url = "http://www.baidu.com:8889/get_sign?game_url=" + encodeURIComponent(location.href).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
http.open("GET", url, true);
http.onreadystatechange = wxInit;
http.send();
};
cocos2d-js微信分享客户端代码
最新推荐文章于 2022-10-09 14:28:14 发布