Scan Code
scanCode
TIP
The API usage is as follows: wx.scanCode(Object object)
This API is supported by mini programs, but not by mini games.
Functional description: Call up the client code scanning interface to scan
Parameters and descriptions: Object object。
Properties Type Legal values Default value Required Description onlyFromCamera boolean - false No Whether the code can only be scanned from the camera, and pictures cannot be selected from the album scanType Array.< string>1. barCode:One-dimensional code
2. qrCode:Two-dimensional code
3. datamatrix:Data Matrix code
4.pdf417:PDF417 barcode['barCode', 'qrCode'] No Scanning type success Function - - No Callback function for successful interface call fail Function - - No Callback function for failed interface call complete Function - - No Callback function for interface call completion (executed regardless of success or failure) object.success callback function parameters: Object object。
Properties Type Legal values Description result string - Content of the scanned code scanType string 1.QR_CODE:Two-dimensional code
2. AZTEC:One-dimensional code
3. CODABAR:One-dimensional code
4.CODE_39:One-dimensional code
5. CODE_93:One-dimensional code
6. CODE_128:One-dimensional code
7. DATA_MATRIX:Two-dimensional code
8.EAN_8:One-dimensional code
9.EAN_13:One-dimensional code
10. ITF:One-dimensional code
11. datamatrix:One-dimensional code
12.PDF_417:Two-dimensional code
13. RSS_14:One-dimensional code
14. RSS_EXPANDED:One-dimensional code
15. UPC_A:One-dimensional code
16.UPC_E:One-dimensional code
17. UPC_EAN_EXTENSION:One-dimensional code
18. WX_CODE:Two-dimensional code
19.CODE_25:One-dimensional codeType of the scanned code charSet string - Character set of the scanned code path string - When the scanned code is the current mini program QR code, this field will be returned, and the content is the path carried by the QR code rawData string - Original data, base64 encoding Sample code:
js
// Allow scanning from both the camera and album
wx.scanCode({
success(res) {
console.log(res);
},
});
// Allow scanning from the camera only
wx.scanCode({
onlyFromCamera: true,
success(res) {
console.log(res);
},
});