Commit 08c4f6d7 by zeven

修复没有打印机模块导致闪退问题

parent bbdc5272
{ {
"name": "zm-face-counter", "name": "zm-face-counter",
"version": "1.2.8", "version": "1.2.9",
"private": true, "private": true,
"scripts": { "scripts": {
"android": "react-native run-android", "android": "react-native run-android",
......
...@@ -412,6 +412,14 @@ const CounterMixins = ComposeComponent => { ...@@ -412,6 +412,14 @@ const CounterMixins = ComposeComponent => {
}; };
print = async () => { print = async () => {
const isConnected = await Printer.isConnected();
if (!isConnected) {
const success = await Printer.usbConnect();
if (!success) {
Toast.info('打印机模块未连接,无法打印');
return;
}
}
let total = 0; let total = 0;
let goods = []; let goods = [];
this.state.printer.map(v => { this.state.printer.map(v => {
......
...@@ -189,15 +189,15 @@ if (_Printer) { ...@@ -189,15 +189,15 @@ if (_Printer) {
await Printer.halfCut(); // 半切 await Printer.halfCut(); // 半切
}, },
}; };
(async () => { // (async () => {
// 修复没有打印机模块导致闪退问题 // // 修复没有打印机模块导致闪退问题
try { // try {
const isConnected = await Printer.isConnected(); // const isConnected = await Printer.isConnected();
if (!isConnected) await Printer.usbConnect(); // if (!isConnected) await Printer.usbConnect();
} catch (e) { // } catch (e) {
// do nothing // // do nothing
} // }
})(); // })();
} }
export default Printer; export default Printer;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment