| | |
| | | </template> |
| | | |
| | | <script> |
| | | import printerMeta from "../../static/json/printerMeta.json"; |
| | | import { |
| | | CommonUtils |
| | | } from '../../utils/common'; |
| | |
| | | that.clock.stop(); |
| | | reject(new Error('读取超时')); |
| | | } |
| | | }, 2000); |
| | | }, printerMeta['timeoutPerMillSecond']); |
| | | |
| | | // 启动时钟 |
| | | that.clock.start(); |
| | |
| | | title: "发送中..." |
| | | }) |
| | | // console.log("msg: " + cmd); |
| | | let toast = (msg) => { |
| | | uni.hideLoading() |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: msg, |
| | | duration: 2000 |
| | | }) |
| | | } |
| | | let that = this |
| | | return new Promise((resolve, reject) => { |
| | | const result = blueToothTool.sendByteData(cmd); |
| | | if (!result) { |
| | | toast("发送失败,请重试...") |
| | | reject(false) |
| | | this.clock.stop(); |
| | | reject("发送失败,请重试...") |
| | | } |
| | | that.checkReadSuccess(5) |
| | | that.checkReadSuccess(printerMeta['timeoutCount']) |
| | | .then((res) => { |
| | | if (res === true) { |
| | | toast('发送成功!!!') |
| | | resolve(true) |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | toast('设备异常,请检查设备状态...') |
| | | reject(false) |
| | | this.clock.stop(); |
| | | reject('设备异常,请检查设备状态...') |
| | | }) |
| | | .finally(() => { |
| | | that.readSuccess = false |