1
fei.wang
2025-03-07 1b6a3e58e8d3f9a4a56810b5433e28230fe8f3bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module.exports = {
  onLoad() {
    // 设置默认的转发参数
    this.$tn.mpShare = {
      // 分享的标题,默认为小程序名称
      title: '',
      // 分享的路径,默认为当前页面
      path: '',
      // 分享时显示的图片,默认为当前页面截图
      imageUrl: '',
      // 当前页面是否可以分享
      share: true
    }
    if (!this.$tn.mpShare.share) {
      uni.hideShareMenu()
    }
  },
  onShareAppMessage() {
    return this.$tn.mpShare
  },
  // #ifdef MP-WEIXIN
  onShareTimeline() {
    return {
      title: this.$tn.mpShare.title,
      query: this.$tn.mpShare.path.substring(this.$tn.mpShare.path.indexOf('?') + 1, this.$tn.mpShare.path.length),
      imageUrl: this.$tn.mpShare.imageUrl
    }
  }
  // #endif
}