wx_share.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. wx.ready(function(){
  2. //分享到 qq 和朋友
  3. wx.updateAppMessageShareData({
  4. title: share_info.title, // 分享标题
  5. desc: share_info.desc, // 分享描述
  6. link: share_info.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  7. imgUrl: share_info.imgUrl, // 分享图标
  8. success: function () {
  9. console.log('timeline');
  10. }
  11. });
  12. //分享到 qq空间 和朋友圈
  13. wx.updateTimelineShareData({
  14. title: share_info.title, // 分享标题
  15. link: share_info.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  16. imgUrl: share_info.imgUrl, // 分享图标
  17. success: function () {
  18. console.log('timeline');
  19. }
  20. });
  21. //分享到朋友圈 即将废弃
  22. wx.onMenuShareTimeline({
  23. title: share_info.title, // 分享标题
  24. link: share_info.link, // 分享链接
  25. imgUrl: share_info.imgUrl, // 分享图标
  26. success: function () {
  27. // 用户确认分享后执行的回调函数
  28. console.log('timeline');
  29. },
  30. cancel: function () {
  31. // 用户取消分享后执行的回调函数
  32. }
  33. });
  34. //分享给朋友 即将废弃
  35. wx.onMenuShareAppMessage({
  36. title: share_info.title, // 分享标题
  37. desc: share_info.desc, // 分享描述
  38. link: share_info.link, // 分享链接
  39. imgUrl: share_info.imgUrl, // 分享图标
  40. type: '', // 分享类型,music、video或link,不填默认为link
  41. dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
  42. success: function () {
  43. // 用户确认分享后执行的回调函数
  44. console.log('appmessage');
  45. },
  46. cancel: function () {
  47. // 用户取消分享后执行的回调函数
  48. }
  49. });
  50. //分享到qq 即将废弃
  51. wx.onMenuShareQQ({
  52. title: share_info.title, // 分享标题
  53. desc: share_info.desc, // 分享描述
  54. link: share_info.link, // 分享链接
  55. imgUrl: share_info.imgUrl, // 分享图标
  56. success: function () {
  57. // 用户确认分享后执行的回调函数
  58. console.log('qq');
  59. },
  60. cancel: function () {
  61. // 用户取消分享后执行的回调函数
  62. }
  63. });
  64. //分享到微博
  65. wx.onMenuShareWeibo({
  66. title: share_info.title, // 分享标题
  67. desc: share_info.desc, // 分享描述
  68. link: share_info.link, // 分享链接
  69. imgUrl: share_info.imgUrl, // 分享图标
  70. success: function () {
  71. // 用户确认分享后执行的回调函数
  72. console.log('weibo');
  73. },
  74. cancel: function () {
  75. // 用户取消分享后执行的回调函数
  76. }
  77. });
  78. //分享到qq控件 即将废弃
  79. wx.onMenuShareQZone({
  80. title: share_info.title, // 分享标题
  81. desc: share_info.desc, // 分享描述
  82. link: share_info.link, // 分享链接
  83. imgUrl: share_info.imgUrl, // 分享图标
  84. success: function () {
  85. // 用户确认分享后执行的回调函数
  86. console.log('qzone');
  87. },
  88. cancel: function () {
  89. // 用户取消分享后执行的回调函数
  90. }
  91. });
  92. });