| export default { | |
|   data() { | |
|     return { | |
|       containerHeight: 0 | |
|     } | |
|   }, | |
|   methods: { | |
|     // 自定义分享内容 | |
|     mixinCustomShare() { | |
|       return { | |
|       } | |
|     }, | |
|     // 计算容器高度 | |
|     calculateContainerHeight() { | |
|       const systemInfo = uni.getSystemInfoSync(); | |
|       const statusBarHeight = systemInfo.statusBarHeight || 0; | |
|       const navigationBarHeight = 44; // 默认导航栏高度 | |
|       this.containerHeight = 2 * (systemInfo.windowHeight - statusBarHeight - navigationBarHeight); | |
|       console.log('最后的容器高度为', this.containerHeight/2 + 'px', '状态栏高度:', statusBarHeight + 'px', 'nav导航栏高度:', navigationBarHeight + 'px'); | |
|     }, | |
|   }, | |
|   computed: { | |
|     // 获取全局配置的文本 | |
|     configParamInfo() { | |
|       return key => this.$store.state.configList[key]?.info || '默认资料' | |
|     }, | |
|     // 获取全局配置的图片 | |
|     configParamContent() { | |
|       return key => this.$store.state.configList[key]?.content || '默认内容' | |
|     }, | |
| 
 | |
|     // 默认的全局分享参数 | |
|     GShare() { | |
|       const obj = {} | |
|       if (this.$store.state.userInfo.id) { | |
|         obj.path = this.configParamContent('xcxSharePage') + '?inviter=' + this.$store.state.userInfo.id | |
|       }else { | |
|         obj.path = this.configParamContent('xcxSharePage') | |
|       } | |
|       return { | |
|         title: this.configParamContent('app_name'), | |
|         desc: this.configParamContent('share_desc'), | |
|         imageUrl: this.configParamContent('login_logo'), | |
|         ...obj | |
|       } | |
|     } | |
|   }, | |
|   // 分享到好友 | |
|   onShareAppMessage() { | |
|     return { | |
|       ...this.GShare, | |
|       ...this.mixinCustomShare() | |
|     } | |
|   }, | |
|   // 分享到朋友圈 | |
|   onShareTimeline() { | |
|     return { | |
|       ...this.GShare, | |
|       ...this.mixinCustomShare() | |
|     } | |
|   }, | |
|   onLoad(args) { | |
|     // this.calculateContainerHeight(); | |
|     if (args.inviter){ | |
|       uni.setStorageSync('inviter', args.inviter) | |
|     } | |
|   } | |
| }
 |