/** * LUMI版本Login页面 * @邠心vbe on 2024/05/31 */ import React from 'react'; import { BackHandler, Image, ScrollView, StyleSheet, TextInput, View } from 'react-native'; import { PageList } from '../Router'; import apiUser from '../../api/apiUser'; import Button from '../../components/Button'; import Dialog from '../../components/Dialog'; import { setAccessToken } from '../../api/http'; import TextView from '../../components/TextView'; import { BackButton } from '../../components/Toolbar'; import CheckBoxText from '../../components/CheckBoxText'; import { getStorageJsonSync, setStorageJson } from '../../utils/storage'; export default class LoginVL extends React.Component { constructor(props) { super(props); this.state = { email: '', password: '', rememberMe: false, showPassword: false } this.isHide = false; this.backHandler = undefined; } componentDidMount() { this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.toExit) this.props.navigation.addListener('focus', () => { this.isHide = false; }); this.props.navigation.addListener('blur', () => { this.isHide = true; }); //this.getEmail(); } componentWillUnmount() { if (this.backHandler) { this.backHandler.remove(); } } toExit = () => { if (!this.isHide) return true; } async getEmail() { const data = await getStorageJsonSync('loginData'); if (data && data.email) { this.setState({ email: data.email }); } } onLogin() { //console.log(this.state); if (this.state.email == '') { toastShort($t('sign.plsInputEmail')); return; } if (this.state.password == '') { toastShort($t('sign.plsInputPassword')); return; } Dialog.showProgressDialog(); apiUser.login(this.state).then(res => { console.log('res.data', res); if (res.data.accessToken) { setAccessToken(res.data.accessToken); Dialog.dismissLoading(); if (this.state.rememberMe) { setStorageJson('loginData', this.state); } else { setStorageJson('loginData', {}); } startPage(PageList.home); //this.props.navigation.goBack(); } else { toastShort(res.msg); Dialog.dismissLoading(); } }).catch(err => { toastShort(err); Dialog.dismissLoading(); }); } getBackTopPosition() { return isIOS ? statusHeight : 4; } togglePassword() { this.setState({ showPassword: !this.state.showPassword }) } render() { return ( {/* */} {/* */} {$t('sign.plsLoginTitle')} {/* */} {/* */} { this.setState({ email: v }) }}/> {/* */} {/* */} { this.setState({ password: v }) }} onSubmitEditing={() => { //this.onLogin(); }}/> this.togglePassword()}/> {/* { this.setState({ rememberMe: newValue }); }} text={$t('sign.rememberMe')} /> */} startPage(PageList.forgotPasswordLumi)}>{$t('sign.forgotPassword')}