This topic describes the JavaScript API of WVScan. You can refer to this topic when you create HTML5 apps or Miniapps. You can use the JavaScript APIs of WVScan to scan a code.
WVScan.scan
This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.
Call the scan QR code or bar code function.
Input parameters
[
boolean]openFlight: optional. Specifies whether to enable the flash. true indicates that the flash is enabled, while false indicates that the flash is disabled. The flash is disabled by default.[
string]title: optional. The title of the scanning page. The default parameter value is "scan QR code or bar code".
Callback parameters
Parameters for a success callback:
No callback parameters exist.
Parameters for a failure callback:
[
string]msg: the error message.
Event listening
WVScan.Event.scanSuccess: The code is scanned.
Event parameters:
[
string]content: the result that is obtained by scanning a code.[
string]format: the format of the code scanning. Valid values:[
string]QR_CODE: the QR code.[
string]AZTEC: the barcode. It is an Aztec 2D barcode.[
string]CODABAR: the barcode. The format is Codabar.[
string]CODE_39: the barcode. The format is Code 39.[
string]CODE_93: the barcode. The format is Code 93.[
string]CODE_128: the barcode. The format is Code 128.[
string]DATA_MATRIX: the barcode. The format is Data Matrix. It is a 2D matrix barcode.[
string]EAN_8: the barcode. The format is EAN-8.[
string]EAN_13: the barcode. The format is EAN-13.[
string]ITF: the barcode. The format is Interleaved 2 of 5 (ITF).[
string]MAXICODE: the barcode. The format is MaxiCode. It is a hexagonal 2D barcode.[
string]PDF_147: the barcode. The format is PDF147. It is a 2D barcode.[
string]RSS_14: the barcode. The format is RSS 14.[
string]RSS_EXPANDED: the barcode. The format is RSS Expanded.[
string]UPC_A: the barcode. The format is UPC-A.[
string]UPC_E: the barcode. The format is UPC-E.
WVScan.Event.scanFailed: Code scanning failed.
Event parameters:
[
string]msg: the error message.
document.addEventListener('WVScan.Event.scanSuccess', function (e) {
alert('event scanSuccess: ' + JSON.stringify(e.param));
});
document.addEventListener('WVScan.Event.scanFailed', function (e) {
alert('event scanFailed: ' + JSON.stringify(e.param));
});
var params = {
openFlight: true,
title: 'XXX'
};
window.WindVane.call('WVScan', 'scan', params, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});