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