添加测试页面

This commit is contained in:
李宇奇 2025-09-10 22:55:40 +08:00
parent 484b9c332b
commit c12750ee9a
8 changed files with 289 additions and 35 deletions

View File

@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MainApplication"

View File

@ -4,6 +4,17 @@ import type {ApiResponse} from '../types';
export class WmsApiClient {
private static http = HttpClient.getInstance();
static async test(timeOut: number = 5000) : Promise<ApiResponse<any>> {
const response = await this.http.get(
'/wms/test/hello',
{
timeout: timeOut,
}
);
console.log("yuqili {}", JSON.stringify(response));
return response.data.data;
}
/**
*
*/

View File

@ -1,5 +1,5 @@
export const ENV = {
API_URL: __DEV__ ? 'http://dev-api.example.com' : 'https://api.example.com',
API_URL: 'http://10.0.2.2:12315',
APP_NAME: 'PdaRnTemplate',
VERSION: '1.0.0',
};

View File

@ -5,6 +5,7 @@ import {LoginScreen} from '../screens/auth/LoginScreen';
import { HomeScreen } from '../screens/home/HomeScreen';
import { StockInEmpty } from '../screens/stockIn/StockInEmpty';
import { StockInManual } from '../screens/stockIn/StockInManual';
import {Test} from '../screens/test/TestPage';
import { RootStackParamList } from './types';
import { Platform } from 'react-native';
import { screensEnabled, enableScreens } from 'react-native-screens';
@ -35,6 +36,13 @@ const Navigation = () => {
animation: 'none',
}}
/>
<Stack.Screen
name="Test"
component={Test}
options={{
animation: 'none',
}}
/>
<Stack.Screen
name="Home"
component={HomeScreen}

View File

@ -1,6 +1,7 @@
import {NativeStackScreenProps} from '@react-navigation/native-stack';
export type RootStackParamList = {
Test: undefined;
Login: undefined;
Home: undefined;
StockInEmpty: undefined;

View File

@ -48,6 +48,7 @@ export const HomeScreen: React.FC = () => {
}, []);
const menuItems: MenuItem[] = [
{title: 'test', icon: 'local-shipping', route: 'Test'},
{title: '空载具入库', icon: 'local-shipping', route: 'StockInEmpty'},
{title: '手动码盘入库', icon: 'inventory', route: 'StockInManual'},
];

View File

@ -72,8 +72,7 @@ export const StockInEmpty: React.FC = () => {
} catch (error) {
DialogUtils.showErrorMessage(
'请求发生错误',
`请求服务器发生错误:${
error instanceof Error ? error.message : String(error)
`请求服务器发生错误:${error instanceof Error ? error.message : String(error)
}`,
'我知道了',
);

View File

@ -0,0 +1,233 @@
import { WmsApiClient } from '../../api/wmsApi'
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { useNavigation } from '@react-navigation/native';
import { RootStackParamList } from '../../navigation/types';
import { useState } from 'react';
import { DialogUtils } from '../../utils';
import {
View,
Text,
StyleSheet,
TextInput,
TouchableOpacity,
SafeAreaView,
ActivityIndicator,
} from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import Icon from 'react-native-vector-icons/MaterialIcons';
import { useTheme } from '../../contexts/ThemeContext';
import Svg, { Path } from 'react-native-svg';
type TestScreenNavigationProp = NativeStackNavigationProp<
RootStackParamList,
'Test'
>;
export const Test: React.FC = () => {
const navigation = useNavigation<TestScreenNavigationProp>();
const theme = useTheme();
const [showStr, setStr] = useState('');
const test = async () => {
try {
const response = await WmsApiClient.test();
DialogUtils.showSuccessMessage('成功', "success", "我知道了",);
setStr(response.data);
return;
} catch (error) {
DialogUtils.showErrorMessage(
'请求发生错误',
`请求服务器发生错误:${JSON.stringify(error)
}`,
'我知道了',
);
}
}
return (
<SafeAreaView
style={[styles.container, { backgroundColor: theme.colors.background }]} >
<LinearGradient
colors={theme.colors.gradients.primary}
start={{ x: 0, y: 0 }}
end={{ x: 1, y: 0 }}
style={styles.header}>
<TouchableOpacity
onPress={() => navigation.goBack()}
style={styles.backButton}>
<Icon name="arrow-back" size={24} color={theme.colors.background} />
</TouchableOpacity>
<Text style={[styles.headerTitle, { color: theme.colors.background }]}>
</Text>
<View style={styles.headerRight} />
</LinearGradient>
<View style={styles.waveContainer}>
<Svg
height="100%"
width="100%"
viewBox="0 0 1440 320"
style={styles.waveSvg}
preserveAspectRatio="none">
<Path
fill={`${theme.colors.aqua}30`}
d="M0,96L48,112C96,128,192,160,288,186.7C384,213,480,235,576,213.3C672,192,768,128,864,128C960,128,1056,192,1152,213.3C1248,235,1344,213,1392,202.7L1440,192L1440,0L1392,0C1344,0,1248,0,1152,0C1056,0,960,0,864,0C768,0,672,0,576,0C480,0,384,0,288,0C192,0,96,0,48,0L0,0Z"
/>
</Svg>
</View>
<View
style={[
styles.content,
{ backgroundColor: theme.colors.backgroundGray },
]}>
<Text>
{showStr}
</Text>
<LinearGradient
colors={theme.colors.gradients.button}
start={{ x: 0, y: 0 }}
end={{ x: 1, y: 0 }}
style={styles.submitButton}>
<TouchableOpacity
style={styles.submitButtonContent}
onPress={test}>
{
<>
<Icon
name="save"
size={24}
color={theme.colors.background}
style={styles.submitIcon}
/>
<Text
style={[
styles.submitButtonText,
{ color: theme.colors.background },
]}>
Click Me
</Text>
</>
}
</TouchableOpacity>
</LinearGradient>
</View>
</SafeAreaView>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
header: {
height: 56,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: 16,
elevation: 4,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.2,
shadowRadius: 2,
},
waveContainer: {
height: 100,
backgroundColor: 'transparent',
position: 'absolute',
top: 56,
left: 0,
right: 0,
zIndex: -1,
},
waveSvg: {
position: 'absolute',
top: 0,
},
backButton: {
padding: 8,
},
headerTitle: {
fontSize: 18,
fontWeight: '600',
},
headerRight: {
width: 40,
},
content: {
flex: 1,
padding: 20,
},
infoSection: {
flexDirection: 'row',
alignItems: 'center',
padding: 16,
borderRadius: 8,
marginBottom: 24,
},
infoText: {
marginLeft: 12,
fontSize: 14,
flex: 1,
},
inputContainer: {
marginBottom: 24,
},
inputLabel: {
fontSize: 16,
marginBottom: 8,
fontWeight: '500',
},
required: {
color: '#ff4d4f',
},
inputWrapper: {
flexDirection: 'row',
alignItems: 'center',
borderWidth: 1,
borderRadius: 8,
height: 48,
paddingHorizontal: 12,
},
inputIcon: {
marginRight: 8,
},
input: {
flex: 1,
fontSize: 16,
padding: 0,
height: '100%',
},
clearButton: {
padding: 4,
},
submitButton: {
height: 48,
borderRadius: 24,
marginTop: 32,
elevation: 2,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 2,
},
submitButtonContent: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
},
submitButtonDisabled: {
opacity: 0.6,
},
submitIcon: {
marginRight: 8,
},
submitButtonText: {
fontSize: 16,
fontWeight: '600',
},
});