当前位置:网站首页>Wechat applet obtains the parameters carried after scanning the QR code
Wechat applet obtains the parameters carried after scanning the QR code
2022-06-25 02:52:00 【YZHD】
Wechat applet obtains the parameters carried after scanning the QR code
1、decodeURIComponent Parse the link to generate the QR code .
/** * Life cycle function -- Monitor page loading */
onLoad: function(options) {
if (options.scene) {
// Get the link information carried by the QR code
let qrUrl = decodeURIComponent(options.scene)
console.log(qrUrl)
this.setData({
// Get the parameter information in the link
actId: utils.getQueryString(qrUrl, 'actId'),
shareUserId: utils.getQueryString(qrUrl, 'shareUserId'),
})
}
},
2、utils To get the parameters carried in the link
// Resolving parameters in links
let getQueryString = function (url, name) {
console.log("url = " + url)
console.log("name = " + name)
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
var r = url.substr(1).match(reg)
if (r != null) {
console.log("r = " + r)
console.log("r[2] = " + r[2])
return r[2]
}
return null;
}
// Export method , External call
module.exports = {
getQueryString: getQueryString,
}
Avoid pit :
onLoad (option) {
console.log(option)
}
Can receive Take parameters to request data and other operations ~
If your app is going to be released
At this point, you should change the way you get parameters , Because the parameters obtained after the official release are different from those in the developer tools , The pit !!!. The following code is the code for you to obtain the parameters in the entry QR code after the official release of the applet ,scene It is a parameter of the method of generating QR code by wechat , It is used to write the parameters you want to carry in the QR code
onLoad (option) {
console.log(option)
if (option.scene) {
let obj = decodeURIComponent(option.scene)
... // Here is the parameter you hold obj To operate
}
}
边栏推荐
- Dirvish Chinese document of vim
- DSPACE设置斑马线和道路箭头
- Go synchronization waiting group
- Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (2) -- convert database to cluster mode
- QT package the EXE file to solve the problem that "the program input point \u zdapvj cannot be located in the dynamic link library qt5cored.dll"
- 把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(4)—— 修改 oracle11g rac 集群的 scanIP
- Smartctl opens the device and encounters permission denied problem troubleshooting process record
- 计网 | 【四 网络层】知识点及例题
- GO同步等待组
- When they are in private, they have a sense of propriety
猜你喜欢
After reciting the eight part essay, I won the hemp in June
自动化测试
Transformers Roberta如何添加tokens
Software testing salary in first tier cities - are you dragging your feet
計網 | 【四 網絡層】知識點及例題
Solution of separating matlab main window and editor window into two interfaces
Pit entry machine learning: I. Introduction
Once beego failed to find bee after passing the go get command Exe's pit
DDD concept is complex and difficult to understand. How to design code implementation model in practice?
Network planning | [four network layers] knowledge points and examples
随机推荐
AOSP ~ WIFI架构总览
计网 | 【四 网络层】知识点及例题
MySQL command backup
Refresh mechanism of vie
Post competition summary of kaggle patent matching competition
微信小程序获取扫描二维码后携带的参数
F - Spices(线性基)
使用ShaderGraph制作边缘融合粒子Shader的启示
E - Average and Median(二分)
[i.mx6ul] u-boot migration (VI) network driver modification lan8720a
UnityShader入门精要——PBS基于物理的渲染
Smartctl opens the device and encounters permission denied problem troubleshooting process record
After reciting the eight part essay, I won the hemp in June
yarn : 无法加载文件 C:\Users\xxx\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本
CMakeLists中的add_definitions()函数
背了八股文,六月赢麻了……
Summary of stack frame in arm assembly
Getting started with unityshader - Surface Shader
Computer wechat user picture decoded into picture in DAT format (TK version)
AI服装生成,帮你完成服装设计的最后一步