uniapp 小程序跳app,app跳小程序
·
uniapp跳到小程序
plus.share.getServices(function(res) {
var sweixin = null;
console.log("sweixin", sweixin, res)
for (var i = 0; i < res.length; i++) {
var t = res[i];
if (t.id == 'weixin') {
sweixin = t;
// break;
}
}
if (sweixin) {
sweixin.launchMiniProgram({
id: id,
type: 0, //小程序版本 0-正式版; 1-测试版; 2-体验版。
path: '../../pay/pay' //小程序的页面,用传的参数在小程序接值判断跳转指定页面
});
} else {
alert('当前环境不支持微信操作')
}
});
如果报错:bad_param
原始ID填错了,记得是 gh_ 打头的 原始id 记得是 gh_打头的 原始id 记得是 gh_打头的 原始id 不是wx_打头的小程序id ,在微信公众平台的- 设置-里面找 原始id
小程序跳回app
<button open-type="launchApp" type="primary" :app-parameter="toAppData" binderror="launchAppError">返回APP</button>
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
that.getArguments();
},
getArguments: function() {
// 处理第三方传入的参数
// #ifdef APP-PLUS
var param = plus.runtime.arguments;
if (param != '') {
try {
console.log(param);
var userInfo = JSON.parse(param); //获取小程序传输到app的数据方法
console.log("5");
plus.runtime.arguments = "";
console.log("清除plus.runtime.arguments数据成功")
// 跳转进入app页面
//uni.switchTab({
// url: '../my/my'
//});
} catch (e) {
// 若传入的参数不是JSON格式字符,需处理异常情况
console.error(e);
console.log('若传入的参数不是JSON格式字符,需处理异常情况。');
}
}
// #endif
}
更多推荐
所有评论(0)