Browse Source

fix: 修复bug

zengkunsen 4 months ago
parent
commit
7b4b306ed4

BIN
component/accountPages/.accountMainPageComponent.tsx.swp


+ 13 - 7
component/chargingPage/noChargingOngoingPageComponent.tsx

@@ -47,9 +47,15 @@ const NoChargingOngoingPageComponent = () => {
         }, []) // Add any missing dependencies here if needed
     );
 
-    const StationRow = ({ item }: { item: any }) => {
+    const StationRow = ({ item, index }: { item: any, index: number }) => {
         // const imageSource = stationImages[stationID] || require('../../assets/dummyStationPicture.png');
-        const imgObj = item.image? {uri: item.image} : require('../../assets/dummyStationPicture.png')
+        console.log('image', item.image, item.stationName);
+        let imgObj = null
+        if (item.image) {
+            imgObj = {uri: item.image}
+        } else {
+            imgObj = require('../../assets/dummyStationPicture.png')
+        }
         return (
             <Pressable
                 onPress={() => {
@@ -69,7 +75,7 @@ const NoChargingOngoingPageComponent = () => {
                 }}
             >
                 <View className="flex flex-1 flex-row w-full ">
-                    <Image style={styles.image} source={imgObj} />
+                    <Image style={styles.image} source={imgObj} key={index} />
                     <View className="flex flex-col gap-2 mt-5 mr-2">
                         <Text
                             style={{
@@ -110,17 +116,17 @@ const NoChargingOngoingPageComponent = () => {
     return (
         <SafeAreaView edges={['top', 'left', 'right']} className="flex-1 bg-white">
             <ScrollView className="flex-1 mt-8 " nestedScrollEnabled={true} showsVerticalScrollIndicator={false}>
-                <View className="">
-                    <View className="">
+                <View>
+                    <View>
                         <Text className="text-5xl pt-1 pb-6 mx-[5%]">暫無正在進行的充電</Text>
                         <View>
                             <Text className="text-lg mx-[5%] mb-6">立刻前往Crazy Charge 充電站充電吧!</Text>
 
-                            <View className="">
+                            <View>
                                 {newAvailableConnectors?.map((item, index) => (
                                     <View key={index}>
                                         <View className="border-b border-gray-200" />
-                                        <StationRow item={item} key={index} />
+                                        <StationRow item={item} key={index}/>
                                     </View>
                                 ))}
                             </View>

+ 1 - 1
service/chargeStationService.tsx

@@ -219,7 +219,7 @@ class ChargeStationService {
                             equipment.ConnectorInfos.filter((connector: any) => connector.Status === '待机').length
                         );
                     }, 0);
-                    let imgUrl = station.image ? EXPO_PUBLIC_API_IMG_URL + station.image : null;
+                    let imgUrl = station.image ? `${EXPO_PUBLIC_API_IMG_URL}${station.image}` : false;
                     return {
                         stationID: snapshotData.StationID,
                         stationName: snapshotData.StationName,