扫描二维码进小程序指定页面并取出编码
onLoad(options) {
// 扫描普通二维码进入
if (options.q) {
let params = this.getRequest(decodeURIComponent(options.q));
this.businessId = params.businessId || '';
}
// 分享进入
if (options.businessId) {
this.businessId = options.businessId || '';
}
},
//去参方法
getRequest(params) {
let url = params.substring(params.indexOf("?")); //获取url中"?"符后的字串
let theRequest = new Object();
if (url.indexOf("?") != -1) {
let str = url.substr(1);
let strs = str.split("&");
for (let i = 0; i < strs.length; i++) {
heRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
},