share.js 948 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * author:AbuCoder
  3. * date:2022年5月22日13:53:23
  4. * description:全局分享
  5. * 在项目的 main.js 文件中引入该 share.js 文件并使用 Vue.mixin() 方法将之全局混入:
  6. */
  7. export default {
  8. data() {
  9. return {
  10. // 默认的全局分享内容
  11. share: {
  12. title: '我在使用“AbuCoder"小程序,你也要不要试试呢~',//分享时的标题
  13. path: '/pages/index/index?shareid='+ uni.getStorageSync('token'), // 全局分享的路径,比如 首页
  14. imageUrl: '/static/img/share.jpg', // 全局分享的图片(可本地可网络)
  15. }
  16. }
  17. },
  18. // 定义全局分享
  19. // 1.发送给朋友
  20. onShareAppMessage(res) {
  21. return {
  22. title: this.share.title,
  23. path: this.share.path,
  24. imageUrl: this.share.imageUrl,
  25. }
  26. },
  27. //2.分享到朋友圈
  28. onShareTimeline(res) {
  29. return {
  30. title: this.share.title,
  31. path: this.share.path,
  32. imageUrl: this.share.imageUrl,
  33. }
  34. },
  35. }