import { Image } from 'expo-image'; import { useLocalSearchParams, useRouter } from 'expo-router'; import React, { useCallback, useEffect, useState } from 'react'; import { ActivityIndicator, Dimensions, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View, } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { getPoolDetail } from '@/services/award'; const { width: SCREEN_WIDTH } = Dimensions.get('window'); interface ProductItem { id: string; name: string; cover: string; level: string; probability: number; quantity?: number; spu?: { id: string; cover: string; name: string; marketPrice?: number; parameter?: string; brandName?: string; worksName?: string; pic?: string; }; } interface PoolData { id: string; name: string; price: number; luckGoodsList: ProductItem[]; recommendedLuckPool?: any[]; } export default function AwardDetailSwipeScreen() { const { poolId, index } = useLocalSearchParams<{ poolId: string; index: string }>(); const router = useRouter(); const insets = useSafeAreaInsets(); const [loading, setLoading] = useState(true); const [data, setData] = useState(null); const [products, setProducts] = useState([]); const [currentIndex, setCurrentIndex] = useState(parseInt(index || '0', 10)); const loadData = useCallback(async () => { if (!poolId) return; setLoading(true); try { const detail = await getPoolDetail(poolId); if (detail) { setData(detail); setProducts(detail.luckGoodsList || []); } } catch (error) { console.error('加载数据失败:', error); } setLoading(false); }, [poolId]); useEffect(() => { loadData(); }, [poolId]); const handlePrev = () => { if (currentIndex > 0) setCurrentIndex(currentIndex - 1); }; const handleNext = () => { if (currentIndex < products.length - 1) setCurrentIndex(currentIndex + 1); }; const parseParameter = (paramStr?: string) => { if (!paramStr) return []; try { return JSON.parse(paramStr); } catch { return []; } }; if (loading) { return ( ); } if (!data || products.length === 0) { return ( 商品不存在 router.back()}> 返回 ); } const currentProduct = products[currentIndex]; const params = parseParameter(currentProduct?.spu?.parameter); const detailPics = currentProduct?.spu?.pic ? currentProduct.spu.pic.split(',').filter(Boolean) : []; const recommendList = data.recommendedLuckPool || []; return ( {/* 顶部导航 */} router.back()}> {'<'} {/* 商品图片区域 */} {/* 左右切换按钮 */} {currentIndex > 0 && ( {'<'} )} {currentIndex < products.length - 1 && ( {'>'} )} {/* 价格和名称区域 */} ¥{currentProduct?.spu?.marketPrice || data.price} {currentProduct?.name} {/* 参数区域 */} 参数 {params.length > 0 && ( {params.map((param: { label: string; value: string }, idx: number) => ( {param.label} {param.value} ))} )} {currentProduct?.spu?.worksName && ( IP {currentProduct.spu.worksName} )} {currentProduct?.spu?.brandName && ( 品牌 {currentProduct.spu.brandName} )} {/* 放心购 正品保障 */} 放心购 正品保障 不支持七天无理由退换货 包邮 {/* 商品推荐 */} {recommendList.length > 0 && ( 商品推荐 {recommendList.map((item: any) => ( router.push({ pathname: '/award-detail', params: { poolId: item.id } } as any)} > {item.name} ¥{item.price} ))} )} {/* 商品详情 */} 商品详情 {detailPics.length > 0 ? ( detailPics.map((pic, idx) => ( )) ) : ( 商城购买须知! 商城现货 商城所售现货商品均为全新正版商品。手办模玩非艺术品,因厂商品控差异导致的微小瑕疵属于正常情况,官图仅供参考,具体以实物为准。 新品预定 预定商品的总价=定金+尾款,在预定期限内支付定金后,商品到货并补齐尾款后,超级商城才会发货相应商品预定订单确认成功后,定金不可退。{'\n'} 商品页面显示的商品制作完成时间及预计补款时间,都是按照官方预估的时间推测,具体到货时间请以实际出货为准。如因厂商、海关等因素造成延期的,不接受以此原因申请定金退款,请耐心等待。 预售补款 商品到货后超级商城会通过您在预定时预留的号码进行短信通知请自行留意。为防止错过补款通知,可添加商城客服,并备注所购商品进入对应社群,社群会同步推送新品咨询及补款通知。 )} ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#f5f5f5' }, loadingContainer: { flex: 1, backgroundColor: '#f5f5f5', justifyContent: 'center', alignItems: 'center' }, errorText: { color: '#999', fontSize: 16 }, backBtn2: { marginTop: 20, backgroundColor: '#ff6600', paddingHorizontal: 20, paddingVertical: 10, borderRadius: 8 }, backBtn2Text: { color: '#fff', fontSize: 14 }, header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 10, paddingBottom: 10, backgroundColor: 'transparent', position: 'absolute', top: 0, left: 0, right: 0, zIndex: 10, }, backBtn: { width: 40, height: 40, justifyContent: 'center', alignItems: 'center' }, backText: { color: '#333', fontSize: 24, fontWeight: 'bold' }, placeholder: { width: 40 }, scrollView: { flex: 1 }, // 图片区域 imageSection: { paddingTop: 80, paddingBottom: 20, alignItems: 'center', position: 'relative', }, productImage: { width: SCREEN_WIDTH * 0.7, height: 350, }, prevBtn: { position: 'absolute', left: 10, top: '50%', width: 36, height: 36, backgroundColor: 'rgba(0,0,0,0.3)', borderRadius: 18, justifyContent: 'center', alignItems: 'center', }, nextBtn: { position: 'absolute', right: 10, top: '50%', width: 36, height: 36, backgroundColor: 'rgba(0,0,0,0.3)', borderRadius: 18, justifyContent: 'center', alignItems: 'center', }, arrowText: { color: '#fff', fontSize: 18, fontWeight: 'bold' }, // 价格区域 priceSection: { backgroundColor: '#fff', paddingHorizontal: 16, paddingVertical: 12, }, priceRow: { flexDirection: 'row', alignItems: 'baseline', }, priceText: { fontSize: 24, color: '#ff4444', fontWeight: 'bold', }, productName: { fontSize: 16, color: '#333', marginTop: 8, lineHeight: 22, }, // 参数区域 paramSection: { backgroundColor: '#fff', marginTop: 10, paddingHorizontal: 16, paddingVertical: 12, }, paramHeader: { flexDirection: 'row', alignItems: 'center', paddingBottom: 10, borderBottomWidth: 1, borderBottomColor: '#eee', }, paramTitle: { fontSize: 14, color: '#666', }, paramScroll: { marginTop: 10, }, paramItem: { paddingHorizontal: 12, borderRightWidth: 1, borderRightColor: '#eee', }, paramLabel: { fontSize: 14, color: '#666' }, paramValue: { fontSize: 14, color: '#333', marginTop: 4 }, paramRow: { flexDirection: 'row', alignItems: 'center', paddingTop: 12, }, paramRowLabel: { fontSize: 14, color: '#666', width: 50, }, paramRowValue: { fontSize: 14, color: '#333', flex: 1, }, // 放心购区域 guaranteeSection: { backgroundColor: '#fff', marginTop: 10, paddingHorizontal: 16, paddingVertical: 12, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', }, guaranteeTitle: { fontSize: 14, color: '#333', fontWeight: 'bold', }, guaranteeText: { fontSize: 12, color: '#999', }, // 商品推荐 recommendSection: { backgroundColor: '#1a1a1a', marginTop: 10, paddingHorizontal: 16, paddingVertical: 16, }, recommendTitle: { fontSize: 16, fontWeight: 'bold', color: '#fff', marginBottom: 12, }, recommendScroll: { paddingRight: 10, }, recommendItem: { width: 90, marginRight: 12, }, recommendImage: { width: 90, height: 90, backgroundColor: '#fff', borderRadius: 4, }, recommendName: { fontSize: 12, color: '#fff', marginTop: 6, }, recommendPrice: { fontSize: 14, color: '#ff4444', fontWeight: 'bold', marginTop: 4, }, // 商品详情 detailSection: { backgroundColor: '#1a1a1a', marginTop: 10, paddingHorizontal: 16, paddingVertical: 16, }, detailTitle: { fontSize: 16, fontWeight: 'bold', color: '#fff', marginBottom: 16, }, detailImage: { width: SCREEN_WIDTH - 32, height: 400, marginBottom: 10, }, detailContent: { backgroundColor: '#fff', borderRadius: 8, padding: 16, }, detailHeading: { fontSize: 18, fontWeight: 'bold', color: '#333', textAlign: 'center', marginBottom: 20, }, detailSubTitle: { fontSize: 16, fontWeight: 'bold', color: '#333', marginTop: 16, marginBottom: 8, paddingLeft: 10, borderLeftWidth: 3, borderLeftColor: '#333', }, detailText: { fontSize: 14, color: '#666', lineHeight: 22, }, });