四零语境前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.9 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. import { mapState } from 'vuex'
  2. export default {
  3. data() {
  4. return {
  5. containerHeight: 0
  6. }
  7. },
  8. methods: {
  9. // 自定义分享内容
  10. mixinCustomShare() {
  11. return {
  12. }
  13. },
  14. // 计算容器高度
  15. calculateContainerHeight() {
  16. const systemInfo = uni.getSystemInfoSync();
  17. const statusBarHeight = systemInfo.statusBarHeight || 0;
  18. const navigationBarHeight = 44; // 默认导航栏高度
  19. this.containerHeight = 2 * (systemInfo.windowHeight - statusBarHeight - navigationBarHeight);
  20. console.log('最后的容器高度为', this.containerHeight / 2 + 'px', '状态栏高度:', statusBarHeight + 'px', 'nav导航栏高度:', navigationBarHeight + 'px');
  21. },
  22. },
  23. computed: {
  24. ...mapState(['userInfo']),
  25. // 获取全局配置的文本
  26. configParamInfo() {
  27. return key => this.$store.state.configList[key]?.info
  28. },
  29. // 获取全局配置的图片
  30. configParamContent() {
  31. return key => this.$store.state.configList[key]?.content
  32. },
  33. // 默认的全局分享参数
  34. GShare() {
  35. const obj = {}
  36. if (this.$store.state.userInfo.id) {
  37. obj.path = this.configParamContent('xcxSharePage') + '?inviter=' + this.$store.state.userInfo.id
  38. } else {
  39. obj.path = this.configParamContent('xcxSharePage')
  40. }
  41. return {
  42. title: this.configParamContent('app_name'),
  43. desc: this.configParamContent('share_desc'),
  44. imageUrl: this.configParamContent('login_logo'),
  45. ...obj
  46. }
  47. }
  48. },
  49. // 分享到好友
  50. onShareAppMessage() {
  51. return {
  52. ...this.GShare,
  53. ...this.mixinCustomShare()
  54. }
  55. },
  56. // 分享到朋友圈
  57. onShareTimeline() {
  58. return {
  59. ...this.GShare,
  60. ...this.mixinCustomShare()
  61. }
  62. },
  63. onLoad(args) {
  64. // this.calculateContainerHeight();
  65. if (args.inviter) {
  66. uni.setStorageSync('inviter', args.inviter)
  67. }
  68. }
  69. }