Commit 81dc7d6b by zeven

优化收银台回车事件触发按钮问题

parent b6882f09
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
TouchableWithoutFeedback, TouchableWithoutFeedback,
View, View,
} from 'react-native'; } from 'react-native';
import EnterEvent from '../utils/EnterEvent';
let TouchableComponent; let TouchableComponent;
...@@ -30,7 +31,11 @@ export default class PlatformTouchable extends React.Component { ...@@ -30,7 +31,11 @@ export default class PlatformTouchable extends React.Component {
static Ripple = TouchableComponent.Ripple; static Ripple = TouchableComponent.Ripple;
static canUseNativeForeground = TouchableComponent.canUseNativeForeground; static canUseNativeForeground = TouchableComponent.canUseNativeForeground;
onPress = () => { onPress = e => {
if (e.constructor.name === 'SyntheticEvent') {
EnterEvent.emit('Trigger');
return;
}
let {onPress} = this.props; let {onPress} = this.props;
window.count = window.defaultCount; window.count = window.defaultCount;
if (onPress) { if (onPress) {
...@@ -50,9 +55,7 @@ export default class PlatformTouchable extends React.Component { ...@@ -50,9 +55,7 @@ export default class PlatformTouchable extends React.Component {
...props ...props
} = this.props; } = this.props;
if (feedback === false) { if (!feedback) TouchableComponent = TouchableWithoutFeedback;
TouchableComponent = TouchableWithoutFeedback;
}
props.onPress = this.onPress; props.onPress = this.onPress;
// Even though it works for TouchableWithoutFeedback and // Even though it works for TouchableWithoutFeedback and
......
...@@ -16,6 +16,7 @@ import NP from '../utils/np'; ...@@ -16,6 +16,7 @@ import NP from '../utils/np';
import {total} from '../utils/validity'; import {total} from '../utils/validity';
import RedPacketModal from '../components/RedPacketModal'; import RedPacketModal from '../components/RedPacketModal';
import {width, scaleSize} from '../utils/screen'; import {width, scaleSize} from '../utils/screen';
import EnterEvent from '../utils/EnterEvent';
window.RN = RN; window.RN = RN;
window.Toast = Toast; window.Toast = Toast;
...@@ -110,6 +111,10 @@ const CounterMixins = ComposeComponent => { ...@@ -110,6 +111,10 @@ const CounterMixins = ComposeComponent => {
this.barcode += pressedKey; this.barcode += pressedKey;
} }
}); });
EnterEvent.on('Trigger', async () => {
await handleScan();
this.barcode = '';
});
this.listen(); this.listen();
}; };
......
import mitt from './mitt';
const emitter = mitt();
export default emitter;
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