新APP的分享到小程序

2023-12-25 17:45:19 阅读:3 编辑

分享到小程序

https://dev.weixin.qq.com/docs/framework/dev/jsapi/miniapp/shareMiniProgramMessage.html?utm_source=donut_header

newappShare(){
    wx.miniapp.shareMiniProgramMessage({
      // 注: 小程序原始id 不是小程序 appid,通常是 gh_xxx 开头的内容, 如 gh_d43f693ca31f 
      userName: 'gh_c4518a01180b',  
      path: 'base/goodsdetail/goodsdetail?id=' + this.data.id,
      imagePath: '/zhy/resource/images/offlineform.png',
      webpageUrl: 'https://jfsh.aissyun.com',
      withShareTicket: false,
      miniprogramType: 0,
      scene: 0, 
      success(res) {
      wx.showToast({
          title: '成功:分享小程序',
      })
      console.log(res)
      },
      fail(res) {
        console.log(res);
      wx.showToast({
          title: '失败:分享小程序',
      })
      }
  })
  },

分享到h5

https://dev.weixin.qq.com/docs/framework/dev/jsapi/miniapp/shareWebPageMessage.html?utm_source=donut_header --分享缩略图,支持代码包图片资源路径或者本地临时、缓存、用户文件;不支持网络图片路径

wx.miniapp.shareWebPageMessage({
    title: '网页标题',
    description: '网页描述',
    thumbPath: '/pages/thumb.png',
    webpageUrl: 'www.qq.com',
    scene: 0, 
    success(res) {
        wx.showToast({
            title: '成功:分享网页',
        })
    },
    fail() {
        wx.showToast({
            title: '失败:分享网页',
        })
    }
})