目录

uniApp微信小程序扫描普通二维码跳转到小程序指定页面操作方法

目录

uniApp微信小程序扫描普通二维码跳转到小程序指定页面操作方法

这篇文章主要给大家介绍了关于微信小程序扫描普通二维码跳转到小程序指定页面操作的相关资料,需要的朋友可以参考下

1、首先我们需要在微信公众平台的开发管理——>开发设置,找到(扫普通链接二维码打开小程序),点击添加,根据提示进行相关配置

https://i-blog.csdnimg.cn/direct/b1f060d7731c4e5baa956f5f010b2fbb.png

2、配置好之后我们去草料二维码网站生成一个网址链接二维码,网址就是你在上面配置的测试链接

3、扫描二维码就可以跳转到微信小程序的指定页面了

4、微信小程序页面接收传过来的参数,扫码跳到指定页面后,在onLoad方法接收参数

if(options.q && options.q != "undefined"){
	const qrUrl = decodeURIComponent(options.q) 
	console.log(qrUrl);
	let jsonUrl = this.getUrlParam(qrUrl);
	this.no = jsonUrl.No;
}  

4、解析链接地址方法如下

getUrlParam(url) {
	let theRequest = {};
	if(url.indexOf("#") != -1){
		const str=url.split("#")[1];
		const strs=str.split("&");
		for (let i = 0; i < strs.length; i++) {
			theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
		}
	}else if(url.indexOf("?") != -1){
		const str=url.split("?")[1];
		const strs=str.split("&");
		for (let i = 0; i < strs.length; i++) {
			theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
		}
	}
	return theRequest;
}

到这里,就可以实现扫码普通二维码跳转到微信小程序指定页面