一、配置

1、微信开放平台,创建移动应用与绑定小程序

2、manifest.json,填写移动应用的appid

Uni-app 之APP打开小程序与分享小程序页面_JSON

二、打开小程序

plus.share.getServices(res => {
  var is_weixin = res.find(i => i.id === 'weixin');
  if (is_weixin) {
    is_weixin.launchMiniProgram({
      id: weixin_id,
      path: '/pages/index/index' //要打开小程序的路径
    }, res => {
      console.log(JSON.stringify(res));
      //成功
    }, res => {
      //失败
    })
  }
}, res => {
  
})

三、分享小程序

uni.share({
  provider: "weixin",
  scene: "WXSceneSession",
  type: 5,
  imageUrl: imgUrl, //图片地址。type为0时,推荐使用小于20Kb的图片
  title: title, //分享内容的标题
  miniProgram: {
    id: weixin_id, //微信小程序原始id
    path: 'pages/index/index', //点击链接进入的页面
    type: 0,
    webUrl: '' //兼容低版本的网页链接
  },
  success: ret => {
    console.log(JSON.stringify(ret));
  },
  fail(res) {
    console.log(JSON.stringify(res))
  }
})