From c12750ee9acc269cdf0abcb85d51ffa944896de6 Mon Sep 17 00:00:00 2001 From: liyuqi Date: Wed, 10 Sep 2025 22:55:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 3 +- src/api/wmsApi.ts | 11 ++ src/constants/env.ts | 2 +- src/navigation/index.tsx | 26 ++- src/navigation/types.ts | 1 + src/screens/home/HomeScreen.tsx | 1 + src/screens/stockIn/StockInEmpty.tsx | 47 +++-- src/screens/test/TestPage.tsx | 233 +++++++++++++++++++++++ 8 files changed, 289 insertions(+), 35 deletions(-) create mode 100644 src/screens/test/TestPage.tsx diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index e189252..e8e80f4 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ - + + > { + const response = await this.http.get( + '/wms/test/hello', + { + timeout: timeOut, + } + ); + console.log("yuqili {}", JSON.stringify(response)); + return response.data.data; + } + /** * 空载具入库 */ diff --git a/src/constants/env.ts b/src/constants/env.ts index ce77cf7..e953718 100644 --- a/src/constants/env.ts +++ b/src/constants/env.ts @@ -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', }; diff --git a/src/navigation/index.tsx b/src/navigation/index.tsx index c7b6a67..6e2d92d 100644 --- a/src/navigation/index.tsx +++ b/src/navigation/index.tsx @@ -1,13 +1,14 @@ import React from 'react'; -import {NavigationContainer} from '@react-navigation/native'; -import {createNativeStackNavigator} from '@react-navigation/native-stack'; -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 {RootStackParamList} from './types'; -import {Platform} from 'react-native'; -import {screensEnabled, enableScreens} from 'react-native-screens'; +import { NavigationContainer } from '@react-navigation/native'; +import { createNativeStackNavigator } from '@react-navigation/native-stack'; +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'; // 确保 react-native-screens 在导航之前初始化 if (Platform.OS === 'android' && !screensEnabled()) { @@ -35,6 +36,13 @@ const Navigation = () => { animation: 'none', }} /> + { }, []); const menuItems: MenuItem[] = [ + {title: 'test', icon: 'local-shipping', route: 'Test'}, {title: '空载具入库', icon: 'local-shipping', route: 'StockInEmpty'}, {title: '手动码盘入库', icon: 'inventory', route: 'StockInManual'}, ]; diff --git a/src/screens/stockIn/StockInEmpty.tsx b/src/screens/stockIn/StockInEmpty.tsx index 1a2d98a..9122e80 100644 --- a/src/screens/stockIn/StockInEmpty.tsx +++ b/src/screens/stockIn/StockInEmpty.tsx @@ -1,4 +1,4 @@ -import React, {useState} from 'react'; +import React, { useState } from 'react'; import { View, Text, @@ -8,15 +8,15 @@ import { SafeAreaView, ActivityIndicator, } from 'react-native'; -import {NativeStackNavigationProp} from '@react-navigation/native-stack'; -import {useNavigation} from '@react-navigation/native'; -import {RootStackParamList} from '../../navigation/types'; -import {useTheme} from '../../contexts/ThemeContext'; +import { NativeStackNavigationProp } from '@react-navigation/native-stack'; +import { useNavigation } from '@react-navigation/native'; +import { RootStackParamList } from '../../navigation/types'; +import { useTheme } from '../../contexts/ThemeContext'; import Icon from 'react-native-vector-icons/MaterialIcons'; import LinearGradient from 'react-native-linear-gradient'; -import Svg, {Path} from 'react-native-svg'; +import Svg, { Path } from 'react-native-svg'; import axios from 'axios'; -import {DialogUtils} from '../../utils'; +import { DialogUtils } from '../../utils'; interface StockInEmptyResponse { code: number; @@ -49,7 +49,7 @@ export const StockInEmpty: React.FC = () => { setLoading(true); const response = await axios.post( '/api/vehicle/empty-in', - {vehicleNo: vehicleNo.trim()}, + { vehicleNo: vehicleNo.trim() }, ); if (response.status !== 200) { @@ -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) }`, '我知道了', ); @@ -84,19 +83,19 @@ export const StockInEmpty: React.FC = () => { return ( + style={[styles.container, { backgroundColor: theme.colors.background }]}> {/* 头部导航栏 */} navigation.goBack()} style={styles.backButton}> - + 空载具入库 @@ -121,23 +120,23 @@ export const StockInEmpty: React.FC = () => { {/* 说明文字 */} - + 请扫描或输入载具号进行空载具入库操作 {/* 载具号输入框 */} - + 载具号 * { style={styles.inputIcon} /> { {/* 提交按钮 */} { 确认入库 @@ -220,7 +219,7 @@ const styles = StyleSheet.create({ paddingHorizontal: 16, elevation: 4, shadowColor: '#000', - shadowOffset: {width: 0, height: 2}, + shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.2, shadowRadius: 2, }, @@ -300,7 +299,7 @@ const styles = StyleSheet.create({ marginTop: 32, elevation: 2, shadowColor: '#000', - shadowOffset: {width: 0, height: 2}, + shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 2, }, diff --git a/src/screens/test/TestPage.tsx b/src/screens/test/TestPage.tsx new file mode 100644 index 0000000..1c002b3 --- /dev/null +++ b/src/screens/test/TestPage.tsx @@ -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(); + 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 ( + + + navigation.goBack()} + style={styles.backButton}> + + + + 测试页面 + + + + + + + + + + + + + {showStr} + + + + + { + <> + + + Click Me + + + } + + + + + ) +} + +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', + }, +}); \ No newline at end of file