Commit 75151180 by 黄日华

收银程序横屏兼容

parent b447f4dc
...@@ -2,6 +2,7 @@ import React, {Component} from 'react'; ...@@ -2,6 +2,7 @@ import React, {Component} from 'react';
import {Dimensions, Image, Text, View} from 'react-native'; import {Dimensions, Image, Text, View} from 'react-native';
import {appName} from '../utils/config'; import {appName} from '../utils/config';
import {setSpText, scaleSize} from '../utils/screen'; import {setSpText, scaleSize} from '../utils/screen';
const {width, height} = Dimensions.get('window');
class HomeLayout extends Component { class HomeLayout extends Component {
render() { render() {
...@@ -30,7 +31,7 @@ const LandscapeStyles = { ...@@ -30,7 +31,7 @@ const LandscapeStyles = {
top: 0, top: 0,
paddingLeft: scaleSize(50), paddingLeft: scaleSize(50),
flexDirection: 'row', flexDirection: 'row',
height: scaleSize(110), // 修改了这里 height: scaleSize(width > height ? height * 0.12 : height * 0.2), // 修改了这里
width: '100%', width: '100%',
position: 'absolute', position: 'absolute',
backgroundColor: 'white', backgroundColor: 'white',
...@@ -85,8 +86,6 @@ const portraitStyles = { ...@@ -85,8 +86,6 @@ const portraitStyles = {
}, },
}; };
const {width, height} = Dimensions.get('window');
const isLandscape = width > height; const isLandscape = width > height;
const styles = isLandscape ? LandscapeStyles : portraitStyles; const styles = isLandscape ? LandscapeStyles : portraitStyles;
......
...@@ -7,6 +7,7 @@ import {counterLogin} from '../utils/authLogin'; ...@@ -7,6 +7,7 @@ import {counterLogin} from '../utils/authLogin';
import config from '../utils/config'; import config from '../utils/config';
import HomeLayout from '../components/HomeLayout'; import HomeLayout from '../components/HomeLayout';
import {setSpText, scaleSize} from '../utils/screen'; import {setSpText, scaleSize} from '../utils/screen';
const {width, height} = Dimensions.get('window');
class AuthPage extends Component { class AuthPage extends Component {
state = { state = {
...@@ -14,7 +15,6 @@ class AuthPage extends Component { ...@@ -14,7 +15,6 @@ class AuthPage extends Component {
}; };
async componentDidMount() { async componentDidMount() {
const {width, height} = Dimensions.get('window');
this.setState({isLandscape: width > height}); this.setState({isLandscape: width > height});
this.socket = io(axios.defaults.baseURL); this.socket = io(axios.defaults.baseURL);
this.socket.on('storeAuth', this.handleLogin); this.socket.on('storeAuth', this.handleLogin);
...@@ -34,11 +34,12 @@ class AuthPage extends Component { ...@@ -34,11 +34,12 @@ class AuthPage extends Component {
render() { render() {
const {socket, isLandscape} = this.state; const {socket, isLandscape} = this.state;
console.warn(width, height);
return ( return (
<HomeLayout> <HomeLayout>
<View style={styles.qrcode}> <View style={styles.qrcode}>
<QRCode <QRCode
size={isLandscape ? scaleSize(320) : scaleSize(700)} size={isLandscape ? scaleSize(height * 0.35) : scaleSize(700)}
logo={require('../assets/logo.png')} logo={require('../assets/logo.png')}
backgroundColor="white" backgroundColor="white"
value={`${config.qrHost}/#/store-auth-${socket}`} value={`${config.qrHost}/#/store-auth-${socket}`}
......
...@@ -804,6 +804,7 @@ const CounterMixins = ComposeComponent => { ...@@ -804,6 +804,7 @@ const CounterMixins = ComposeComponent => {
return; return;
} }
barcode = barcode || this.barcode; barcode = barcode || this.barcode;
console.warn(barcode);
if (isNaN(barcode.substring(0, 4))) { if (isNaN(barcode.substring(0, 4))) {
const msg = '请遮住条码旁边的二维码,再重新扫条码'; const msg = '请遮住条码旁边的二维码,再重新扫条码';
this.setState({voiceModal: true, voiceTitle: msg}); this.setState({voiceModal: true, voiceTitle: msg});
......
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