小程序禁止二次转发分享
发布于 1 年前 作者 aye 3819 次浏览 来自 分享

一、效果图:

正常分享, 可以继续转发

私密分享, 无法二次转发

二业务场景, 一些私密的小程序分享(比如设备授权,赠送会员卡等),  禁止二次转发

官方文档 : https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share/private-message.html

wx.updateShareMenu 设置私密分享参数 官方文档:https://developers.weixin.qq.com/miniprogram/dev/api/share/wx.updateShareMenu.html


实操代码截图:

 demo代码:

  // 用户点击分享
  onShareAppMessage(res) {
    // isPrivateMessage: true转发私密消息=>然后通过 wx.updateShareMenu 接口声明本次分享的消息为私密消息,私密消息具有不可二次转发性。
    wx.updateShareMenu({
        isPrivateMessage: true,
        success () { },
        fail () {}
    })
    return {
      title: "", // 自定义分享标题
      imageUrl: "", // 自定义分享图片
      path: "", // 自定义分享页面路径,默认本页面路径
    };
  },
回到顶部