shareMixin.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { onLaunch, onShow, onHide, onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
  2. export default {
  3. data() {
  4. return {
  5. // 可全局覆盖的默认参数
  6. shareConfig: {
  7. title: '金邻助家-着力打造全国居家服务行业标准和建立综合信用评价体系',
  8. // path: `/pages/login?scene=${uni.getStorageSync('userType')}:${uni.getStorageSync('userId')}`,
  9. path:'/pages/index',
  10. // imageUrl: '/static/serverImg/mine/user.png',
  11. imageUrl:''
  12. }
  13. }
  14. },
  15. onLaunch:function () {
  16. uni.showShareMenu({
  17. withShareTicket: true,
  18. menus: ['shareAppMessage', 'shareTimeline']
  19. })
  20. },
  21. onShareAppMessage() {
  22. return {
  23. title: this.shareConfig.title,
  24. path: this.shareConfig.path,
  25. imageUrl: this.shareConfig.imageUrl
  26. }
  27. },
  28. onShareTimeline() {
  29. return {
  30. title: this.shareConfig.title,
  31. // query: `scene=${uni.getStorageSync('userType')}:${uni.getStorageSync('userId')}`,
  32. query:``,
  33. imageUrl: this.shareConfig.imageUrl
  34. }
  35. }
  36. }