bluetooth.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. const util = require('../../utils/util.js')
  2. const BL = require('../../utils/lanya.js')
  3. var pos = require('../../utils/pos.js')
  4. var GXZT;//更新状态
  5. Page({
  6. data: {
  7. LYData: {
  8. openOK: false,//蓝牙是否打开
  9. BLZT: false,//蓝牙状态是否可用
  10. BLSO: false,//蓝牙是否正在搜索
  11. TS: "",
  12. },
  13. LYSB: [],
  14. },
  15. onShow:function(){
  16. //BL.zdlj();
  17. },
  18. onUnload: function () {
  19. //BL.stopBL();
  20. },
  21. openP: function (e) {
  22. BL.OpenPrint();
  23. clearTimeout(GXZT);
  24. tim(this);
  25. },
  26. lianjie: function (e) {
  27. console.log("连接按钮", e)
  28. var uuid = e.currentTarget.dataset.uuid;
  29. BL.lianjie(uuid,function(res){
  30. console.log(res)
  31. });
  32. //BL.dellb(e.currentTarget.dataset.ite);
  33. },
  34. duankai: function (e) {
  35. var uuid = e.currentTarget.dataset.uuid;
  36. BL.duankai(uuid,"no",function(){});
  37. },
  38. Printg: function () {
  39. printText()
  40. },
  41. tuichu:function(){
  42. wx.navigateBack({
  43. delta: 0,
  44. })
  45. }
  46. })
  47. function tim(that) {
  48. that.setData({
  49. LYData: BL.GETData(),
  50. LYSB: BL.GETSB()
  51. })
  52. //console.log(BL.BLData)
  53. GXZT=setTimeout(function () { tim(that) }, 500)
  54. }
  55. function printText() {
  56. console.log("开始打印")
  57. //pos.PrintText("情景4:综合支付不使用零钱也不存零,无找零");//打印标题
  58. pos.PrintJumpLines(5);
  59. pos.PrintTitle(" 测试");//打印标题
  60. pos.PrintNameValue('单号: ', 'ls0220180125000001');
  61. pos.PrintText("收银员: 1001 机器编号: 001");//打印标题
  62. pos.PrintNameValue('时间: ', '2017-12-23 12:01:01');
  63. pos.PrintText("品名 数量 单价 小计");
  64. pos.PrintMiddleText('--------------------------------');
  65. // pos.PrintText("可口可乐(听)");
  66. // pos.PPP("2.0", "2", "4.00");
  67. // pos.PrintText("大泽山葡萄(kg)");
  68. // pos.PPP("12.8", "2.0", "25.6");
  69. // pos.PrintText("大泽山葡萄(盒)");
  70. // pos.PPP("30", "2.0", "60.0");
  71. // pos.PrintMiddleText('--------------------------------');
  72. // pos.PrintNameValue('合计数量: ', '6.0');
  73. // pos.PrintNameValue('标价金额: ', '128.8');
  74. // pos.PrintText('合计优惠(促销/特价等): -2.3');
  75. // pos.PrintNameValue('合计应收: ', '126.5');
  76. // pos.PrintNameValue('实际收款: ', '126.5');
  77. // //pos.PrintNameValue('优惠(抹零): ', '0.5');
  78. // pos.PrintMiddleText('--------------------------------');
  79. // pos.PrintText("收款明细: ");//打印标题
  80. // pos.PrintNameValue('现金: ', '100');
  81. // pos.PrintNameValue('微信刷卡: ', '26.5');
  82. // //pos.PrintNameValue('零钱包支付: ', '0.5');
  83. // //pos.PrintNameValue('现金找零: ', '4.0');
  84. // pos.PrintMiddleText('--------------------------------');
  85. // pos.PrintNameValue('会员卡: ', '132****8588');
  86. // //pos.PrintNameValue('支付前余额: ', '5.00');
  87. // pos.PrintNameValue('当前可用余额: ', '4.5');
  88. // pos.PrintNameValue('本次积分: ', '12.0');
  89. // pos.PrintNameValue('当前可用积分: ', '285.0');
  90. // pos.PrintMiddleText('--------------------------------');
  91. // pos.PrintText("谢谢您的惠顾,欢迎下次光临!");//打印标题
  92. // pos.PrintQRcode('http://xxx.xxx.xxx');//二维码 PrintBarcode: PrintBarcode,//打印条码
  93. // pos.PrintJumpLines(3);
  94. pos.PrintBarcode('6934199500017');//条码
  95. // pos.PrintJumpLines(3);
  96. pos.DaYin(function (res) {
  97. if (res == "err") {
  98. pos.ClearQueue();//清空打印列队
  99. //提示,打印出错,请稍后再试,仍然出错请重新设置打印机
  100. }
  101. });
  102. }