uniapp 小程序分享

315 阅读1分钟
<button open-type="share">分享</button>
js
onShareAppMessage(res) {
    if (res.from === 'button') {// 来自页面内分享按钮
      console.log(res.target)
    }
    return {
      title: '自定义分享标题',
      path: '/pages/test/test?id=123'imgUrl:''
    }
  }
  //分享到朋友圈
 onShareTimeline(res) {
    if (res.from === 'button') {// 来自页面内分享按钮
      console.log(res.target)
    }
    return {
      title: '自定义分享标题',
      path: '/pages/test/test?id=123'imgUrl:''
    }
  }

分享三步走:

  1. (分享者)分享的时候 ,把邀请者的ID带上 inviteID
  2. (受邀请者) 进入首页 onload(options){options.inviteID }获取邀请者的ID 并且uni.setstor....存入缓存、
  3. (受邀请者)进入登录页,在调登录接口的时候把inviteID 坐蓐参数传入即可