设置微信分享的标题 缩略图 连接 描述

javascript 专栏收录该内容
42 篇文章 0 订阅
  1. <script>
  2. var imgUrl = 'http://topic.xcar.com.cn/201403/ad_q3/pic/banner.jpg';
  3. var lineLink = 'http://topic.xcar.com.cn/201403/ad_q3/index.php';
  4. var descContent = "http://topic.xcar.com.cn/201403/ad_q3/index.php";
  5. var shareTitle = '【奥迪Q3开启尊享礼遇季】报名试驾,赢取精美礼品';
  6. var appid = 'wxc9937e3a66af6dc8';
  7. function shareFriend() {
  8. WeixinJSBridge.invoke('sendAppMessage',{
  9. "appid": appid,
  10. "img_url": imgUrl,
  11. "img_width": "640",
  12. "img_height": "640",
  13. "link": lineLink,
  14. "desc": descContent,
  15. "title": shareTitle
  16. }, function(res) {
  17. _report('send_msg', res.err_msg);
  18. })
  19. }
  20. function shareTimeline() {
  21. WeixinJSBridge.invoke('shareTimeline',{
  22. "img_url": imgUrl,
  23. "img_width": "640",
  24. "img_height": "640",
  25. "link": lineLink,
  26. "desc": descContent,
  27. "title": shareTitle
  28. }, function(res) {
  29. _report('timeline', res.err_msg);
  30. });
  31. }
  32. function shareWeibo() {
  33. WeixinJSBridge.invoke('shareWeibo',{
  34. "content": descContent,
  35. "url": lineLink,
  36. }, function(res) {
  37. _report('weibo', res.err_msg);
  38. });
  39. }
  40. // 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
  41. document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
  42. // 发送给好友
  43. WeixinJSBridge.on('menu:share:appmessage', function(argv){
  44. shareFriend();
  45. });
  46. // 分享到朋友圈
  47. WeixinJSBridge.on('menu:share:timeline', function(argv){
  48. shareTimeline();
  49. });
  50. // 分享到微博
  51. WeixinJSBridge.on('menu:share:weibo', function(argv){
  52. shareWeibo();
  53. });
  54. }, false);
  55. </script>