uniapp框架:app分享到小程序、app跳转到小程序、小程序跳转到其他小程序

app分享内容到小程序

    //app分享到微信
        uni.share({
          provider: 'weixin',
          scene: "WXSceneSession",
          type: 5, //分享到微信
          imageUrl: "https://admin.yibenfng.com/prod-api//profile/upload/2024/03/05/logo_20240808102526A002_20240305133837A003.jpg",//必填
          title: '医生已开方',
          miniProgram: {
            id: 'gh_d425283400ff', // 必填
            path: 'pages/index/children/shareOrder?id=' + this.pjId, // 默认为当前页面路径  必填
            type: 0, // 0-正式版; 1-测试版; 2-体验版。 默认值为0
            webUrl: 'https://ask.dcloud.net.cn/article/287' //必须填一个
          },
          success: ret => {
            console.log(JSON.stringify(ret));
          },
         fail: function (err) {
           console.log("fail:" + JSON.stringify(err));
         }
        });

小程序跳转到其他小程序、app跳转到小程序

     // #ifdef MP-WEIXIN
        //跳转到其他小程序
        uni.navigateToMiniProgram({  
          appId: 'wxb4ecc4071133f009',  //appId
          path: 'pages/index/index', //页面路径
          extraData: {
            'data1': 'test'
          },
          success(res) {
            // 打开成功
          }
        })
        // #endif

        // #ifdef APP-PLUS
        //获取终端支持的分享通道列表
        plus.share.getServices(function (s) {
          let sweixin = null;
          for (let i = 0; i < s.length; i++) {
            if (s[i].id == 'weixin') {
              sweixin = s[i];
            }
          }
          //判断是否有微信
          if (sweixin) {
            console.log('调起小程序', s)
            //唤起微信跳转小程序
            sweixin.launchMiniProgram({
              id: 'gh_32f481a0bb00', //小程序原始id
              path: 'pages/index/index', //小程序页面路径
              type: 0, //这里是不同的环境(默认0)
            }, function () {
              return true;
            }, function (e) {
              console.log("微信唤起失败", e);
              uni.showToast({
                title: '微信唤起失败,请检查是否有微信应用',
                icon: 'none'
              })
              return false;
            })
          } else {
            uni.showToast({
              title: '微信唤起失败,请检查是否有微信应用',
              icon: 'none',
              duration: 3000
            })
            return false;
          }
        }, function (e) {
          console.log("微信唤起失败", e);
          uni.showToast({
            title: '微信唤起失败,请重试',
            icon: 'none',
            duration: 3000
          })
          return false;
        });
        // #endif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值