微信分享,使用js,分享给朋友,朋友圈,QQ微博
1 <script> 2 var imgUrl = "http://www.baidu.com/img/bdlogo.gif"; 3 var lineLink = "http://www.baidu.com"; 4 var descContent = '亲子游来玩了'; 5 var shareTitle = '我的标题'; 6 var appid = ''; 7 function shareFriend() { 8 WeixinJSBridge.invoke('sendAppMessage',{ 9 "appid": appid, 10 "img_url": imgUrl, 11 "img_width": "200", 12 "img_height": "200", 13 "link": lineLink, 14 "desc": descContent, 15 "title": shareTitle 16 }, function(res) { 17 18 }); 19 } 20 21 function shareTimeline() { 22 WeixinJSBridge.invoke('shareTimeline',{ 23 "img_url": imgUrl, 24 "img_width": "200", 25 "img_height": "200", 26 "link": lineLink, 27 "desc": descContent, 28 "title": shareTitle 29 }, function(res) { 30 31 }); 32 } 33 34 function shareWeibo() { 35 WeixinJSBridge.invoke('shareWeibo',{ 36 "content": descContent, 37 "url": lineLink, 38 }, function(res) { 39 40 }); 41 } 42 43 // 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。 44 document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() { 45 // 发送给好友 46 WeixinJSBridge.on('menu:share:appmessage', function(argv){ 47 shareFriend(); 48 }); 49 // 分享到朋友圈 50 WeixinJSBridge.on('menu:share:timeline', function(argv){ 51 shareTimeline(); 52 }); 53 // 分享到微博 54 WeixinJSBridge.on('menu:share:weibo', function(argv){ 55 shareWeibo(); 56 }); 57 }, false); 58 </script>