diff --git a/app/(tabs)/generate.tsx b/app/(tabs)/generate.tsx index 01aaacd..fd941e9 100644 --- a/app/(tabs)/generate.tsx +++ b/app/(tabs)/generate.tsx @@ -159,6 +159,7 @@ type Template = { name: string image: string type: 'video' + price?: number data?: any } @@ -261,9 +262,17 @@ const TemplateSection = memo(function TemplateSection({ te ) }) -type GenerateSectionProps = { onGenerate: () => void } -const GenerateSection = memo(function GenerateSection({ onGenerate }) { +type GenerateSectionProps = { + selectedTemplate: Template | undefined + onGenerate: () => void +} +const GenerateSection = memo(function GenerateSection({ selectedTemplate, onGenerate }) { const insets = useSafeAreaInsets() + + if (!selectedTemplate) return null + + const price = selectedTemplate.price || selectedTemplate.data?.price || 0 + return ( @@ -281,7 +290,7 @@ const GenerateSection = memo(function GenerateSection({ on {/* 右侧 Goo 标签 */} - 3 Goo + {price} Goo @@ -317,6 +326,7 @@ export default function Index() { name: t.title, image: t.coverImageUrl, type: 'video' as const, + price: t.price, data: t, })) }, [templates.data]) @@ -393,7 +403,7 @@ export default function Index() { - + ) } diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index 5b53fa0..ed96a4f 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -32,6 +32,7 @@ type MediaItem = { url: string poster?: string likeCount: number + price: number } type ActiveTab = 'gen' | '' | 'new' | 'like' @@ -358,6 +359,7 @@ export default function Sync() { url: isVideo ? template.previewUrl : template.coverImageUrl || template.previewUrl, poster: isVideo ? template.coverImageUrl : undefined, likeCount: template.likeCount || 0, + price: template.price || 2, // 默认为 2 Goo } }, []) @@ -594,7 +596,7 @@ export default function Sync() { return } - const cost = 2 + const cost = selectedItem.price if (balance < cost) { Toast.show({ title: '余额不足,请充值' })