my.scan

Call the scan QR code function.

Sample Code

copy
Page({
  scan() {
    my.scan({
      type: 'qr',
      success: (res) => {
        my.alert({ title: res.code });
      },
    });
  }
})

Parameters

NameTypeMandatoryDescription
typeStringNoType for scanning (qr by default):  
1. qr:   two-dimensional QR scanning frame  
2. bar:   Linear barcode scanning frame
hideAlbumBooleanNoHide camera or not (does not allow   selecting from album); scan from camera only
successFunctionNoCallback function upon call success
failFunctionNoCallback function upon call failure
completeFunctionNoCallback function upon call   completion (to be executed upon either call success or failure)

Success Callback Function

The incoming parameter is of the Object type with the following attributes:

NameTypeDescription
codeStringData resulting from scanning
qrCodeStringQR code data returned from scanning
barCodeStringBar code data returned from scanning

Error Code

errorDescription
10User cancellation
11Operation failure