|
@@ -1,4 +1,4 @@
|
|
|
-import React, {useState} from 'react';
|
|
|
+import React, { useState } from 'react';
|
|
|
import {
|
|
|
View,
|
|
|
Text,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
} from 'react-native';
|
|
|
import { useNavigation } from '@react-navigation/native';
|
|
|
|
|
|
-const LoginScreen = ({}) => {
|
|
|
+const LoginScreen = ({ }) => {
|
|
|
const navigation = useNavigation();
|
|
|
const [username, setUsername] = useState('manage1');
|
|
|
const [password, setPassword] = useState('trops@2022');
|
|
@@ -23,7 +23,7 @@ const LoginScreen = ({}) => {
|
|
|
|
|
|
const handleLogin = async () => {
|
|
|
if (!username || !password) {
|
|
|
- ToastAndroid.show('请输入用户名和密码',2000);
|
|
|
+ ToastAndroid.show('请输入用户名和密码', 2000);
|
|
|
return;
|
|
|
}
|
|
|
setIsLoading(true);
|
|
@@ -32,17 +32,17 @@ const LoginScreen = ({}) => {
|
|
|
username,
|
|
|
password,
|
|
|
};
|
|
|
- global.$http.common.getLogin(params).then((res:any) => {
|
|
|
- console.log("eeeeeee",res)
|
|
|
+ global.$http.common.getLogin(params).then((res: any) => {
|
|
|
+ console.log("eeeeeee", res)
|
|
|
if (res.data.access_token) {
|
|
|
// let token = "JWT " + res.data.access_token;
|
|
|
- ToastAndroid.show('登录成功',2000);
|
|
|
- navigation.navigate('Home'); // 登录成功后跳转到主页
|
|
|
+ ToastAndroid.show('登录成功', 2000);
|
|
|
+ navigation.navigate('MainTabs'); // 登录成功后跳转到主页
|
|
|
}
|
|
|
})
|
|
|
- } catch (error:any) {
|
|
|
+ } catch (error: any) {
|
|
|
console.log(error);
|
|
|
- ToastAndroid.show(error.response?.data?.message || '网络请求失败',2000);
|
|
|
+ ToastAndroid.show(error.response?.data?.message || '网络请求失败', 2000);
|
|
|
} finally {
|
|
|
setIsLoading(false);
|
|
|
}
|