import { Images } from '@/constants/images'; import { Image, ImageBackground } from 'expo-image'; import React from 'react'; import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; interface FirstLastProps { data: any; box: any; onPrevBox?: () => void; onNextBox?: () => void; onChangeBox?: () => void; onProductClick?: (product: any) => void; } export default function FirstLast({ data, box, onPrevBox, onNextBox, onChangeBox, onProductClick }: FirstLastProps) { // Filter for special prizes: FIRST, LAST, LASTALL const prizeList = React.useMemo(() => { if (!box || !box.prizeList) return []; return box.prizeList.filter((item: any) => ['FIRST', 'LAST', 'LASTALL'].includes(item.level) ); }, [box]); if (!box) return null; return ( {/* Title / Remain Info */} 当前盒子剩余: {box.leftQuantity} /{box.quantity}发 {/* Prize List (First/Last) */} {prizeList.map((item: any, index: number) => ( onProductClick && onProductClick(item.spu)} > {item.level === 'FIRST' && ( 抢先赏 )} {item.level === 'LAST' && ( 最终赏 )} {item.level === 'LASTALL' && ( 全局赏 )} {/* User Avatar if someone won it? Legacy logic: v-if="item.nickname" */} {item.nickname && ( {item.nickname} )} ))} {/* Controls */} 上一盒 换盒({box.number}/{box.lastNumber}) 下一盒 ); } const styles = StyleSheet.create({ container: { paddingHorizontal: 10, marginBottom: 10, }, bg: { width: '100%', height: 193, // 386rpx / 2 alignItems: 'center', }, header: { width: '100%', flexDirection: 'row', justifyContent: 'space-between', paddingHorizontal: 20, paddingTop: 20, }, remainInfo: { flexDirection: 'row', alignItems: 'center', }, remainLabel: { color: '#fff', fontSize: 12 }, remainValue: { color: '#fff', fontSize: 12 }, remainNum: { fontSize: 16, fontWeight: 'bold' }, ruleBtn: { width: 41, height: 17 }, prizeContainer: { flexDirection: 'row', justifyContent: 'space-around', width: '80%', marginTop: 10, height: 70, // Adjust based on item size }, prizeItem: { width: 63, // 126rpx / 2 height: 65, }, prizeItemBg: { flex: 1, alignItems: 'center', justifyContent: 'center', }, prizeImg: { width: 60, height: 60, }, prizeLabelContainer: { position: 'absolute', bottom: -8, width: '100%', alignItems: 'center', }, prizeLabel: { fontSize: 10, color: '#fff', paddingHorizontal: 4, paddingVertical: 1, borderRadius: 4, overflow: 'hidden', }, winnerBox: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, justifyContent: 'center', alignItems: 'center', backgroundColor: 'rgba(0,0,0,0.6)', borderRadius: 30, // Circleish }, winnerAvatar: { width: 24, height: 24, borderRadius: 12, borderWidth: 1, borderColor: '#FFE996' }, winnerName: { color: '#FEC433', fontSize: 8, marginTop: 2, maxWidth: 50 }, controlsBg: { width: 270, // 540rpx / 2 height: 38, // 76rpx / 2 flexDirection: 'row', alignItems: 'center', justifyContent: 'center', marginTop: 25, }, controlBtn: { width: 90, height: '100%', justifyContent: 'center', alignItems: 'center', }, changeBtn: { width: 110, height: '100%', justifyContent: 'center', alignItems: 'center', }, controlText: { color: '#fff', fontSize: 14, fontWeight: '500', } });