|
|
@@ -6,215 +6,260 @@ import { ScrollView } from 'react-native-gesture-handler';
|
|
|
import { TextInputMask } from 'react-native-masked-text';
|
|
|
import { useMount } from 'ahooks';
|
|
|
import { useNavigation } from '@react-navigation/native';
|
|
|
+import { useTranslation } from 'react-i18next';
|
|
|
+import useModel from 'flooks';
|
|
|
|
|
|
-import { RootStackParamList, LoginTabParamList } from '../types';
|
|
|
+import { MainStackParamList, LoginTabParamList } from '../types';
|
|
|
import Navigation from '../navigation';
|
|
|
|
|
|
+import Login from './model';
|
|
|
+
|
|
|
const LoginTab = createMaterialTopTabNavigator<LoginTabParamList>();
|
|
|
|
|
|
-export default function LoginScreen({ navigation }: StackScreenProps<RootStackParamList, 'Login'>) {
|
|
|
- return (
|
|
|
- <Div flex={1} bg="yellow200">
|
|
|
- <ScrollView
|
|
|
- contentContainerStyle={{
|
|
|
- flexGrow: 1,
|
|
|
- backgroundColor: '#FFF2C7',
|
|
|
- justifyContent: 'center'
|
|
|
- }}
|
|
|
- keyboardDismissMode="on-drag"
|
|
|
- >
|
|
|
- <Div bg="white" mx={13} px={10} py={20} rounded="xs">
|
|
|
- <Image
|
|
|
- source={require('../assets/images/loginImg2.png')}
|
|
|
- alignSelf="center"
|
|
|
- w={217}
|
|
|
- h={100}
|
|
|
- />
|
|
|
+export default function LoginScreen({
|
|
|
+ navigation,
|
|
|
+}: StackScreenProps<MainStackParamList, 'Login'>) {
|
|
|
+ const { t } = useTranslation();
|
|
|
+ return (
|
|
|
+ <Div flex={1} bg="yellow200">
|
|
|
+ <ScrollView
|
|
|
+ contentContainerStyle={{
|
|
|
+ flexGrow: 1,
|
|
|
+ backgroundColor: '#FFF2C7',
|
|
|
+ justifyContent: 'center',
|
|
|
+ }}
|
|
|
+ keyboardDismissMode="on-drag"
|
|
|
+ >
|
|
|
+ <Div bg="white" mx={13} px={10} py={20} rounded="xs">
|
|
|
+ <Image
|
|
|
+ source={require('../assets/images/loginImg2.png')}
|
|
|
+ alignSelf="center"
|
|
|
+ w={217}
|
|
|
+ h={100}
|
|
|
+ />
|
|
|
|
|
|
- <Image
|
|
|
- source={require('../assets/images/loginImg.png')}
|
|
|
- w={275}
|
|
|
- h={60}
|
|
|
- position="absolute"
|
|
|
- top={-59}
|
|
|
- left="50%"
|
|
|
- ml={-137}
|
|
|
- zIndex={2}
|
|
|
- />
|
|
|
+ <Image
|
|
|
+ source={require('../assets/images/loginImg.png')}
|
|
|
+ w={275}
|
|
|
+ h={60}
|
|
|
+ position="absolute"
|
|
|
+ top={-59}
|
|
|
+ left="50%"
|
|
|
+ ml={-137}
|
|
|
+ zIndex={2}
|
|
|
+ />
|
|
|
|
|
|
- <Div bg="white">
|
|
|
- <LoginTab.Navigator
|
|
|
- initialRouteName="Psd"
|
|
|
- tabBarOptions={{
|
|
|
- inactiveTintColor: '#000',
|
|
|
- activeTintColor: '#FFC21C',
|
|
|
- indicatorStyle: { height: 0 },
|
|
|
- labelStyle: { fontSize: 13 }
|
|
|
- }}
|
|
|
- >
|
|
|
- <LoginTab.Screen
|
|
|
- name="Psd"
|
|
|
- component={LoginByPsd}
|
|
|
- options={{
|
|
|
- title: '密码登录',
|
|
|
- backgroundColor: '#fff'
|
|
|
- }}
|
|
|
- />
|
|
|
- <LoginTab.Screen
|
|
|
- name="Code"
|
|
|
- component={LoginByCode}
|
|
|
- options={{
|
|
|
- title: '验证码登录'
|
|
|
- }}
|
|
|
- />
|
|
|
- </LoginTab.Navigator>
|
|
|
- </Div>
|
|
|
- </Div>
|
|
|
- </ScrollView>
|
|
|
+ <Div bg="white">
|
|
|
+ <LoginTab.Navigator
|
|
|
+ initialRouteName="Psd"
|
|
|
+ tabBarOptions={{
|
|
|
+ inactiveTintColor: '#000',
|
|
|
+ activeTintColor: '#FFC21C',
|
|
|
+ indicatorStyle: { height: 0 },
|
|
|
+ labelStyle: { fontSize: 13 },
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <LoginTab.Screen
|
|
|
+ name="Psd"
|
|
|
+ component={LoginByPsd}
|
|
|
+ options={{
|
|
|
+ title: t('mi-ma-deng-lu'),
|
|
|
+ backgroundColor: '#fff',
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <LoginTab.Screen
|
|
|
+ name="Code"
|
|
|
+ component={LoginByCode}
|
|
|
+ options={{
|
|
|
+ title: t('yan-zheng-ma-deng-lu'),
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </LoginTab.Navigator>
|
|
|
+ </Div>
|
|
|
</Div>
|
|
|
- );
|
|
|
+ </ScrollView>
|
|
|
+ </Div>
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
function LoginByPsd() {
|
|
|
- const [phone, setphone] = React.useState<string>('');
|
|
|
- const [password, setpassword] = React.useState<string>('');
|
|
|
+ const { t } = useTranslation();
|
|
|
+ const [phone, setphone] = React.useState<string>('');
|
|
|
+ const [password, setpassword] = React.useState<string>('');
|
|
|
+ const navigation = useNavigation();
|
|
|
|
|
|
- const navigation = useNavigation();
|
|
|
- return (
|
|
|
- <Div bg="white">
|
|
|
- <Div row alignItems="center" py={10}>
|
|
|
- <Text w={96} textAlign="right">
|
|
|
- 手机号:
|
|
|
- </Text>
|
|
|
- <Div flex={1} bg="gray100" rounded="sm" px={15} ml={5} h={30} alignItems="stretch">
|
|
|
- <TextInputMask
|
|
|
- type={'custom'}
|
|
|
- value={phone}
|
|
|
- keyboardType="numeric"
|
|
|
- options={{
|
|
|
- mask: '999 9999 9999'
|
|
|
- }}
|
|
|
- onChangeText={(text) => {
|
|
|
- console.log(text);
|
|
|
- setphone(text);
|
|
|
- }}
|
|
|
- style={{ flex: 1, fontSize: 14 }}
|
|
|
- placeholder="输入商家名称"
|
|
|
- />
|
|
|
- </Div>
|
|
|
- </Div>
|
|
|
- <Div row alignItems="center" py={10}>
|
|
|
- <Text w={96} textAlign="right">
|
|
|
- 密 码:
|
|
|
- </Text>
|
|
|
- <Input
|
|
|
- flex={1}
|
|
|
- bg="gray100"
|
|
|
- rounded="sm"
|
|
|
- px={15}
|
|
|
- ml={5}
|
|
|
- h={30}
|
|
|
- type={'custom'}
|
|
|
- value={password}
|
|
|
- borderWidth={0}
|
|
|
- fontSize="md"
|
|
|
- secureTextEntry
|
|
|
- color="gray700"
|
|
|
- onChangeText={(text) => {
|
|
|
- console.log(text);
|
|
|
- setpassword(text);
|
|
|
- }}
|
|
|
- style={{ flex: 1 }}
|
|
|
- placeholder="输入密码"
|
|
|
- />
|
|
|
- </Div>
|
|
|
+ const loginModel = useModel(Login, []);
|
|
|
|
|
|
- <Div row justifyContent="space-between" pl={90}>
|
|
|
- <Button
|
|
|
- color="gray400"
|
|
|
- fontSize="sm"
|
|
|
- bg="white"
|
|
|
- onPress={() => navigation.navigate('ForgetPsd')}
|
|
|
- >
|
|
|
- 忘记密码
|
|
|
- </Button>
|
|
|
- <Button
|
|
|
- color="gray400"
|
|
|
- fontSize="sm"
|
|
|
- bg="white"
|
|
|
- onPress={() => navigation.navigate('Root')}
|
|
|
- >
|
|
|
- 骑手注册
|
|
|
- </Button>
|
|
|
- </Div>
|
|
|
-
|
|
|
- <Button block bg="yellow500" w={112} fontSize="sm" ml={96} mt={10}>
|
|
|
- 登录
|
|
|
- </Button>
|
|
|
+ return (
|
|
|
+ <Div bg="white">
|
|
|
+ <Div row alignItems="center" py={10}>
|
|
|
+ <Text w={96} textAlign="right">
|
|
|
+ {t('shou-ji-hao')}:
|
|
|
+ </Text>
|
|
|
+ <Div
|
|
|
+ flex={1}
|
|
|
+ bg="gray100"
|
|
|
+ rounded="sm"
|
|
|
+ px={15}
|
|
|
+ ml={5}
|
|
|
+ h={30}
|
|
|
+ alignItems="stretch"
|
|
|
+ >
|
|
|
+ <TextInputMask
|
|
|
+ type={'custom'}
|
|
|
+ value={phone}
|
|
|
+ keyboardType="numeric"
|
|
|
+ options={{
|
|
|
+ mask: '999 9999 9999',
|
|
|
+ }}
|
|
|
+ onChangeText={(text) => {
|
|
|
+ console.log(text);
|
|
|
+ setphone(text);
|
|
|
+ }}
|
|
|
+ style={{ flex: 1, fontSize: 14 }}
|
|
|
+ placeholder={t('shu-ru-shang-jia-ming-cheng')}
|
|
|
+ />
|
|
|
</Div>
|
|
|
- );
|
|
|
+ </Div>
|
|
|
+ <Div row alignItems="center" py={10}>
|
|
|
+ <Text w={96} textAlign="right">
|
|
|
+ {t('mi-ma')}:
|
|
|
+ </Text>
|
|
|
+ <Input
|
|
|
+ flex={1}
|
|
|
+ bg="gray100"
|
|
|
+ rounded="sm"
|
|
|
+ px={15}
|
|
|
+ ml={5}
|
|
|
+ h={30}
|
|
|
+ type={'custom'}
|
|
|
+ value={password}
|
|
|
+ borderWidth={0}
|
|
|
+ fontSize="md"
|
|
|
+ secureTextEntry
|
|
|
+ color="gray700"
|
|
|
+ onChangeText={(text) => {
|
|
|
+ console.log(text);
|
|
|
+ setpassword(text);
|
|
|
+ }}
|
|
|
+ style={{ flex: 1 }}
|
|
|
+ placeholder={t('shu-ru-mi-ma')}
|
|
|
+ />
|
|
|
+ </Div>
|
|
|
+
|
|
|
+ <Div row justifyContent="space-between" pl={90}>
|
|
|
+ <Button
|
|
|
+ color="gray400"
|
|
|
+ fontSize="sm"
|
|
|
+ bg="white"
|
|
|
+ onPress={() => navigation.navigate('ForgetPsd')}
|
|
|
+ >
|
|
|
+ {t('wang-ji-mi-ma')}
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ color="gray400"
|
|
|
+ fontSize="sm"
|
|
|
+ bg="white"
|
|
|
+ onPress={() => navigation.navigate('Register')}
|
|
|
+ >
|
|
|
+ {t('qi-shou-zhu-ce')}
|
|
|
+ </Button>
|
|
|
+ </Div>
|
|
|
+
|
|
|
+ <Button
|
|
|
+ block
|
|
|
+ bg="yellow500"
|
|
|
+ w={112}
|
|
|
+ fontSize="sm"
|
|
|
+ ml={96}
|
|
|
+ mt={10}
|
|
|
+ onPress={() => {
|
|
|
+ loginModel.loginByPsd();
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {t('deng-lu')}
|
|
|
+ </Button>
|
|
|
+ </Div>
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
function LoginByCode() {
|
|
|
- const [phone, setphone] = React.useState<string>('');
|
|
|
- const [code, setCode] = React.useState<string>('');
|
|
|
- return (
|
|
|
- <Div bg="white">
|
|
|
- <Div row alignItems="center" py={10}>
|
|
|
- <Text w={96} textAlign="right">
|
|
|
- 手机号:
|
|
|
- </Text>
|
|
|
- <Div flex={1} bg="gray100" rounded="sm" px={15} ml={5} h={30} alignItems="stretch">
|
|
|
- <TextInputMask
|
|
|
- type={'custom'}
|
|
|
- value={phone}
|
|
|
- keyboardType="numeric"
|
|
|
- options={{
|
|
|
- mask: '999 9999 9999'
|
|
|
- }}
|
|
|
- onChangeText={(text) => {
|
|
|
- console.log(text);
|
|
|
- setphone(text);
|
|
|
- }}
|
|
|
- style={{ flex: 1, fontSize: 14 }}
|
|
|
- placeholder="输入手机号"
|
|
|
- />
|
|
|
- </Div>
|
|
|
- </Div>
|
|
|
- <Div row alignItems="center" py={10}>
|
|
|
- <Text w={96} textAlign="right">
|
|
|
- 验证码:
|
|
|
- </Text>
|
|
|
- <Div flex={1} bg="gray100" rounded="sm" px={15} ml={5} h={30} alignItems="stretch">
|
|
|
- <TextInputMask
|
|
|
- type={'custom'}
|
|
|
- value={code}
|
|
|
- keyboardType="numeric"
|
|
|
- options={{
|
|
|
- mask: '9999'
|
|
|
- }}
|
|
|
- onChangeText={(text) => {
|
|
|
- console.log(text);
|
|
|
- setCode(text);
|
|
|
- }}
|
|
|
- style={{ flex: 1, fontSize: 14 }}
|
|
|
- placeholder="输入验证码"
|
|
|
- />
|
|
|
- </Div>
|
|
|
- </Div>
|
|
|
+ const { t } = useTranslation();
|
|
|
+ const [phone, setphone] = React.useState<string>('');
|
|
|
+ const [code, setCode] = React.useState<string>('');
|
|
|
+ return (
|
|
|
+ <Div bg="white">
|
|
|
+ <Div row alignItems="center" py={10}>
|
|
|
+ <Text w={96} textAlign="right">
|
|
|
+ {t('shou-ji-hao')}:
|
|
|
+ </Text>
|
|
|
+ <Div
|
|
|
+ flex={1}
|
|
|
+ bg="gray100"
|
|
|
+ rounded="sm"
|
|
|
+ px={15}
|
|
|
+ ml={5}
|
|
|
+ h={30}
|
|
|
+ alignItems="stretch"
|
|
|
+ >
|
|
|
+ <TextInputMask
|
|
|
+ type={'custom'}
|
|
|
+ value={phone}
|
|
|
+ keyboardType="numeric"
|
|
|
+ options={{
|
|
|
+ mask: '999 9999 9999',
|
|
|
+ }}
|
|
|
+ onChangeText={(text) => {
|
|
|
+ console.log(text);
|
|
|
+ setphone(text);
|
|
|
+ }}
|
|
|
+ style={{ flex: 1, fontSize: 14 }}
|
|
|
+ placeholder={t('shu-ru-shou-ji-hao')}
|
|
|
+ />
|
|
|
+ </Div>
|
|
|
+ </Div>
|
|
|
+ <Div row alignItems="center" py={10}>
|
|
|
+ <Text w={96} textAlign="right">
|
|
|
+ {t('yan-zheng-ma')}:
|
|
|
+ </Text>
|
|
|
+ <Div
|
|
|
+ flex={1}
|
|
|
+ bg="gray100"
|
|
|
+ rounded="sm"
|
|
|
+ px={15}
|
|
|
+ ml={5}
|
|
|
+ h={30}
|
|
|
+ alignItems="stretch"
|
|
|
+ >
|
|
|
+ <TextInputMask
|
|
|
+ type={'custom'}
|
|
|
+ value={code}
|
|
|
+ keyboardType="numeric"
|
|
|
+ options={{
|
|
|
+ mask: '9999',
|
|
|
+ }}
|
|
|
+ onChangeText={(text) => {
|
|
|
+ console.log(text);
|
|
|
+ setCode(text);
|
|
|
+ }}
|
|
|
+ style={{ flex: 1, fontSize: 14 }}
|
|
|
+ placeholder={t('shu-ru-yan-zheng-ma')}
|
|
|
+ />
|
|
|
+ </Div>
|
|
|
+ </Div>
|
|
|
|
|
|
- <Div row justifyContent="space-between" pl={90}>
|
|
|
- <Button color="gray400" fontSize="sm" bg="white">
|
|
|
- 忘记密码
|
|
|
- </Button>
|
|
|
- <Button color="gray400" fontSize="sm" bg="white">
|
|
|
- 骑手注册
|
|
|
- </Button>
|
|
|
- </Div>
|
|
|
+ <Div row justifyContent="space-between" pl={90}>
|
|
|
+ <Button color="gray400" fontSize="sm" bg="white">
|
|
|
+ {t('wang-ji-mi-ma')}
|
|
|
+ </Button>
|
|
|
+ <Button color="gray400" fontSize="sm" bg="white">
|
|
|
+ {t('qi-shou-zhu-ce')}
|
|
|
+ </Button>
|
|
|
+ </Div>
|
|
|
|
|
|
- <Button block bg="yellow500" w={112} fontSize="sm" ml={96} mt={10}>
|
|
|
- 登录
|
|
|
- </Button>
|
|
|
- </Div>
|
|
|
- );
|
|
|
+ <Button block bg="yellow500" w={112} fontSize="sm" ml={96} mt={10}>
|
|
|
+ {t('deng-lu')}
|
|
|
+ </Button>
|
|
|
+ </Div>
|
|
|
+ );
|
|
|
}
|