WeChat Open Platform

Mini Programs Documentation

Scanning Code

wx.scanCode(OBJECT)

Calls the client's code scanning interface, the corresponding results are returned after codes are scanned successfully.

Object parameter descriptions:

Parameter Type Required Description
success Function No Callback function for successful interface call, refer to return parameter descriptions for return content
fail Function No Callback function for failed interface call
complete Function No Callback function for interface call results (will be executed if call succeeds or fails)

success return parameter descriptions:

Parameter Description
result Content of scanned code
scanType Type of code scanned
charSet Character set of scanned code
path This field will be returned if the code scanned is a legitimate QR code for a current Mini Program, it contains the path carried by the QR code

Sample code:

wx.scanCode({
  success: (res) => {
    console.log(res)
  }
})