Commit f553da2c by zeven

修复触摸事件影响扫码枪

parent 4e11f08f
......@@ -57,3 +57,5 @@ buck-out/
# CocoaPods
/ios/Pods/
*.apk
android @ a68acacc
Subproject commit f1af412d416703975a237f1787c7047c62cdafcd
Subproject commit a68acacc0bd5b01ab34362b4ef09bbab72ded3d5
......@@ -7,7 +7,7 @@
"start": "react-native start",
"test": "jest",
"lint": "eslint --ext .js index.js src",
"apk": "cd android && ./gradlew assembleRelease && cp ./app/build/outputs/apk/release/app-release.apk ../release.apk"
"apk": "cd android && ./gradlew app:assembleRelease && cp ./app/build/outputs/apk/release/app-release.apk ../counter.apk"
},
"pre-commit": [
"lint"
......
......@@ -9,7 +9,6 @@ import Modal from './Modal';
import Toast from './Toast';
import Touch from './Touch';
import {counterInterval} from '../utils/authInterval';
import {switchQr, switchEnv} from '../utils/switchHost';
const weekdays = {
0: '周日',
......@@ -130,7 +129,7 @@ class Layout extends React.Component {
};
render() {
const {children, app} = this.props;
const {children} = this.props;
let {contact, maskVisible, dateInfo, visibleActive} = this.state;
contact = contact || '未授权';
return (
......@@ -163,37 +162,29 @@ class Layout extends React.Component {
</View>
</View>
</View>
<Touch
onPress={!app.lock && this.showCounterLogin}
style={{alignItems: 'center'}}>
<Image
style={{width: 325, height: 36, resizeMode: 'contain'}}
source={require('../assets/zmgo_title.png')}
/>
<View style={styles.navRight}>
<Image
style={{width: 325, height: 36, resizeMode: 'contain'}}
source={require('../assets/zmgo_title.png')}
source={require('../assets/phone_icon.png')}
style={{
width: 36,
height: 36,
marginRight: 5,
resizeMode: 'contain',
}}
/>
</Touch>
<View style={styles.navRight}>
<Touch onPress={!app.lock && switchQr}>
<Image
source={require('../assets/phone_icon.png')}
style={{
width: 36,
height: 36,
marginRight: 5,
resizeMode: 'contain',
}}
/>
</Touch>
<Touch onPress={!app.lock && switchEnv}>
<Text
style={{
color: '#F5AB61',
fontSize: 32,
fontWeight: 'bold',
marginRight: 20,
}}>
{contact}
</Text>
</Touch>
<Text
style={{
color: '#F5AB61',
fontSize: 32,
fontWeight: 'bold',
marginRight: 20,
}}>
{contact}
</Text>
</View>
</View>
{maskVisible ? (
......
......@@ -45,11 +45,12 @@ export default class PlatformTouchable extends React.Component {
foreground,
background,
useForeground,
feddback,
feedback,
viewWrap,
...props
} = this.props;
if (feddback === false) {
if (feedback === false) {
TouchableComponent = TouchableWithoutFeedback;
}
props.onPress = this.onPress;
......@@ -59,6 +60,9 @@ export default class PlatformTouchable extends React.Component {
// the API to be the same for all components so we require
// exactly one direct child for every touchable type.
children = React.Children.only(children);
if (viewWrap !== false) {
children = <View style={style}>{children}</View>;
}
if (TouchableComponent === TouchableNativeFeedback) {
useForeground =
......@@ -76,13 +80,13 @@ export default class PlatformTouchable extends React.Component {
{...props}
useForeground={useForeground}
background={(useForeground && foreground) || background}>
<View style={style}>{children}</View>
{children}
</TouchableComponent>
);
} else if (TouchableComponent === TouchableWithoutFeedback) {
return (
<TouchableWithoutFeedback {...props}>
<View style={style}>{children}</View>
{children}
</TouchableWithoutFeedback>
);
} else {
......
import AsyncStorage from '@react-native-community/async-storage';
import * as api from '../services/admin';
import axios from 'axios';
export default {
namespace: 'admin',
......@@ -33,6 +34,9 @@ export default {
let login = action.login;
action.device = login;
delete action.login;
if (action.host) {
axios.defaults.baseURL = action.host;
}
const {data} = action.key
? yield call(api.token, action)
: yield call(api.refreshToken);
......@@ -43,6 +47,9 @@ export default {
if (action.key) {
yield call(AsyncStorage.setItem, 'KEY', action.key);
}
if (action.host) {
yield call(AsyncStorage.setItem, 'HOST', action.host);
}
yield put({type: 'setAuth', id: data.id, auth: data.data, login});
}
return data;
......
......@@ -22,9 +22,6 @@ class AuthPage extends Component {
handleLogin = async values => {
this.setState({loading: true});
if (!values.host) {
values.host = config.host;
}
values.login = values.device;
await counterLogin(values);
};
......
......@@ -80,7 +80,8 @@ const CounterMixins = ComposeComponent => {
DeviceEventEmitter.addListener('onError', () => (this.busy = false));
const handleScan = this.submitBarcode;
// if you want to react to keyUp
KeyEvent.onKeyUpListener(async ({keyCode}) => {
KeyEvent.onKeyUpListener(async e => {
const {keyCode} = e;
if (keyCode === 66) {
// 回车事件
await handleScan();
......@@ -93,7 +94,6 @@ const CounterMixins = ComposeComponent => {
};
componentWillUnmount = () => {
clearInterval(this.preventInter);
clearInterval(this.clearListInter);
clearInterval(this.payInter);
clearTimeout(this.paidTimeout);
......
......@@ -15,7 +15,6 @@ import phone from '../assets/Vertical/phone.png';
import {login} from '../utils/config';
import {colors} from '../utils/common';
import WxFacepay from '../utils/WxFacepay';
import {switchQr, switchEnv} from '../utils/switchHost';
import {width} from '../utils/screen';
let pageSize = 8; // 分页大小
......@@ -189,23 +188,22 @@ class VerticalPage extends Component {
</View>
<View style={styles.TdStyle}>
{item.numChange ? (
<Touch
<Icon
onPress={() =>
this.props.numRemove(
item.num,
index + (this.props.current - 1) * pageSize,
)
}>
<Icon
name="ios-remove-circle"
color={item.num === 1 ? '#909090' : '#00c670'}
size={35}
/>
</Touch>
}
name="ios-remove-circle"
color={item.num === 1 ? '#909090' : '#00c670'}
size={35}
/>
) : (
<View />
)}
<Touch
viewWrap={false}
onPress={() =>
item.numChange &&
this.props.numChange(index + (this.props.current - 1) * pageSize)
......@@ -213,15 +211,17 @@ class VerticalPage extends Component {
<Text style={styles.TdText}> {item.num} </Text>
</Touch>
{item.numChange ? (
<Touch
<Icon
name="ios-add-circle"
color="#00c670"
size={35}
onPress={() =>
this.props.numAdd(
item.num,
index + (this.props.current - 1) * pageSize,
)
}>
<Icon name="ios-add-circle" color="#00c670" size={35} />
</Touch>
}
/>
) : (
<View />
)}
......@@ -236,20 +236,22 @@ class VerticalPage extends Component {
{NP.round(item.prePrice * item.num, 2).toFixed(2)}
</Text>
)}
<Touch
<Icon
style={{marginLeft: 10}}
name="ios-close-circle"
size={35}
color={colors.bg}
onPress={() =>
this.props.removeIndex(index + (this.props.current - 1) * pageSize)
}
style={{marginLeft: 10}}>
<Icon name="ios-close-circle" size={35} color={colors.bg} />
</Touch>
/>
</View>
</View>
);
render() {
let {admin, goods, goodsArr, qrHost, current} = this.props;
let {contact, maskVisible, visibleActive} = this.state;
let {contact} = this.state;
pageSize = goods && goods.bags.length > 0 ? 7 : pageSize;
window.pageSize = pageSize;
contact = contact || '未授权';
......@@ -278,53 +280,10 @@ class VerticalPage extends Component {
<Image source={img24h} />
</View>
<View style={styles.right}>
<Touch onPress={switchQr}>
<Image style={styles.phone} source={phone} />
</Touch>
<Touch onPress={switchEnv}>
<Text style={styles.number}>{contact}</Text>
</Touch>
<Image style={styles.phone} source={phone} />
<Text style={styles.number}>{contact}</Text>
</View>
</View>
{maskVisible ? (
<View style={styles.navMask}>
<Touch
onPress={() => this.stepOne()}
style={{
width: 120,
height: 80,
backgroundColor: visibleActive ? colors.bg : 'transparent',
}}>
<View />
</Touch>
<View style={{flex: 1, alignItems: 'center'}} />
<View
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-end',
}}>
<Touch
onPress={() => this.stepTwo()}
style={{width: 150, height: 80}}>
<View />
</Touch>
<View style={{opacity: 0}}>
<Text
style={{
color: '#F5AB61',
fontSize: 32,
fontWeight: 'bold',
marginRight: 20,
}}>
{contact}
</Text>
</View>
</View>
</View>
) : (
<View style={{display: 'none'}} />
)}
<View style={styles.container}>
<View style={{flexDirection: 'row', flex: 1}}>
<View style={{width: '90%'}}>
......
......@@ -25,7 +25,7 @@ const loginError = async msg => {
Toast.fail(msg, 1);
};
export const counterLogin = async ({key, secret, device = 'counter'}) => {
export const counterLogin = async ({key, secret, device = 'counter', host}) => {
if (!key) {
await loginError('请输入门店标识');
return;
......@@ -40,7 +40,7 @@ export const counterLogin = async ({key, secret, device = 'counter'}) => {
return;
}
await Toast.loading('授权认证中');
const action = {type: 'admin/auth', key, secret, login: device};
const action = {type: 'admin/auth', key, secret, login: device, host};
// const { dispatch } = this.props;
// const res = await dispatch(action);
const res = await window.dispatch(action);
......
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