فهرست منبع

debug: 仓库详情页添加调试日志和错误处理

zbb 1 ماه پیش
والد
کامیت
ac19edf0be
3فایلهای تغییر یافته به همراه28 افزوده شده و 7 حذف شده
  1. 1 1
      app.json
  2. 23 5
      app/cloud-warehouse/detail.tsx
  3. 4 1
      app/cloud-warehouse/index.tsx

+ 1 - 1
app.json

@@ -12,7 +12,7 @@
       "supportsTablet": false,
       "bundleIdentifier": "com.asios",
       "appleTeamId": "Y9ZVX3FRX6",
-      "buildNumber": "26",
+      "buildNumber": "27",
       "infoPlist": {
         "CFBundleDisplayName": "艾斯潮盒",
         "ITSAppUsesNonExemptEncryption": false,

+ 23 - 5
app/cloud-warehouse/detail.tsx

@@ -42,22 +42,37 @@ const FROM_TYPE_MAP: Record<string, string> = {
 };
 
 export default function StoreDetailScreen() {
-  const { id } = useLocalSearchParams<{ id: string }>();
+  const params = useLocalSearchParams<{ id: string }>();
+  const id = params?.id;
   const router = useRouter();
   const insets = useSafeAreaInsets();
 
   const [loading, setLoading] = useState(true);
   const [item, setItem] = useState<any>(null);
   const [converting, setConverting] = useState(false);
+  const [error, setError] = useState<string | null>(null);
+
+  console.log('[仓库详情] 页面加载, params:', JSON.stringify(params), 'id:', id);
 
   const loadData = useCallback(async () => {
-    if (!id) return;
+    console.log('[仓库详情] loadData 开始, id:', id);
+    if (!id) {
+      setError('未获取到商品ID');
+      setLoading(false);
+      return;
+    }
     setLoading(true);
+    setError(null);
     try {
       const data = await getLuckDetail(id);
+      console.log('[仓库详情] getLuckDetail 返回:', data ? '有数据' : 'null');
       setItem(data);
-    } catch (e) {
-      console.error("加载详情失败:", e);
+      if (!data) {
+        setError('商品数据为空');
+      }
+    } catch (e: any) {
+      console.error("[仓库详情] 加载失败:", e);
+      setError(`加载失败: ${e?.message || '未知错误'}`);
     }
     setLoading(false);
   }, [id]);
@@ -111,7 +126,10 @@ export default function StoreDetailScreen() {
   if (!item) {
     return (
       <View style={styles.loadingBox}>
-        <Text style={{ color: "#999", fontSize: 16 }}>商品不存在</Text>
+        <Text style={{ color: "#999", fontSize: 16 }}>{error || '商品不存在'}</Text>
+        <TouchableOpacity onPress={() => router.back()} style={{ marginTop: 20 }}>
+          <Text style={{ color: "#fff", fontSize: 14 }}>返回</Text>
+        </TouchableOpacity>
       </View>
     );
   }

+ 4 - 1
app/cloud-warehouse/index.tsx

@@ -333,7 +333,10 @@ export default function StoreScreen() {
           </TouchableOpacity>
           <TouchableOpacity
             style={styles.cellBody}
-            onPress={() => router.push({ pathname: '/cloud-warehouse/detail', params: { id: item.id } } as any)}
+            onPress={() => {
+              console.log('[仓库] 点击商品详情, id:', item.id);
+              router.push({ pathname: '/cloud-warehouse/detail', params: { id: item.id } } as any);
+            }}
             activeOpacity={0.7}
           >
             <ImageBackground