import ReturnArrowSvg from '@/assets/icons/svg/returnArrow.svg'; import StarSvg from '@/assets/icons/svg/whiteStart.svg'; import PrivacyModal from '@/components/owner/qualification/privacy'; import Normal from '@/components/owner/rights/normal'; import Premium, { PayItem } from '@/components/owner/rights/premium'; import ProRights from '@/components/owner/rights/proRights'; import { maxDiscountProduct } from '@/components/owner/rights/utils'; import { ThemedText } from '@/components/ThemedText'; import { fetchApi } from '@/lib/server-api-util'; import { useLocalSearchParams, useRouter } from "expo-router"; import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Image, ScrollView, StyleSheet, TouchableOpacity, View } from 'react-native'; import { useSafeAreaInsets } from "react-native-safe-area-context"; export default function Rights() { const insets = useSafeAreaInsets(); const router = useRouter(); const { t } = useTranslation(); // 获取路由参数 const { credit } = useLocalSearchParams<{ credit: string; }>(); // 普通用户,会员 const [userType, setUserType] = useState<'normal' | 'premium'>('normal'); // 选择权益方式 const [payType, setPayType] = useState(''); // 用户协议弹窗打开 const [showTerms, setShowTerms] = useState(false); // 调接口获取支付信息 const [premiumPay, setPremiumPay] = useState(); const [loading, setLoading] = useState(false); const getPAy = async () => { setLoading(true); const payInfo = await fetchApi(`/order/product-items?product_type=Membership`) let bestValue = maxDiscountProduct(payInfo) setPayType(bestValue?.product_code) setPremiumPay([bestValue, ...payInfo?.filter((item) => item.product_code !== bestValue?.product_code)]); setLoading(false); } useEffect(() => { getPAy(); }, []); return ( {/* 导航栏 */} { router.push('/owner') }} style={{ padding: 16 }}> {t('rights.title', { ns: 'personal' })} 123 {/* 会员卡 */} {userType === 'normal' ? ( ) : ( )} {t('rights.purchase', { ns: 'personal' })} {credit} {/* 会员信息 */} {/* 切换按钮 */} { setUserType("normal") }} style={[styles.switchButtonItem, { backgroundColor: userType === 'normal' ? "#FFB645" : "#fff", borderColor: userType === 'normal' ? "#FFB645" : "#E2793F" }]} > {t('rights.free', { ns: 'personal' })} { setUserType("premium") }} style={[styles.switchButtonItem, { backgroundColor: userType === 'premium' ? "#E2793F" : "#fff", borderColor: userType === 'premium' ? "#E2793F" : "#E2793F" }]} > {t('rights.premium', { ns: 'personal' })} {/* 普通权益 */} {/* 会员权益 */} {/* 会员权益信息 */} {/* 付费按钮 */} { setUserType('premium'); }} activeOpacity={0.8} > {t('rights.subscribe', { ns: 'personal' })} { setShowTerms(true); }} activeOpacity={0.8} > {t('rights.terms', { ns: 'personal' })} {/* 协议弹窗 */} ); } const styles = StyleSheet.create({ goPay: { backgroundColor: '#E2793F', borderRadius: 24, paddingVertical: 10, display: "flex", alignItems: "center", width: "100%", }, switchButton: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', gap: 16, marginBottom: 16 }, switchButtonItem: { width: "48%", borderRadius: 24, paddingVertical: 6, display: "flex", alignItems: "center", borderWidth: 1 }, info: { marginHorizontal: 16, marginVertical: 16, padding: 16, borderRadius: 12, backgroundColor: '#fff', shadowColor: '#000', shadowOffset: { width: 0, height: 2, }, shadowOpacity: 0.25, shadowRadius: 5, elevation: 5, }, container: { flex: 1, backgroundColor: 'white', }, header: { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginVertical: 16, }, headerTitle: { fontSize: 20, fontWeight: '700', color: '#4C320C', }, card: { marginHorizontal: 16, marginVertical: 16, backgroundColor: '#FFB645', borderRadius: 12, }, cardContent: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0, padding: 16, justifyContent: 'space-between' }, cardinfo: { alignItems: 'flex-end', }, cardTitle: { fontSize: 12, fontWeight: '700', color: '#E2793F', backgroundColor: '#fff', paddingHorizontal: 8, paddingVertical: 2, borderRadius: 20, textAlign: 'center', marginBottom: 24 }, cardPoints: { display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 4 }, cardPointsText: { fontSize: 32, fontWeight: '700', color: '#4C320C', lineHeight: 32 } });