Browse Source

分离app.tsx的屏幕类型和设置

main
Your Name 3 weeks ago
parent
commit
0e1ddc385b
  1. 455
      App.tsx
  2. 341
      app/navigation/AppNavigator.tsx
  3. 77
      app/navigation/screens.ts
  4. 36
      app/navigation/types.ts
  5. 2
      app/screens/BalanceScreen.tsx
  6. 1
      app/screens/ChatScreen.tsx
  7. 4
      app/screens/ProfileScreen.tsx
  8. 3
      app/screens/previewOrder/PaymentMethod.tsx
  9. 18
      app/screens/previewOrder/PreviewAddress.tsx
  10. 2
      app/screens/previewOrder/ShippingFee.tsx
  11. 325
      app/store/burialPoint.ts
  12. 4
      app/store/previewShipping.ts
  13. 3
      app/types/react-native-md5.d.ts
  14. 1
      package.json
  15. 5
      yarn.lock

455
App.tsx

@ -1,118 +1,48 @@
import "react-native-gesture-handler";
import React from "react";
import { useEffect, useState } from "react";
import Toast from "react-native-toast-message";
import { Alert, ActivityIndicator, View } from "react-native";
import { userApi } from "./app/services/api/userApi";
import useUserStore from "./app/store/user";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { CountrySelect } from "./app/screens/CountrySelect";
import { MainApp } from "./app/screens/MainApp";
import { LoginScreen } from "./app/screens/loginList/index";
import { EmailLoginScreen } from "./app/screens/EmailLoginScreen";
import { GoogleScreen } from "./app/screens/login/Google";
import "./app/i18n";
import { TabNavigator } from "./app/navigation/TabNavigator";
import useBurialPointStore from "./app/store/burialPoint";
import { AuthProvider, useAuth } from "./app/contexts/AuthContext";
import { SearchScreen } from "./app/screens/SearchScreen";
import { SearchResultScreen } from "./app/screens/SearchResultScreen";
import { ProductDetailScreen } from "./app/screens/ProductDetailScreen";
import { BalanceScreen } from "./app/screens/BalanceScreen";
import { ShippingDetailsSection } from "./app/screens/banner/ShippingDetailsSection";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { InquiryScreen } from "./app/screens/banner/InquiryScreen";
import { Recipient } from "./app/screens/Recipient/Recipient";
import { AddRess } from "./app/screens/Recipient/Address";
import { SettingList } from "./app/screens/setting/SettingList";
import { CountrySetting } from "./app/screens/setting/CountrySetting";
import { MySetting } from "./app/services/api/setting";
import { MyAddress } from "./app/screens/setting/MyAddress";
import { CartScreen } from "./app/screens/CartScreen";
import { PaymentSuccessScreen } from "./app/screens/pay/PaySuccess";
import { MyAccount } from "./app/screens/MyAccount/myAccount";
import { ConfirmOrder } from "./app/screens/Recipient/ConfirmOrder";
import { Pay } from "./app/screens/pay/Pay";
import { Status } from "./app/screens/productStatus/Status";
import { OrderDetails } from "./app/screens/productStatus/OrderDatails";
import { TikTokScreen } from "./app/screens/banner/TikTokScreen";
import { BrowseHistoryScreen } from "./app/screens/function/BrowseHistoryScreen";
import { Collection } from "./app/screens/function/Collection";
import { AppNavigator } from "./app/navigation/AppNavigator";
import { View, ActivityIndicator } from "react-native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { MemberIntroduction } from "./app/screens/MemberScreen/MemberIntroduction";
import { CompanyScreen } from "./app/screens/MemberScreen/CompanyScreen";
import { PreviewAddress } from "./app/screens/previewOrder/PreviewAddress";
import { AddressList } from "./app/screens/address/AddressList";
import { AddAddress } from "./app/screens/address/AddAddress";
import { EditAddress } from "./app/screens/address/EditAddress";
import { PaymentMethod } from "./app/screens/previewOrder/PaymentMethod";
import { ShippingFee } from "./app/screens/previewOrder/ShippingFee";
import { PreviewOrder } from "./app/screens/previewOrder/perviewOrder";
import {ForgotPhonePassword} from "./app/screens/loginList/ForgotPhonePassword";
export type RootStackParamList = {
CountrySelect: undefined;
MainApp: undefined;
Login: undefined;
EmailLogin: undefined;
MainTabs: undefined;
Search: undefined;
SearchResult: { keyword: string };
ProductDetail: { productId: string; searchKeyword?: string };
Balance: undefined;
ShippingDetailsSection: undefined;
InquiryScreen: undefined;
Recipient: { items: { cart_item_id: number }[] };
AddRess: undefined;
SettingList: undefined;
CountrySetting: { mySetting?: MySetting };
MyAddress: undefined;
CartScreen: undefined;
PaymentSuccessScreen: undefined;
MyAccount: undefined;
Google: undefined;
ConfirmOrder: undefined;
Pay: undefined;
Status: undefined;
OrderDetails: undefined;
TikTokScreen: undefined;
BrowseHistoryScreen: undefined;
Collection: undefined;
MemberIntroduction: undefined;
CompanyScreen: undefined;
PreviewAddress: undefined;
AddressList: undefined;
AddAddress: undefined;
EditAddress: undefined;
PaymentMethod: undefined;
ShippingFee: undefined;
PreviewOrder: undefined;
ForgotPhonePassword: undefined,
};
const Stack = createNativeStackNavigator<RootStackParamList>();
import "./app/i18n";
function AppContent() {
const { setUser } = useUserStore();
const { login, logout } = useAuth();
const { logAppLaunch } = useBurialPointStore();
const [isLoading, setIsLoading] = useState(true);
const getUserInfo = async () => {
const token = await AsyncStorage.getItem("token");
if (token) {
useEffect(() => {
const initApp = async () => {
try {
const user = await userApi.getProfile();
setUser(user);
login();
const token = await AsyncStorage.getItem("token");
if (token) {
try {
const user = await userApi.getProfile();
setUser(user);
login();
} catch (error) {
console.error('Failed to get user profile:', error);
logout();
}
}
// 记录应用启动成功埋点
logAppLaunch(true);
} catch (error) {
logout();
console.error('App initialization error:', error);
// 记录应用启动失败埋点
logAppLaunch(false);
} finally {
setIsLoading(false);
}
}
setIsLoading(false);
};
};
useEffect(() => {
getUserInfo();
initApp();
}, []);
if (isLoading) {
@ -123,336 +53,7 @@ function AppContent() {
);
}
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerShown: false,
}}
>
<Stack.Screen name="CountrySelect" component={CountrySelect} />
<Stack.Screen
name="Login"
component={LoginScreen}
options={{
presentation: "modal",
animation: "slide_from_bottom",
gestureEnabled: true,
gestureDirection: "vertical",
}}
/>
<Stack.Screen
name="MainTabs"
component={TabNavigator}
options={{
gestureEnabled: false,
}}
/>
<Stack.Screen
name="EmailLogin"
component={EmailLoginScreen}
options={{
presentation: "modal",
animation: "slide_from_bottom",
gestureEnabled: true,
gestureDirection: "vertical",
}}
/>
<Stack.Screen
name="Search"
component={SearchScreen}
options={{
presentation: "fullScreenModal",
animation: "fade",
animationDuration: 200,
gestureEnabled: true,
gestureDirection: "vertical",
contentStyle: { backgroundColor: "#ffffff" },
}}
/>
<Stack.Screen
name="SearchResult"
component={SearchResultScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="ProductDetail"
component={ProductDetailScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Balance"
component={BalanceScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="ShippingDetailsSection"
component={ShippingDetailsSection}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="InquiryScreen"
component={InquiryScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Recipient"
component={Recipient}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="AddRess"
component={AddRess}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="SettingList"
component={SettingList}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="CountrySetting"
component={CountrySetting}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="MyAddress"
component={MyAddress}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="CartScreen"
component={CartScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="PaymentSuccessScreen"
component={PaymentSuccessScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="MyAccount"
component={MyAccount}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Google"
component={GoogleScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="ConfirmOrder"
component={ConfirmOrder}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Pay"
component={Pay}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Status"
component={Status}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="OrderDetails"
component={OrderDetails}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="TikTokScreen"
component={TikTokScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="BrowseHistoryScreen"
component={BrowseHistoryScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Collection"
component={Collection}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="MemberIntroduction"
component={MemberIntroduction}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="CompanyScreen"
component={CompanyScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="PreviewAddress"
component={PreviewAddress}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="AddressList"
component={AddressList}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="AddAddress"
component={AddAddress}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="EditAddress"
component={EditAddress}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="PaymentMethod"
component={PaymentMethod}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="ShippingFee"
component={ShippingFee}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="PreviewOrder"
component={PreviewOrder}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="ForgotPhonePassword"
component={ForgotPhonePassword}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
</Stack.Navigator>
<Toast />
</NavigationContainer>
);
return <AppNavigator />;
}
export default function App() {

341
app/navigation/AppNavigator.tsx

@ -0,0 +1,341 @@
import React from 'react';
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { RootStackParamList } from './types';
import * as Screens from './screens';
import Toast from "react-native-toast-message";
const Stack = createNativeStackNavigator<RootStackParamList>();
export const AppNavigator = () => {
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerShown: false,
}}
>
<Stack.Screen name="CountrySelect" component={Screens.CountrySelect} />
<Stack.Screen
name="Login"
component={Screens.LoginScreen}
options={{
presentation: "modal",
animation: "slide_from_bottom",
gestureEnabled: true,
gestureDirection: "vertical",
}}
/>
<Stack.Screen
name="MainTabs"
component={Screens.TabNavigator}
options={{
gestureEnabled: false,
}}
/>
<Stack.Screen
name="EmailLogin"
component={Screens.EmailLoginScreen}
options={{
presentation: "modal",
animation: "slide_from_bottom",
gestureEnabled: true,
gestureDirection: "vertical",
}}
/>
<Stack.Screen
name="Search"
component={Screens.SearchScreen}
options={{
presentation: "fullScreenModal",
animation: "fade",
animationDuration: 200,
gestureEnabled: true,
gestureDirection: "vertical",
contentStyle: { backgroundColor: "#ffffff" },
}}
/>
<Stack.Screen
name="SearchResult"
component={Screens.SearchResultScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="ProductDetail"
component={Screens.ProductDetailScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Balance"
component={Screens.BalanceScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="ShippingDetailsSection"
component={Screens.ShippingDetailsSection}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="InquiryScreen"
component={Screens.InquiryScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Recipient"
component={Screens.Recipient}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="AddRess"
component={Screens.AddRess}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="SettingList"
component={Screens.SettingList}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="CountrySetting"
component={Screens.CountrySetting}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="MyAddress"
component={Screens.MyAddress}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="CartScreen"
component={Screens.CartScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="PaymentSuccessScreen"
component={Screens.PaymentSuccessScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="MyAccount"
component={Screens.MyAccount}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Google"
component={Screens.GoogleScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="ConfirmOrder"
component={Screens.ConfirmOrder}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Pay"
component={Screens.Pay}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Status"
component={Screens.Status}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="OrderDetails"
component={Screens.OrderDetails}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="TikTokScreen"
component={Screens.TikTokScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="BrowseHistoryScreen"
component={Screens.BrowseHistoryScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="Collection"
component={Screens.Collection}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="MemberIntroduction"
component={Screens.MemberIntroduction}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="CompanyScreen"
component={Screens.CompanyScreen}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="PreviewAddress"
component={Screens.PreviewAddress}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="AddressList"
component={Screens.AddressList}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="AddAddress"
component={Screens.AddAddress}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="EditAddress"
component={Screens.EditAddress}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="PaymentMethod"
component={Screens.PaymentMethod}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="ShippingFee"
component={Screens.ShippingFee}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="PreviewOrder"
component={Screens.PreviewOrder}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="ForgotPhonePassword"
component={Screens.ForgotPhonePassword}
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
</Stack.Navigator>
<Toast />
</NavigationContainer>
);
};

77
app/navigation/screens.ts

@ -0,0 +1,77 @@
import { CountrySelect } from "../screens/CountrySelect";
import { MainApp } from "../screens/MainApp";
import { LoginScreen } from "../screens/loginList/index";
import { EmailLoginScreen } from "../screens/EmailLoginScreen";
import { TabNavigator } from "./TabNavigator";
import { SearchScreen } from "../screens/SearchScreen";
import { SearchResultScreen } from "../screens/SearchResultScreen";
import { ProductDetailScreen } from "../screens/ProductDetailScreen";
import { BalanceScreen } from "../screens/BalanceScreen";
import { ShippingDetailsSection } from "../screens/banner/ShippingDetailsSection";
import { InquiryScreen } from "../screens/banner/InquiryScreen";
import { Recipient } from "../screens/Recipient/Recipient";
import { AddRess } from "../screens/Recipient/Address";
import { SettingList } from "../screens/setting/SettingList";
import { CountrySetting } from "../screens/setting/CountrySetting";
import { MyAddress } from "../screens/setting/MyAddress";
import { CartScreen } from "../screens/CartScreen";
import { PaymentSuccessScreen } from "../screens/pay/PaySuccess";
import { MyAccount } from "../screens/MyAccount/myAccount";
import { GoogleScreen } from "../screens/login/Google";
import { ConfirmOrder } from "../screens/Recipient/ConfirmOrder";
import { Pay } from "../screens/pay/Pay";
import { Status } from "../screens/productStatus/Status";
import { OrderDetails } from "../screens/productStatus/OrderDatails";
import { TikTokScreen } from "../screens/banner/TikTokScreen";
import { BrowseHistoryScreen } from "../screens/function/BrowseHistoryScreen";
import { Collection } from "../screens/function/Collection";
import { MemberIntroduction } from "../screens/MemberScreen/MemberIntroduction";
import { CompanyScreen } from "../screens/MemberScreen/CompanyScreen";
import { PreviewAddress } from "../screens/previewOrder/PreviewAddress";
import { AddressList } from "../screens/address/AddressList";
import { AddAddress } from "../screens/address/AddAddress";
import { EditAddress } from "../screens/address/EditAddress";
import { PaymentMethod } from "../screens/previewOrder/PaymentMethod";
import { ShippingFee } from "../screens/previewOrder/ShippingFee";
import { PreviewOrder } from "../screens/previewOrder/perviewOrder";
import { ForgotPhonePassword } from "../screens/loginList/ForgotPhonePassword";
export {
CountrySelect,
MainApp,
LoginScreen,
EmailLoginScreen,
TabNavigator,
SearchScreen,
SearchResultScreen,
ProductDetailScreen,
BalanceScreen,
ShippingDetailsSection,
InquiryScreen,
Recipient,
AddRess,
SettingList,
CountrySetting,
MyAddress,
CartScreen,
PaymentSuccessScreen,
MyAccount,
GoogleScreen,
ConfirmOrder,
Pay,
Status,
OrderDetails,
TikTokScreen,
BrowseHistoryScreen,
Collection,
MemberIntroduction,
CompanyScreen,
PreviewAddress,
AddressList,
AddAddress,
EditAddress,
PaymentMethod,
ShippingFee,
PreviewOrder,
ForgotPhonePassword
};

36
app/navigation/types.ts

@ -1,15 +1,41 @@
import { MySetting } from '../services/api/setting';
export type RootStackParamList = {
Login: undefined;
EmailLogin: undefined;
CountrySelect: undefined;
MainApp: undefined;
Login: undefined;
EmailLogin: undefined;
MainTabs: undefined;
Search: undefined;
SearchResult: { keyword: string };
ProductDetail: { productId: string; searchKeyword?: string };
Balance: undefined;
Recipient: undefined;
ShippingDetailsSection: undefined;
InquiryScreen: undefined;
Recipient: { items: { cart_item_id: number }[] };
AddRess: undefined;
SettingList: undefined;
CountrySetting: { mySetting?: MySetting | undefined };
CountrySetting: { mySetting?: MySetting };
MyAddress: undefined;
MyAccount:undefined;
CartScreen: undefined;
PaymentSuccessScreen: undefined;
MyAccount: undefined;
Google: undefined;
ConfirmOrder: undefined;
Pay: undefined;
Status: undefined;
OrderDetails: undefined;
TikTokScreen: undefined;
BrowseHistoryScreen: undefined;
Collection: undefined;
MemberIntroduction: undefined;
CompanyScreen: undefined;
PreviewAddress: undefined;
AddressList: undefined;
AddAddress: undefined;
EditAddress: undefined;
PaymentMethod: undefined;
ShippingFee: undefined;
PreviewOrder: undefined;
ForgotPhonePassword: undefined;
};

2
app/screens/BalanceScreen.tsx

@ -5,7 +5,7 @@ import fontSize from '../utils/fontsizeUtils';
import widthUtils from '../utils/widthUtils';
import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { RootStackParamList } from '../../App';
import { RootStackParamList } from '../navigation/types';
import RechargeScreen from './RechargeScreen';
import BackIcon from '../components/BackIcon';

1
app/screens/ChatScreen.tsx

@ -16,7 +16,6 @@ import {
} from "react-native";
import { useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import { RootStackParamList } from "../../App";
import { useTranslation } from 'react-i18next';

4
app/screens/ProfileScreen.tsx

@ -452,11 +452,13 @@ const styles = StyleSheet.create({
},
gradientCardContainer: {
position: "absolute",
bottom: -10,
bottom: 0,
left: 19,
right: 19,
backgroundColor: "#3A3128",
borderRadius: 10,
marginBottom: Platform.OS === 'ios' ? -18 : -15,
zIndex: 1,
},
promoCardContainer2: {
flexDirection: "column",

3
app/screens/previewOrder/PaymentMethod.tsx

@ -8,7 +8,6 @@ import {
Image,
Alert,
ActivityIndicator,
Platform,
StatusBar,
SafeAreaView
} from "react-native";
@ -275,7 +274,7 @@ export const PaymentMethod = () => {
const getPaymentMethods = async () => {
try {
const response = await payApi.getCountryPaymentMethods();
console.log(response);
setPaymentMethods(response);
// 设置默认支付方式选项
setTabs([

18
app/screens/previewOrder/PreviewAddress.tsx

@ -13,7 +13,8 @@ import {
FlatList,
Dimensions,
StatusBar,
SafeAreaView
SafeAreaView,
ScrollView
} from "react-native";
import { useState } from "react";
@ -207,7 +208,6 @@ export const PreviewAddress = () => {
const handleSubmit = async () => {
if (validateForm()) {
console.log(defaultAddress);
setOrderData({
...orderData,
address_id: defaultAddress?.address_id,
@ -227,8 +227,11 @@ export const PreviewAddress = () => {
return (
<SafeAreaView style={[styles.safeArea]}>
<StatusBar barStyle="dark-content" backgroundColor="#fff" />
<View style={styles.safeAreaContent}>
<View style={styles.container}>
<KeyboardAvoidingView
behavior={Platform.OS === "ios" ? "padding" : "height"}
style={styles.safeAreaContent}
>
<ScrollView style={styles.container} contentContainerStyle={styles.scrollContainer}>
{loading ? (
<View style={styles.loadingContainer}>
<ActivityIndicator size="large" color="#f77f3a" />
@ -500,8 +503,8 @@ export const PreviewAddress = () => {
</View>
</View>
</Modal>
</View>
</View>
</ScrollView>
</KeyboardAvoidingView>
</SafeAreaView>
);
};
@ -520,7 +523,8 @@ const styles = StyleSheet.create({
backgroundColor: '#fff',
},
scrollContainer: {
width: "100%",
flexGrow: 1,
paddingBottom: 20,
},
recipientFormContainer3: {
flex: 1,

2
app/screens/previewOrder/ShippingFee.tsx

@ -83,6 +83,8 @@ export const ShippingFee = () => {
useEffect(() => {
if (state.freightForwarderAddress) {
console.log(state.freightForwarderAddress.other_addresses);
setFreightForwarderAddress(state.freightForwarderAddress);
// 设置默认选择第一项
if (

325
app/store/burialPoint.ts

@ -0,0 +1,325 @@
import { Platform } from "react-native";
import { create } from 'zustand';
import useUserStore from "./user";
// 定义事件属性类型为灵活的记录类型
type EventProperty = Record<string, any>;
// 定义事件类型
type BurialEvent = {
event_name: string;
page_name: string | null;
referre_page: string | null; // 注意这里字段名已更正为referre_page
event_properties: EventProperty[];
}
// 定义产品属性类型
type ProductProperty = {
offer_id: number;
category_id: number;
price: number;
sku_id: number;
currency: string;
product_name: string;
timestamp: string;
product_img: string;
}
// 定义搜索属性类型
type SearchProperty = {
key_word: string;
timestamp: string;
}
// 定义地址信息属性类型
type AddressProperty = {
last_name: string;
first_name: string;
country: string;
phone_number: number;
whatsApp_number: number;
timestamp: string;
}
// 定义物流信息属性类型
type ShippingProperty = {
shipping_method: number;
shipping_price_outside: number;
shipping_price_within: number;
currency: string;
forwarder_name: string;
country_city: string;
timestamp: string;
product_list_text?: string;
}
// 定义支付方式属性类型
type PaymentProperty = {
pay_method: string;
offline_payment: number;
all_price: number;
currency: string;
pay_product?: string;
shipping_method: number;
shipping_price_outside: number;
shipping_price_within: number;
timestamp: string;
}
// 定义支付结账属性类型
type CheckoutProperty = {
is_suc: number;
all_price: number;
currency: string;
shipping_method: number;
shipping_price_outside: number;
shipping_price_within: number;
pay_product?: string;
timestamp: string;
}
// 生成唯一ID函数,替代md5
const generateUniqueId = () => {
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
};
// 创建唯一的session_id
const SESSION_ID = generateUniqueId();
// 定义埋点store的状态
type BurialPointState = {
device_id: string;
version: string;
session_id: string;
event_list: BurialEvent[];
addEvent: (event: BurialEvent) => void;
logAppLaunch: (isSuccess?: boolean) => void;
logLogin: (isSuccess: boolean, loginMethod: string) => void;
logRegister: (isSuccess: boolean, registerMethod: string) => void;
logViewProduct: (productInfo: ProductProperty, fromPage?: string) => void;
logSearch: (keyword: string, fromPage?: string) => void;
logAddressInfo: (addressInfo: Omit<AddressProperty, "timestamp">, fromPage?: string) => void;
logShippingConfirm: (shippingInfo: Omit<ShippingProperty, "timestamp">, fromPage?: string) => void;
logPaymentConfirm: (paymentInfo: Omit<PaymentProperty, "timestamp">, fromPage?: string) => void;
logPreviewOrder: (fromPage?: string) => void;
logCheckout: (checkoutInfo: Omit<CheckoutProperty, "timestamp">, fromPage?: string) => void;
clearData: () => void;
}
// 获取当前格式化的时间字符串 YYYY-MM-DD HH:MM:SS
const getCurrentFormattedTime = (): string => {
return new Date().toISOString().replace('T', ' ').substr(0, 19);
};
// 创建埋点store
const useBurialPointStore = create<BurialPointState>((set, get) => ({
device_id: Platform.OS,
version: generateUniqueId(),
session_id: SESSION_ID,
event_list: [],
// 添加事件
addEvent: (event: BurialEvent) => {
set((state) => {
const newEventList = [...state.event_list, event];
// 检查是否需要清理数据
if (newEventList.length >= 10) {
// 这里可以在清理前添加发送数据到服务器的逻辑
console.log('Data cleared, event count:', newEventList.length);
return { event_list: [] };
}
return { event_list: newEventList };
});
},
// 记录应用启动埋点
logAppLaunch: (isSuccess = true) => {
const appLaunchEvent: BurialEvent = {
event_name: "app_launch",
page_name: null,
referre_page: null,
event_properties: [
{
is_open: isSuccess ? 1 : 0, // 1表示成功,0表示失败
timestamp: getCurrentFormattedTime()
}
]
};
get().addEvent(appLaunchEvent);
},
// 记录登录事件埋点
logLogin: (isSuccess = true, loginMethod = "phone") => {
const loginEvent: BurialEvent = {
event_name: "login",
page_name: null,
referre_page: null,
event_properties: [
{
is_login: isSuccess ? 1 : 0, // 1表示成功,0表示失败
login_method: loginMethod, // 登录方式
timestamp: getCurrentFormattedTime()
}
]
};
get().addEvent(loginEvent);
},
// 记录注册事件埋点
logRegister: (isSuccess = true, registerMethod = "phone") => {
const registerEvent: BurialEvent = {
event_name: "register",
page_name: null,
referre_page: null,
event_properties: [
{
is_register: isSuccess ? 1 : 0, // 1表示成功,0表示失败
register_method: registerMethod, // 注册方式
timestamp: getCurrentFormattedTime()
}
]
};
get().addEvent(registerEvent);
},
// 记录浏览商品事件埋点
logViewProduct: (productInfo: ProductProperty, fromPage = "home") => {
const viewProductEvent: BurialEvent = {
event_name: "view-product",
page_name: "product",
referre_page: fromPage,
event_properties: [productInfo]
};
get().addEvent(viewProductEvent);
},
// 记录搜索事件埋点
logSearch: (keyword: string, fromPage = "home") => {
const searchEvent: BurialEvent = {
event_name: "search",
page_name: "search",
referre_page: fromPage,
event_properties: [
{
key_word: keyword,
timestamp: getCurrentFormattedTime()
}
]
};
get().addEvent(searchEvent);
},
// 记录填写地址信息事件埋点
logAddressInfo: (addressInfo: Omit<AddressProperty, "timestamp">, fromPage = "cart") => {
const addressEvent: BurialEvent = {
event_name: "fill_information",
page_name: "address",
referre_page: fromPage,
event_properties: [
{
...addressInfo,
timestamp: getCurrentFormattedTime()
}
]
};
get().addEvent(addressEvent);
},
// 记录物流信息确认事件埋点
logShippingConfirm: (shippingInfo: Omit<ShippingProperty, "timestamp">, fromPage = "address") => {
const shippingEvent: BurialEvent = {
event_name: "shipping_confirm",
page_name: "shipping",
referre_page: fromPage,
event_properties: [
{
...shippingInfo,
timestamp: getCurrentFormattedTime()
}
]
};
get().addEvent(shippingEvent);
},
// 记录支付方式确认事件埋点
logPaymentConfirm: (paymentInfo: Omit<PaymentProperty, "timestamp">, fromPage = "shipping") => {
const paymentEvent: BurialEvent = {
event_name: "payment_confirm",
page_name: "pay_method",
referre_page: fromPage,
event_properties: [
{
...paymentInfo,
timestamp: getCurrentFormattedTime()
}
]
};
get().addEvent(paymentEvent);
},
// 记录预览订单事件埋点
logPreviewOrder: (fromPage = "pay_method") => {
const previewEvent: BurialEvent = {
event_name: "preview_order",
page_name: "preview",
referre_page: fromPage,
event_properties: [
{
timestamp: getCurrentFormattedTime()
}
]
};
get().addEvent(previewEvent);
},
// 记录支付结账事件埋点
logCheckout: (checkoutInfo: Omit<CheckoutProperty, "timestamp">, fromPage = "perview") => {
const checkoutEvent: BurialEvent = {
event_name: "check_out",
page_name: "pay",
referre_page: fromPage,
event_properties: [
{
...checkoutInfo,
timestamp: getCurrentFormattedTime()
}
]
};
get().addEvent(checkoutEvent);
},
// 清空数据
clearData: () => {
// 这里可以添加发送数据到服务器的逻辑
console.log('Data cleared, event count:', get().event_list.length);
set({ event_list: [] });
}
}));
// 获取埋点数据,包括从userStore获取的user_id
export const getBurialPointData = () => {
const burialState = useBurialPointStore.getState();
const user = useUserStore.getState().user;
return {
user_id: user?.user_id || null,
device_id: burialState.device_id,
version: burialState.version,
session_id: burialState.session_id,
event_list: burialState.event_list
};
};
export default useBurialPointStore;

4
app/store/previewShipping.ts

@ -40,7 +40,9 @@ const usePreviewShippingStore = create<PreviewShippingStore>((set) => ({
try {
const response = await ordersApi.freightForwarderAddress(transportMode);
response.other_addresses.unshift(response.current_country_address);
if (response.current_country_address != null){
response.other_addresses.unshift(response.current_country_address);
}
set((state) => ({
state: {
...state.state,

3
app/types/react-native-md5.d.ts vendored

@ -0,0 +1,3 @@
declare module 'react-native-md5' {
export function md5(str: string): string;
}

1
package.json

@ -46,6 +46,7 @@
"react-native-image-zoom-viewer": "^3.0.1",
"react-native-linear-gradient": "^2.8.3",
"react-native-localize": "^3.4.1",
"react-native-md5": "^1.0.0",
"react-native-pager-view": "^6.7.0",
"react-native-paper": "^5.13.3",
"react-native-reanimated": "~3.16.1",

5
yarn.lock

@ -9914,6 +9914,11 @@ react-native-localize@^3.4.1:
resolved "https://registry.npmmirror.com/react-native-localize/-/react-native-localize-3.4.1.tgz#df07c13231b4e8cc949e68513b124105f861229c"
integrity sha512-NJqJGBUpHtD/MpLCCkrNiqNZ+xFwbHCivxaoN1Oeb8tBAiZr/IqgP3E+MgnqmmdTMOJ33llUfiW3EM6pEIb33w==
react-native-md5@^1.0.0:
version "1.0.0"
resolved "https://registry.npmmirror.com/react-native-md5/-/react-native-md5-1.0.0.tgz#2320be24d674938ae5ef4f492698edbbfa0e0205"
integrity sha512-+QGVe0ShxWpcgr1pNKc2XGv/EbDpOdpvSQVkIPSGU+wLtlgbz5eDECgIZt+1y8JdNHfofGyQJk4FTTDu3rAX2w==
react-native-pager-view@^6.7.0:
version "6.7.1"
resolved "https://registry.npmmirror.com/react-native-pager-view/-/react-native-pager-view-6.7.1.tgz#60d52dedbcc92ee7037a13287ebeed5f74e49df7"

Loading…
Cancel
Save