轻松聘
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

187 lines
4.9 KiB

import { Ionicons } from '@expo/vector-icons';
import { useRouter } from 'expo-router';
import { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useLegalData } from '../../src/hooks';
import { LoadingState, ErrorState, EmptyState } from '../../src/components/StateView';
import { colors } from '../../src/theme';
import type { LegalPlan } from '../../src/types';
/* ===================== 顶部导航 ===================== */
function Header({ onBack }: { onBack: () => void }) {
return (
<View style={styles.header}>
<Pressable style={styles.headerBtn} onPress={onBack} hitSlop={8}>
<Ionicons name="chevron-back" size={24} color={colors.textPrimary} />
</Pressable>
<Text style={styles.headerTitle}>开通会员</Text>
<View style={styles.headerBtn} />
</View>
);
}
/* ===================== 套餐卡片 ===================== */
function PlanCard({ plan }: { plan: LegalPlan }) {
return (
<View style={[styles.planCard, plan.recommended && styles.planCardRecommended]}>
{plan.recommended && (
<View style={styles.recommendedTag}>
<Text style={styles.recommendedText}>推荐</Text>
</View>
)}
<Text style={styles.planName}>{plan.name}</Text>
<View style={styles.planPriceRow}>
<Text style={styles.planCurrency}>¥</Text>
<Text style={styles.planPrice}>{plan.price}</Text>
<Text style={styles.planPeriod}>{plan.period}</Text>
</View>
<View style={styles.benefits}>
{plan.benefits.map((benefit, idx) => (
<View key={idx} style={styles.benefitRow}>
<Ionicons name="checkmark-circle" size={14} color={colors.success} />
<Text style={styles.benefitText}>{benefit}</Text>
</View>
))}
</View>
</View>
);
}
/* ===================== 页面 ===================== */
export default function LegalUpgradeScreen() {
const router = useRouter();
const { plans, loading, error, refresh } = useLegalData();
return (
<SafeAreaView style={styles.safeArea} edges={['top']}>
<Header onBack={() => router.back()} />
{loading ? (
<LoadingState text="加载套餐中…" />
) : error ? (
<ErrorState message="加载失败,请重试" onRetry={refresh} />
) : plans.length === 0 ? (
<EmptyState icon="card-outline" title="暂无会员套餐" subtitle="如有疑问,可前往法律咨询" />
) : (
<ScrollView
style={styles.scroll}
contentContainerStyle={styles.content}
showsVerticalScrollIndicator={false}
>
<Text style={styles.tip}>开通会员后可享受律师咨询、合同审核等专属法律服务</Text>
<View style={styles.planGrid}>
{plans.map((plan) => (
<PlanCard key={plan.id} plan={plan} />
))}
</View>
</ScrollView>
)}
</SafeAreaView>
);
}
const styles = StyleSheet.create({
safeArea: {
flex: 1,
backgroundColor: colors.pageBg,
},
header: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: 8,
height: 48,
backgroundColor: colors.white,
borderBottomWidth: 1,
borderBottomColor: colors.borderLight,
},
headerBtn: {
width: 40,
height: 40,
alignItems: 'center',
justifyContent: 'center',
},
headerTitle: {
fontSize: 17,
fontWeight: '700',
color: colors.textPrimary,
},
scroll: {
flex: 1,
},
content: {
padding: 12,
paddingBottom: 24,
},
tip: {
fontSize: 13,
color: colors.textSecondary,
marginBottom: 12,
},
planGrid: {
gap: 12,
},
planCard: {
padding: 14,
borderRadius: 8,
backgroundColor: colors.white,
borderWidth: 1,
borderColor: colors.border,
},
planCardRecommended: {
borderColor: colors.action,
backgroundColor: colors.actionLight,
},
recommendedTag: {
alignSelf: 'flex-start',
paddingHorizontal: 6,
paddingVertical: 2,
borderRadius: 4,
backgroundColor: colors.action,
marginBottom: 8,
},
recommendedText: {
fontSize: 10,
fontWeight: '700',
color: colors.white,
},
planName: {
fontSize: 15,
fontWeight: '700',
color: colors.textPrimary,
},
planPriceRow: {
flexDirection: 'row',
alignItems: 'baseline',
marginTop: 8,
marginBottom: 10,
},
planCurrency: {
fontSize: 14,
fontWeight: '700',
color: colors.actionText,
},
planPrice: {
fontSize: 28,
fontWeight: '700',
color: colors.actionText,
},
planPeriod: {
fontSize: 13,
color: colors.textSecondary,
},
benefits: {
gap: 6,
},
benefitRow: {
flexDirection: 'row',
alignItems: 'center',
gap: 6,
},
benefitText: {
fontSize: 12,
color: colors.textSecondary,
},
});