BluetoothPrinterApi.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. if(typeof(plugin) == "undefined"){
  2. var plugin = {};
  3. }
  4. plugin.bluetoothPrinter = {};
  5. plugin.bluetoothPrinter.print = function (data){
  6. if(typeof(BLUETOOTH_PRINTER) == "undefined"){
  7. alert("设备不支持蓝牙打印。");
  8. }else{
  9. BLUETOOTH_PRINTER.print(data);
  10. }
  11. }
  12. plugin.bluetoothPrinter.printTest = function ()
  13. {
  14. var DATA =
  15. "{"
  16. +"'paperHeight':30.0,"
  17. +"'paperWidth':100.0,"
  18. +"'paperMargin' : 2,"
  19. +"'printItems' : ["
  20. +"{"
  21. +"'content':'测试文本',"
  22. +"'enabled':true,"
  23. +"'displayType':'文本',"
  24. +"'left':5.0,"
  25. +"'top':5.0,"
  26. +"'width':40.0,"
  27. +"'height':4.0"
  28. +"},"
  29. +"{"
  30. +"'content':'123456',"
  31. +"'enabled':true,"
  32. +"'displayType':'条形码',"
  33. +"'left':5.0,"
  34. +"'top':10.0,"
  35. +"'width':30.0,"
  36. +"'height':5.0"
  37. +"},"
  38. +"{"
  39. +"'content':'123456789012345678901236',"
  40. +"'enabled':true,"
  41. +"'displayType':'二维码',"
  42. +"'left':5.0,"
  43. +"'top':18.0,"
  44. +"'width':10.0,"
  45. +"'height':7.0"
  46. +"},"
  47. +"{"
  48. +"'content':'123456789012345678901233',"
  49. +"'displayType':'EPC',"
  50. +"'enabled':true,"
  51. +"'left':0,"
  52. +"'top':0,"
  53. +"'width':0,"
  54. +"'height':0"
  55. +"}"
  56. +"]"
  57. +"}";
  58. plugin.bluetoothPrinter.print(DATA);
  59. }