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

59 lines
1.6 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. 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('login_logo'),
  37. path: this.configParamContent('xcxSharePage'),
  38. }
  39. }
  40. },
  41. // 分享到好友
  42. onShareAppMessage() {
  43. return {
  44. ...this.GShare,
  45. ...this.mixinCustomShare()
  46. }
  47. },
  48. // 分享到朋友圈
  49. onShareTimeline() {
  50. return {
  51. ...this.GShare,
  52. ...this.mixinCustomShare()
  53. }
  54. },
  55. onLoad() {
  56. // this.calculateContainerHeight();
  57. }
  58. }