wxShare0.0.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { WxConfig } from './wxConfig'
  2. function funWxShare (ShareTitle = '', ShareText = '', ShareImageUrl = '', link = '') {
  3. const { desc, imgUrl, title } = {
  4. title: ShareTitle,
  5. imgUrl: ShareImageUrl,
  6. desc: ShareText
  7. }
  8. // 低版本微信兼容
  9. const appMessage = {
  10. title: title, // 分享标题
  11. desc: desc, // 分享描述
  12. link: link, // 分享链接
  13. imgUrl: imgUrl, // 分享图标
  14. success: function () {
  15. },
  16. cancel: function () {
  17. }
  18. }
  19. const timeline = {
  20. title: desc, // 分享标题
  21. link: link, // 分享链接
  22. imgUrl: imgUrl, // 分享图标
  23. success: function () {
  24. },
  25. cancel: function () {
  26. }
  27. }
  28. WxConfig().then(result => {
  29. result.ready(() => {
  30. // 分享给朋友
  31. result.updateAppMessageShareData ? result.updateAppMessageShareData(appMessage) : result.onMenuShareAppMessage(appMessage)
  32. // 分享到朋友圈
  33. result.updateTimelineShareData ? result.updateTimelineShareData(timeline) : result.onMenuShareTimeline(timeline)
  34. })
  35. })
  36. }
  37. export default funWxShare