Customize the QR code with parameters to scan the code to enter the WeChat applet to obtain parameters

The first step, you need to enter the background of the applet, in the development settings, add the QR code rule

 The second step is to add the rules for scanning the code to enter, such as scanning the code to enter the specified page of the applet!

(1) Select https for the protocol type
(2) Select lowercase
(3) QR code rules. Some people may be confused when looking at the document. A simple understanding is an https path
(4) Prefix occupancy rules select no occupancy
(5) Verify the file, download the file to the background and put it on the server
(6) The function page of the applet, this page is the page you want to open by scanning the code
(7) Test scope The trial version needs to release the trial version
(8) Test link (optional) If the following two conditions are met, the development version needs the developer to generate the preview code and scan the code by himself.
 

The test link can be used for testing!

In the third step, the applet obtains the incoming parameters!

Pit avoidance - parameters cannot be obtained after going online, it can be normal when not online, but not online

    onLoad(options) {
        
        console.log(options);   //options 里面有传进来的参数   

    }

Using the following can also be successful!

    onLoad:function(e){
        const query = decodeURIComponent(e.q)
        var mun  = query.split("=")
    }

    值 mun[1]

The above method of obtaining parameters is not normal no matter how you debug it in the debugging tool, but it is normal after going online! Odd or not, surprised or not surprised-. -

The fourth step is to set the startup settings in the applet tool!

 The fifth step, after the test is completed, we need to submit the official version test in the applet!

Precautions

1. The small program scanned by the trial version cannot set dynamic parameters, and the recognized link must be exactly the same as the test link

2. After the QR code rules go online, you can set dynamic parameters, and the QR code rules need to be released when they go online

Special attention: Do not report an error for the custom QR code link you set, and do not report the error in the program, otherwise it will be difficult to troubleshoot! ~

Guess you like

Origin blog.csdn.net/munchmills/article/details/128434377