|
|
@@ -4,7 +4,6 @@ import { StyleSheet, View, StatusBar, Platform, Image } from 'react-native'
|
|
|
import { Flex, WingBlank, InputItem } from '@ant-design/react-native'
|
|
|
import { Card, Paragraph, Button, Caption } from 'react-native-paper'
|
|
|
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'
|
|
|
-import { useEventEmitter } from '@umijs/hooks'
|
|
|
import useModel from 'flooks'
|
|
|
import Toast from '../../flooks/Toast'
|
|
|
import user from '../../flooks/User'
|
|
|
@@ -15,7 +14,22 @@ const Tab = createMaterialTopTabNavigator()
|
|
|
const img2 = require('../../assets/images/loginLogo.png')
|
|
|
|
|
|
export default function LoginScreen({ navigation }) {
|
|
|
- const focus$ = useEventEmitter()
|
|
|
+ const btnList = () => (
|
|
|
+ <View style={styles.btn}>
|
|
|
+ <Button
|
|
|
+ mode="ghost"
|
|
|
+ onPress={() => {
|
|
|
+ navigation.navigate('BackPassword')
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Caption style={{ color: '#B4B4B4' }}>忘记密码</Caption>
|
|
|
+ </Button>
|
|
|
+ <Button mode="ghost" onPress={() => {}}>
|
|
|
+ <Caption style={{ color: '#B4B4B4' }}>用户注册</Caption>
|
|
|
+ </Button>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
{Platform.OS !== 'ios' && <StatusBar backgroundColor="#FFF2C7" />}
|
|
|
@@ -59,44 +73,15 @@ export default function LoginScreen({ navigation }) {
|
|
|
<Tab.Screen
|
|
|
name="密码登陆"
|
|
|
component={LoginPassword}
|
|
|
- initialParams={{ focus$ }}
|
|
|
+ initialParams={{ btnList }}
|
|
|
/>
|
|
|
<Tab.Screen
|
|
|
name="验证码登陆"
|
|
|
component={LoginCode}
|
|
|
- initialParams={{ focus$ }}
|
|
|
+ initialParams={{ btnList }}
|
|
|
/>
|
|
|
</Tab.Navigator>
|
|
|
</View>
|
|
|
- <View style={styles.btn}>
|
|
|
- <Button
|
|
|
- mode="ghost"
|
|
|
- onPress={() => {
|
|
|
- navigation.navigate('BackPassword')
|
|
|
- }}
|
|
|
- >
|
|
|
- <Caption style={{ color: '#B4B4B4' }}>忘记密码</Caption>
|
|
|
- </Button>
|
|
|
- <Button mode="ghost" onPress={() => {}}>
|
|
|
- <Caption style={{ color: '#B4B4B4' }}>用户注册</Caption>
|
|
|
- </Button>
|
|
|
- </View>
|
|
|
- <View style={[styles.btn, { marginTop: 20 }]}>
|
|
|
- <Button
|
|
|
- mode="contained"
|
|
|
- contentStyle={{ width: 120 }}
|
|
|
- onPress={() => {}}
|
|
|
- >
|
|
|
- <Paragraph
|
|
|
- style={{ color: '#fff' }}
|
|
|
- onPress={() => {
|
|
|
- focus$.emit()
|
|
|
- }}
|
|
|
- >
|
|
|
- 登录
|
|
|
- </Paragraph>
|
|
|
- </Button>
|
|
|
- </View>
|
|
|
</Card>
|
|
|
</Flex>
|
|
|
</WingBlank>
|
|
|
@@ -105,25 +90,24 @@ export default function LoginScreen({ navigation }) {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-const LoginPassword = ({ navigation, route }) => {
|
|
|
+const LoginPassword = ({ route }) => {
|
|
|
const [phone, setphone] = React.useState()
|
|
|
const [password, setPassword] = React.useState()
|
|
|
|
|
|
const { warnning } = useModel(Toast, [])
|
|
|
const { loginByPsd } = useModel(user, [])
|
|
|
const { params } = route
|
|
|
- const { focus$ } = params || {}
|
|
|
- focus$.useSubscription(() => {
|
|
|
- if (navigation.isFocused()) {
|
|
|
- if (!phone) {
|
|
|
- warnning('手机号不能为空')
|
|
|
- } else if (!password) {
|
|
|
- warnning('密码不能为空')
|
|
|
- } else {
|
|
|
- loginByPsd(phone, password)
|
|
|
- }
|
|
|
+ const { btnList } = params || {}
|
|
|
+
|
|
|
+ const submit = () => {
|
|
|
+ if (!phone) {
|
|
|
+ warnning('手机号不能为空')
|
|
|
+ } else if (!password) {
|
|
|
+ warnning('密码不能为空')
|
|
|
+ } else {
|
|
|
+ loginByPsd(phone, password)
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
|
|
|
return (
|
|
|
<View style={styles.list}>
|
|
|
@@ -147,29 +131,39 @@ const LoginPassword = ({ navigation, route }) => {
|
|
|
>
|
|
|
<Paragraph>密码</Paragraph>
|
|
|
</InputItem>
|
|
|
+
|
|
|
+ {btnList()}
|
|
|
+
|
|
|
+ <View style={[styles.btn, { marginTop: 20 }]}>
|
|
|
+ <Button
|
|
|
+ mode="contained"
|
|
|
+ dark
|
|
|
+ contentStyle={{ width: 120 }}
|
|
|
+ onPress={submit}
|
|
|
+ >
|
|
|
+ 登录
|
|
|
+ </Button>
|
|
|
+ </View>
|
|
|
</View>
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-const LoginCode = ({ navigation, route }) => {
|
|
|
+const LoginCode = ({ route }) => {
|
|
|
const [phone, setphone] = React.useState()
|
|
|
const [code, setCode] = React.useState()
|
|
|
const { warnning } = useModel(Toast, [])
|
|
|
const { loginByPsd } = useModel(user, [])
|
|
|
const { params } = route
|
|
|
- const { focus$ } = params || {}
|
|
|
- focus$.useSubscription(() => {
|
|
|
- if (navigation.isFocused()) {
|
|
|
- if (!phone) {
|
|
|
- warnning('手机号不能为空')
|
|
|
- } else if (!code) {
|
|
|
- warnning('验证码不能为空')
|
|
|
- } else {
|
|
|
- loginByPsd(phone, code)
|
|
|
- }
|
|
|
+ const { btnList } = params || {}
|
|
|
+ const submit = () => {
|
|
|
+ if (!phone) {
|
|
|
+ warnning('手机号不能为空')
|
|
|
+ } else if (!code) {
|
|
|
+ warnning('验证码')
|
|
|
+ } else {
|
|
|
+ loginByPsd(phone, code)
|
|
|
}
|
|
|
- })
|
|
|
-
|
|
|
+ }
|
|
|
return (
|
|
|
<View style={styles.list}>
|
|
|
<InputItem
|
|
|
@@ -197,6 +191,17 @@ const LoginCode = ({ navigation, route }) => {
|
|
|
>
|
|
|
<Paragraph>验证码</Paragraph>
|
|
|
</InputItem>
|
|
|
+ {btnList()}
|
|
|
+ <View style={[styles.btn, { marginTop: 20 }]}>
|
|
|
+ <Button
|
|
|
+ mode="contained"
|
|
|
+ dark
|
|
|
+ contentStyle={{ width: 120 }}
|
|
|
+ onPress={submit}
|
|
|
+ >
|
|
|
+ 登录
|
|
|
+ </Button>
|
|
|
+ </View>
|
|
|
</View>
|
|
|
)
|
|
|
}
|
|
|
@@ -222,11 +227,12 @@ const styles = StyleSheet.create({
|
|
|
backgroundColor: '#fff',
|
|
|
borderWidth: 0,
|
|
|
paddingTop: 10,
|
|
|
+ height: 200,
|
|
|
},
|
|
|
tab: {
|
|
|
- height: 150,
|
|
|
+ flex: 1,
|
|
|
backgroundColor: '#fff',
|
|
|
- paddingBottom: 10,
|
|
|
+ paddingBottom: 20,
|
|
|
},
|
|
|
btn: {
|
|
|
paddingLeft: 80,
|