wx_share.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. wx.ready(function(){
  2. //分享到朋友圈 即将废弃
  3. wx.onMenuShareTimeline({
  4. title: share_info.title, // 分享标题
  5. link: share_info.link, // 分享链接
  6. imgUrl: share_info.imgUrl, // 分享图标
  7. success: function () {
  8. // 用户确认分享后执行的回调函数
  9. console.log('timeline');
  10. },
  11. cancel: function () {
  12. // 用户取消分享后执行的回调函数
  13. }
  14. });
  15. //分享给朋友 即将废弃
  16. wx.onMenuShareAppMessage({
  17. title: share_info.title, // 分享标题
  18. desc: share_info.desc, // 分享描述
  19. link: share_info.link, // 分享链接
  20. imgUrl: share_info.imgUrl, // 分享图标
  21. type: '', // 分享类型,music、video或link,不填默认为link
  22. dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
  23. success: function () {
  24. // 用户确认分享后执行的回调函数
  25. console.log('appmessage');
  26. },
  27. cancel: function () {
  28. // 用户取消分享后执行的回调函数
  29. }
  30. });
  31. //分享到qq 即将废弃
  32. wx.onMenuShareQQ({
  33. title: share_info.title, // 分享标题
  34. desc: share_info.desc, // 分享描述
  35. link: share_info.link, // 分享链接
  36. imgUrl: share_info.imgUrl, // 分享图标
  37. success: function () {
  38. // 用户确认分享后执行的回调函数
  39. console.log('qq');
  40. },
  41. cancel: function () {
  42. // 用户取消分享后执行的回调函数
  43. }
  44. });
  45. //分享到微博
  46. wx.onMenuShareWeibo({
  47. title: share_info.title, // 分享标题
  48. desc: share_info.desc, // 分享描述
  49. link: share_info.link, // 分享链接
  50. imgUrl: share_info.imgUrl, // 分享图标
  51. success: function () {
  52. // 用户确认分享后执行的回调函数
  53. console.log('weibo');
  54. },
  55. cancel: function () {
  56. // 用户取消分享后执行的回调函数
  57. }
  58. });
  59. //分享到qq控件 即将废弃
  60. wx.onMenuShareQZone({
  61. title: share_info.title, // 分享标题
  62. desc: share_info.desc, // 分享描述
  63. link: share_info.link, // 分享链接
  64. imgUrl: share_info.imgUrl, // 分享图标
  65. success: function () {
  66. // 用户确认分享后执行的回调函数
  67. console.log('qzone');
  68. },
  69. cancel: function () {
  70. // 用户取消分享后执行的回调函数
  71. }
  72. });
  73. });