import { Image } from 'expo-image'; import { useRouter } from 'expo-router'; import React, { useCallback, useEffect, useState } from 'react'; import { Dimensions, ImageBackground, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View, } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { Images } from '@/constants/images'; import { getUserInfo, UserInfo } from '@/services/user'; export default function WelfareScreen() { const router = useRouter(); const insets = useSafeAreaInsets(); const [showSection, setShowSection] = useState(true); const [user, setUser] = useState(null); const loadUserInfo = useCallback(async () => { try { const info = await getUserInfo(); setUser(info); } catch (error) { console.error('获取用户信息失败:', error); } }, []); useEffect(() => { loadUserInfo(); }, [loadUserInfo]); const handleRoomPress = (type: number) => { if (type === 0) { // 福利房间 router.push('/weal/room' as any); } else if (type === 1) { // 扭蛋机 router.push('/weal/catchDoll' as any); } else { // 祈愿 router.push('/weal/wish' as any); } }; return ( {/* 顶部导航 */} 福利 {/* 标题区域 */} 限时福利活动 限时活动,不定时开放 {/* 房间列表 */} {showSection && ( handleRoomPress(0)} activeOpacity={0.8} > handleRoomPress(1)} activeOpacity={0.8} > handleRoomPress(2)} activeOpacity={0.8} > )} {/* 底部占位 */} ); } const { width: SCREEN_WIDTH } = Dimensions.get('window'); const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#52504e', }, background: { flex: 1, }, header: { alignItems: 'center', position: 'absolute', top: 0, left: 0, right: 0, zIndex: 100, }, title: { color: '#fff', fontSize: 16, fontWeight: 'bold', height: 40, lineHeight: 40, }, headSection: { width: '100%', height: 192, alignItems: 'center', paddingTop: 90, }, headTitle: { fontWeight: 'bold', fontSize: 40, color: '#FDF685', textShadowColor: '#E85801', textShadowOffset: { width: 1, height: 2 }, textShadowRadius: 0, }, headText: { fontSize: 15, color: '#E85801', marginTop: 5, textShadowColor: '#fff', textShadowOffset: { width: 1, height: 2 }, textShadowRadius: 1, }, scrollView: { flex: 1, marginTop: 15, }, scrollContent: { paddingHorizontal: 0, alignItems: 'center', }, roomItem: { marginBottom: 6, width: SCREEN_WIDTH - 12, // Minimal margins (6px each side) alignSelf: 'center', }, roomImage: { width: '100%', height: undefined, aspectRatio: 3, // Taller (345/115) to reduce horizontal stretch }, });