1.0.3 • Published 4 years ago

@uni/scan v1.0.3

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
4 years ago

scan

npm

Opens the code scanning interface in the app to scan the code.

Supported

Install

$ npm install @uni/scan --save

or

$ npm install @uni/apis --save

示例

import scan from '@uni/scan';

scan({
  scanType: ['qrCode','barCode'],
  success (res) {
    console.log(res.result)
  },
  fail (res) {
    console.log(res)
  }
});

// promise
scan({
  scanType: ['qrCode','barCode'],
}).then(res => {
  console.log(res.result)
});

You can also import from big package:

import { scan } from '@uni/apis';

Function

scan(options)

Property

PropertyTypeDescriptionRequiredDefault
optionsobject -
options.successFunction The callback function for a successful API call-
options.failFunction The callback function for a failed API call-
options.completeFunction The callback function used when the API call completed-
Valid values of object.scanType
ValueDescriptionSupported
barCodeBarcode
qrCodeQR code
dmCodeData Matrix code
pdf417CodePDF417 barcode
narrowCodeNarrow bar QR code
hmCodeHeterogeneous code

Non general parameters

PropertyTypeDescriptionRequiredDefaultSupported
options.hideAlbumBoolean Indicates whether to allow to scan code with camera onlyfalse
options.scanTypeArray<string> Type of code to scan'barCode', 'qrCode'

object.success callback function

Object res
PropertyTypeDescription
resultstringContent of code to scan

Non general parameters

PropertyTypeDescriptionSupported
charSetstringCharacter set of code to scan
pathstringIf the scanned code is the QR code of the current Mini Program, this field is returned, and the content is the path carried by the QR code.
scanTypestringType of code to scan
rawDatastringBase64 encoded raw data
imageChannelstringsource
codestringScan data
qrCodestringReturn QR code data when scanning QR code
barCodestringReturn barcode data when scanning barcode.
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-beta

4 years ago