12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- import React, { Component } from 'react'
- import { StyleSheet, View, Text, Alert, TouchableOpacity, Image } from 'react-native'
- import { connect } from 'react-redux'
- import { Button, InputItem, List, WhiteSpace, WingBlank } from '@ant-design/react-native';
- import { createAction, ScreenUtil } from '../../utils'
- import {NavigationActions} from "react-navigation";
- @connect(auth => ({...auth}))
- class Login extends Component {
- constructor(props) {
- super(props);
- this.state = {
- username: '',
- password: ''
- };
- }
- onLogin = () => {
- if(this.state.username == ''){
- Alert.alert('提示', '请输入用户名!');
- return
- }
- if(this.state.password == ''){
- Alert.alert('提示', '请输入密码!');
- return
- }
- this.props.dispatch(createAction('auth/login')(this.state))
- }
- renderMessage = content => (
- <Text style={{ marginBottom: 24 }}>{content}</Text>
- );
- render() {
- const {
- loading,
- } = this.props.auth
- return (
- <View style={styles.container}>
- <View style={styles.logoContainer}>
- <Image source={require('../../../assets/images/logo.png')} style={styles.logo}/>
- </View>
- <WhiteSpace size="xl" />
- <List style={styles.list}>
- <InputItem
- clear
- value={this.state.username}
- onChange={value => {
- this.setState({
- username:value,
- });
- }}
- >用户名:</InputItem>
- <InputItem
- clear
- type="password"
- value={this.state.password}
- onChange={value => {
- this.setState({
- password:value,
- });
- }}
- >密码:</InputItem>
- </List>
- <WhiteSpace />
- <WingBlank>
- <Button loading={loading} onPress={this.onLogin} type="primary">登录</Button>
- </WingBlank>
- </View>
- )
- }
- }
- const styles = StyleSheet.create({
- container:{
- flex:1,
- },
- logoContainer:{
- alignItems:'center',
- marginTop: 60
- },
- logo: {
- width:ScreenUtil.scaleSize(80),
- height:ScreenUtil.scaleSize(80),
- },
- list: {
- marginTop: 10
- }
- })
- export default Login
|