shareMixin.js 1.1 KB

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