tencent cloud

Feedback

Code Scanning

Last updated: 2024-11-28 10:43:21

    scanCode

    This API is used via wx.scanCode(Object object).
    Feature Description: Initiates the client's scanning interface for barcode scanning.
    Parameter and Description: Object.
    Attribute
    Type
    Valid Values and Descriptions
    Default value
    Required
    Description
    onlyFromCamera
    boolean
    -
    false
    No
    Is it exclusively permissible to scan from the camera, disallowing the selection of images from the album?
    scanType
    Array.<string>
    barCode: Barcode
    qrCode: QR code
    datamatrix: Data Matrix code
    pdf417: PDF417 Barcode
    ['barCode', 'qrCode']
    No
    Code scanning type
    success
    function
    -
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Parameters for object.success callback function: Object res.
    Attribute
    Type
    Valid Values and Descriptions
    Description
    result
    string
    -
    Content of the scanned code
    scanType
    string
    QR_CODE: QR code
    AZTEC: Barcode
    CODABAR: Barcode
    CODE_39: Barcode
    CODE_93: Barcode
    CODE_128: Barcode
    DATA_MATRIX: QR code
    EAN_8: Barcode
    EAN_13: Barcode
    ITF: Barcode
    MAXICODE: Barcode
    PDF_417: QR code
    RSS_14: Barcode
    RSS_EXPANDED: Barcode
    UPC_A: Barcode
    UPC_E: Barcode
    UPC_EAN_EXTENSION: Barcode
    WX_CODE: QR code
    CODE_25: Barcode
    Type of scanned code
    charSet
    string
    -
    String set of the scanned code
    path
    string
    -
    When the scanned code is the current mini program's QR code, this field will be returned, containing the path carried by the QR code.
    rawData
    string
    -
    Raw data, Base64-encoded
    Sample Code
    // 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)
    }
    })
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support