问题描述:
使用微信浏览器打开页面静态html页面,通过ajax获取后端数据,拿到数据处理后作为微信分享的字段,再分享。
var shareInfo = {
image: 'http://ubmcmm.baidustatic.com/media/v1/0f000DTw8MgHL5tiwQ8CC0.png',
url: 'http://www.baidu.com',
title: '测试标题一',
desc: '描述呵呵哒',
title2: '朋友圈的标题'
};
var weixinReadyCallback = function(shareInfo) {
// 发送给好友
WeixinJSBridge.on('menu:share:appmessage', function(argv) {
WeixinJSBridge.invoke('sendAppMessage', {
'img_url': shareInfo.image,
'link': shareInfo.url,
'desc': shareInfo.desc,
'title': shareInfo.title,
}, function(res) {
_report('send_msg', res.err_msg);
});
});
// 分享到朋友圈
WeixinJSBridge.on('menu:share:timeline', function(argv) {
WeixinJSBridge.invoke('shareTimeline', {
'img_url': shareInfo.image,
'link': shareInfo.url,
'desc': shareInfo.desc,
'title': shareInfo.title2,
}, function(res) {
_report('timeline', res.err_msg);
});
});
};
//这样根本不可以的
setTimeout(function() {
shareInfo.title = 'title';
shareInfo.title2 = 'title2';
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
weixinReadyCallback();
}, false);
}, 2000);
目前好像没有什么办法。。。
开发文档中说不能做异步分享,因为分享的时候ajax的回包还没有返回,类似H5游戏排名什么的应该是伪造的。