1.控制分享的内容,定制分享到朋友圈和分享给朋友的内容
var title = "分享百度"; var img_url = "http://g.hiphotos.baidu.com/baike/c0%3Dbaike80%2C5%2C5%2C80%2C26/sign=aea27efc67380cd7f213aabfc02dc651/a5c27d1ed21b0ef405091912dfc451da80cb3e9c.jpg"; var link = "http://www.baidu.com"; var desc = "把分享链接改为百度地址"; document.addEventListener(‘WeixinJSBridgeReady‘, function onBridgeReady() { // 发送给好友 WeixinJSBridge.on(‘menu:share:appmessage‘, function (argv) { WeixinJSBridge.invoke(‘sendAppMessage‘, { "appid": "123", "img_url": img_url, "img_width": "160", "img_height": "160", "link": link, "desc": desc, "title": title }, function (res) { _report(‘send_msg‘, res.err_msg); }) }); // 分享到朋友圈 WeixinJSBridge.on(‘menu:share:timeline‘, function (argv) { WeixinJSBridge.invoke(‘shareTimeline‘, { "img_url":img_url, "img_width": "160", "img_height": "160", "link": link, "desc": desc, "title": title }, function (res) { _report(‘timeline‘, res.err_msg); }); }); }, false)
2.关闭微信内置的浏览器,回到聊天窗口
<input type="button" value="关闭本窗口" onclick="WeixinJSBridge.call(‘closeWindow‘);" />
3.待续