ZXingScannerApi.js 721 B

1234567891011121314151617181920212223242526272829
  1. if(typeof(plugin) == "undefined"){
  2. var plugin = {};
  3. }
  4. plugin.barCode = {};
  5. /**
  6. * 启动摄像头扫码
  7. * continuous: true:连续扫描, false:不连续扫描
  8. */
  9. plugin.barCode.scan = function (continuous){
  10. if(typeof(ZXING_SCANNER) == "undefined"){
  11. alert("设备不支持摄像头扫码。");
  12. }else{
  13. ZXING_SCANNER.start((continuous == true) ? "continuous" : "notContinuous");
  14. }
  15. }
  16. /**
  17. * ZXING读取到数据的事件
  18. * 外部js需要覆盖该方法
  19. */
  20. plugin.barCode.scanEvent = function (barCodeStrs){
  21. if(barCodeStrs != undefined && barCodeStrs.length > 0){
  22. var barCodes = barCodeStrs.split(",");
  23. alert("读取到" + barCodes.length + "个条码。");
  24. }
  25. }