shareMixin.js 787 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // 创建全局mixin
  2. export default {
  3. onLoad() {
  4. // 开启分享功能
  5. uni.showShareMenu({
  6. withShareTicket: true,
  7. menus: ['shareAppMessage', 'shareTimeline']
  8. })
  9. },
  10. onShareAppMessage() {
  11. return {
  12. title: this.shareTitle || '默认分享标题',
  13. path: this.sharePath || '/pages/index/index',
  14. imageUrl: this.shareImage || '/static/share.png'
  15. }
  16. },
  17. onShareTimeline() {
  18. return {
  19. title: this.timelineTitle || '默认朋友圈标题',
  20. query: this.timelineQuery || '',
  21. imageUrl: this.timelineImage || '/static/share.png'
  22. }
  23. },
  24. data() {
  25. return {
  26. shareTitle: '',
  27. sharePath: '',
  28. shareImage: '',
  29. timelineTitle: '',
  30. timelineQuery: '',
  31. timelineImage: ''
  32. }
  33. }
  34. }