微信wx-open-launch-app跳转回app指定页面并带参

使用微信网页wx-open-launch-app跳转APP:

https://developers.weixin.qq.com/doc/oplatform/Mobile_App/WeChat_H5_Launch_APP.html

1.申请微信SDK,获取后端返回的签名及签名相关内容,APPID填写公众号APPID
2.url 传递给后端生成的签名,url为开放平台公众号关联APP 域名的域名, url需要和第一次进入的页面域名一致。

app未启动或启动中获取参数:
https://ask.dcloud.net.cn/article/64

	//onLaunch生命周期中使用:  确保启动时每个页面都能监听到
			let that = this
			plus.globalEvent.addEventListener('newintent', e => {
				that.checkArguments();
			});
	//启动页 onshow生命周期使用:确保未启动时第一次进入可以跳转
			setTimeout(function() {
				that.checkArguments()
			}, 10);

			//方法:
			checkArguments() {
				// plus.runtime.argumrnts为打开时APP传的值(<wx-open-launch-app>中的extinfo),可以传字符串通过符号截取判断类型
				if (this.isJsonObject(plus.runtime.arguments)) {
					//我截取了字符串,判断是商品并且根据ID跳转到商品详情页
					var commodityParams = plus.runtime.arguments;
					uni.navigateTo({
						url: `/pages/commodityDetails/commodityDetails?sendData=${commodityParams}`
					});

					plus.runtime.arguments = null;
					plus.runtime.arguments = "";
				}
			},
			isJsonObject(variable) {
				if (variable) {
					try {
						JSON.parse(variable);
						return true;
					} catch (e) {
						return false;
					}
				}
				return false;
			},
`

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值