| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- import { Image } from 'expo-image';
- import { useRouter } from 'expo-router';
- import React, { useCallback, useEffect, useState } from 'react';
- import {
- 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<UserInfo | null>(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 (
- <View style={styles.container}>
- <StatusBar barStyle="light-content" />
- <ImageBackground
- source={{ uri: Images.mine.kaixinMineBg }}
- style={styles.background}
- resizeMode="cover"
- >
- {/* 顶部导航 */}
- <View style={[styles.header, { paddingTop: insets.top + 50 }]}>
- <Text style={styles.title}>福利</Text>
- </View>
- {/* 标题区域 */}
- <ImageBackground
- source={{ uri: Images.welfare.wealTitle }}
- style={styles.headSection}
- resizeMode="cover"
- >
- <Text style={styles.headTitle}>限时福利活动</Text>
- <Text style={styles.headText}>限时活动,不定时开放</Text>
- </ImageBackground>
- {/* 房间列表 */}
- {showSection && (
- <ScrollView
- style={styles.scrollView}
- showsVerticalScrollIndicator={false}
- contentContainerStyle={styles.scrollContent}
- >
- <TouchableOpacity
- style={styles.roomItem}
- onPress={() => handleRoomPress(0)}
- activeOpacity={0.8}
- >
- <Image
- source={{ uri: Images.welfare.indexItem1 }}
- style={styles.roomImage}
- contentFit="contain"
- />
- </TouchableOpacity>
- <TouchableOpacity
- style={styles.roomItem}
- onPress={() => handleRoomPress(1)}
- activeOpacity={0.8}
- >
- <Image
- source={{ uri: Images.welfare.indexItem2 }}
- style={styles.roomImage}
- contentFit="contain"
- />
- </TouchableOpacity>
- <TouchableOpacity
- style={styles.roomItem}
- onPress={() => handleRoomPress(2)}
- activeOpacity={0.8}
- >
- <Image
- source={{ uri: Images.welfare.indexItem3 }}
- style={styles.roomImage}
- contentFit="contain"
- />
- </TouchableOpacity>
- </ScrollView>
- )}
- {/* 底部占位 */}
- <View style={{ height: 120 }} />
- </ImageBackground>
- </View>
- );
- }
- 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: 15,
- },
- roomImage: {
- width: 375,
- height: 130,
- },
- });
|