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