全部產品
Search
文件中心

SuperApp:掃碼

更新時間:Oct 29, 2024

本文介紹掃碼類WVScan相關的JSAPI,供您建立H5端應用或者小程式時參考。掃碼類WVScan的JSAPI提供掃碼相關的能力。

WVScan.scan

說明

該API只在Windvane Android 1.0.3.4以上版本有效。

調用掃碼功能。

輸入參數

  • [boolean]openFlight:可選,是否開啟閃光燈。true代表開啟,false代表不開啟,預設是不開啟。

  • [string]title: 可選,掃碼頁面的標題。預設是"掃一掃"。

回調參數

成功回調參數:

  • 無回調參數。

失敗回調參數:

  • [string]msg:錯誤訊息。

監聽事件

WVScan.Event.scanSuccess:掃碼成功

事件參數:

  • [string] content:掃碼獲得的結果。

  • [string] format:掃碼的格式。可選值為:

    • [string] QR_CODE: 二維碼。

    • [string] AZTEC: 條碼 - Aztec 2D barcode格式,二維矩陣條碼。

    • [string] CODABAR:條碼 - Codabar 格式。

    • [string] CODE_39:條碼 - Code 39 格式。

    • [string] CODE_93:條碼 - Code 93 格式。

    • [string] CODE_128:條碼 - Code 128 格式。

    • [string] DATA_MATRIX:條碼 - Data Matrix 格式,二維矩陣條碼。

    • [string] EAN_8:條碼 - EAN-8 格式。

    • [string] EAN_13: 條碼 - EAN-13 格式。

    • [string] ITF: 條碼 - 2 of 5 Interleaved 格式。

    • [string] MAXICODE: 條碼 - MaxiCode 格式,六邊形二維條碼。

    • [string] PDF_147: 條碼 - PDF147 格式,二維條碼。

    • [string] RSS_14: 條碼 - RSS 14 格式。

    • [string] RSS_EXPANDED: 條碼 - RSS EXPANDED 格式。

    • [string] UPC_A: 條碼 - UPC-A 格式。

    • [string] UPC_E: 條碼 - UPC-E 格式。

WVScan.Event.scanFailed:掃碼失敗

事件參數:

  • [string] msg:錯誤訊息。

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));
});