四零语境前端代码仓库
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.

57 lines
1.5 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. export default {
  2. data() {
  3. return {
  4. containerHeight: 0
  5. }
  6. },
  7. methods: {
  8. // 自定义分享内容
  9. mixinCustomShare() {
  10. return {
  11. }
  12. },
  13. // 计算容器高度
  14. calculateContainerHeight() {
  15. const systemInfo = uni.getSystemInfoSync();
  16. const statusBarHeight = systemInfo.statusBarHeight || 0;
  17. const navigationBarHeight = 44; // 默认导航栏高度
  18. this.containerHeight = 2 * (systemInfo.windowHeight - statusBarHeight - navigationBarHeight);
  19. console.log('最后的容器高度为', this.containerHeight/2 + 'px', '状态栏高度:', statusBarHeight + 'px', 'nav导航栏高度:', navigationBarHeight + 'px');
  20. },
  21. },
  22. computed: {
  23. // 获取全局配置的文本
  24. configParamInfo() {
  25. return key => this.$store.state.configList[key]?.info || '默认资料'
  26. },
  27. // 获取全局配置的图片
  28. configParamContent() {
  29. return key => this.$store.state.configList[key]?.content || '默认内容'
  30. },
  31. // 默认的全局分享参数
  32. GShare() {
  33. return {
  34. title: this.configParamContent('app_name'),
  35. desc: this.configParamContent('share_desc'),
  36. imageUrl: this.configParamContent('app_logo'),
  37. path: '/pages/index/index'
  38. }
  39. }
  40. },
  41. onShareAppMessage() {
  42. return {
  43. ...this.GShare,
  44. ...this.mixinCustomShare()
  45. }
  46. },
  47. onShareTimeline() {
  48. return {
  49. ...this.GShare,
  50. ...this.mixinCustomShare()
  51. }
  52. },
  53. onLoad() {
  54. // this.calculateContainerHeight();
  55. }
  56. }