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

68 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. 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. const obj = {}
  34. if (this.$store.state.userInfo.id) {
  35. obj.path = this.configParamContent('xcxSharePage') + '?inviter=' + this.$store.state.userInfo.id
  36. }else {
  37. obj.path = this.configParamContent('xcxSharePage')
  38. }
  39. return {
  40. title: this.configParamContent('app_name'),
  41. desc: this.configParamContent('share_desc'),
  42. imageUrl: this.configParamContent('login_logo'),
  43. ...obj
  44. }
  45. }
  46. },
  47. // 分享到好友
  48. onShareAppMessage() {
  49. return {
  50. ...this.GShare,
  51. ...this.mixinCustomShare()
  52. }
  53. },
  54. // 分享到朋友圈
  55. onShareTimeline() {
  56. return {
  57. ...this.GShare,
  58. ...this.mixinCustomShare()
  59. }
  60. },
  61. onLoad(args) {
  62. // this.calculateContainerHeight();
  63. if (args.inviter){
  64. uni.setStorageSync('inviter', args.inviter)
  65. }
  66. }
  67. }