如何在流星应用程序中扫描条形码图像

时间:2015-06-13 23:21:55

标签: meteor

我想整合一个适合移动设备的数据采集应用 此应用程序将用于数据中心,这意味着在断开连接模式下工作 这个应用程序还需要(在客户端)携带一个ASCI的mongodb集合字符代码,与传入的条形码匹配 一旦重新联机,此应用程序应将所有获取的数据与其后端mongodb同步

基于这些要求,我认为,流星将是一个不错的选择

我的问题是:是否有可以扫描图像的流星包,然后将该图像转换为ASCII字符代码?

1 个答案:

答案 0 :(得分:14)

要获得条形码扫描功能,请使用BarcodeScanner cordova插件:

meteor add cordova:com.phonegap.plugins.barcodescanner@2.0.1

模板

<head>
  <title>Barcode Scanner</title>
</head>

<body
  {{> barcode_scanner}}
</body>

<template name="barcode_scanner">
  <button>Scan</button>
</template>

JS

if (Meteor.isCordova) {

  Template.barcode_scanner.events({
    'click button': function () {

      cordova.plugins.barcodeScanner.scan(
        function (result) {
          alert("We got a barcode\n" +
            "Result: " + result.text + "\n" +
            "Format: " + result.format + "\n" +
            "Cancelled: " + result.cancelled);
        }, 
        function (error) {
          alert("Scanning failed: " + error);
        }
     );

    }

  });

}

对于离线数据功能,请查看GroundDB