目录

Code Scan

has.scanCode

has.scanCode(Object object)

Invokes the client to perform a code scan.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Default Value Mandatory Description
onlyFromCamera boolean false No Whether to use only the camera mode for code scans.
scanType Array<string> ['barCode', 'qrCode'] No

Scan type.

- barCode: barcode

- qrCode: QR code

- datamatrix: Data Matrix code

- pdf417: PDF417 barcode

success function - No Callback triggered when the API call is successful.
fail function - No Callback triggered when the API call fails.
complete function - No Callback triggered when the API call is complete, regardless of success or failure.

Return value of success

Parameter Type Description
result string Scan content.
scanType string Scan type. For details, see "Valid values of scanType."

Valid values of scanType

Valid Value Description
FORMAT_UNKNOWN Unknown type. This parameter is used for scenarios where the type of code to be scanned is unknown beforehand. It cannot be used for barcode image generation.
AZTEC AZTEC barcode.
CODABAR CODABAR barcode.
CODE_39 CODE 39 barcode.
CODE_93 CODE 93 barcode.
CODE_128 CODE 128 barcode.
DATA_MATRIX DATA MATRIX 2D barcode.
EAN_8 EAN-8 barcode.
EAN_13 EAN-13 barcode.
ITF_14 ITF-14 barcode.
PDF_417 PDF417 2D barcode.
QR_CODE QR code.
UPC_A UPC-A barcode.
UPC_E UPC-E barcode.
MULTIFUNCTIONAL Multifunctional code. The barcode image generation capability does not support this type currently.

Example:

has.scanCode({
  success: (res) => {
    console.info('scanCode success', res);
  },
  fail: (err) => {
    console.error('scanCode fail', err);
  },
  complete: (res) => {
    console.info('scanCode complete', res);
  }
});