plan pages

This commit is contained in:
xavier
2025-06-03 16:37:39 +08:00
parent 0d33ba7e34
commit 1f2a1dab00
62 changed files with 12508 additions and 1984 deletions

View File

@@ -0,0 +1,307 @@
"use client"
import { useState } from "react"
import { useRouter } from "next/navigation"
import { ChevronLeft, Info } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Card, CardContent } from "@/components/ui/card"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Textarea } from "@/components/ui/textarea"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Switch } from "@/components/ui/switch"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
import { toast } from "@/components/ui/use-toast"
export default function NewPaymentCodePage() {
const router = useRouter()
const [formData, setFormData] = useState({
name: "",
amount: "",
description: "",
paymentMethod: "wechat",
amountType: "fixed",
enableDistribution: false,
distributionType: "percentage",
distributionValue: "",
enableRedPacket: false,
redPacketAmount: "",
enableAutoWelcome: false,
welcomeMessage: "",
tags: [],
})
const handleChange = (field: string, value: any) => {
setFormData((prev) => ({ ...prev, [field]: value }))
}
const handleSubmit = () => {
// 表单验证
if (!formData.name) {
toast({
title: "请输入付款码名称",
variant: "destructive",
})
return
}
if (formData.amountType === "fixed" && !formData.amount) {
toast({
title: "请输入付款金额",
variant: "destructive",
})
return
}
// 模拟API调用
setTimeout(() => {
toast({
title: "付款码创建成功",
description: "您可以在付款码列表中查看和管理",
})
router.push("/scenarios/payment")
}, 1000)
}
return (
<div className="flex flex-col min-h-screen bg-gray-50">
{/* 头部 */}
<header className="sticky top-0 z-10 bg-white border-b">
<div className="flex items-center justify-between h-14 px-4">
<div className="flex items-center">
<Button variant="ghost" size="icon" onClick={() => router.back()}>
<ChevronLeft className="h-5 w-5" />
</Button>
<h1 className="ml-2 text-lg font-medium"></h1>
</div>
</div>
</header>
{/* 表单内容 */}
<div className="flex-1 p-4 pb-20">
<Card className="mb-4">
<CardContent className="p-4 space-y-4">
<h2 className="font-medium"></h2>
<div className="space-y-2">
<Label htmlFor="name"></Label>
<Input
id="name"
placeholder="请输入付款码名称"
value={formData.name}
onChange={(e) => handleChange("name", e.target.value)}
/>
</div>
<div className="space-y-2">
<Label htmlFor="paymentMethod"></Label>
<Select value={formData.paymentMethod} onValueChange={(value) => handleChange("paymentMethod", value)}>
<SelectTrigger id="paymentMethod">
<SelectValue placeholder="选择支付方式" />
</SelectTrigger>
<SelectContent>
<SelectItem value="wechat"></SelectItem>
<SelectItem value="alipay"></SelectItem>
<SelectItem value="both"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<div className="flex items-center justify-between">
<Label></Label>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<Info className="h-4 w-4 text-gray-400" />
</TooltipTrigger>
<TooltipContent>
<p className="w-[200px] text-xs">
<br />
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
<RadioGroup
value={formData.amountType}
onValueChange={(value) => handleChange("amountType", value)}
className="flex flex-col space-y-1"
>
<div className="flex items-center space-x-2">
<RadioGroupItem value="fixed" id="fixed" />
<Label htmlFor="fixed"></Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="free" id="free" />
<Label htmlFor="free"></Label>
</div>
</RadioGroup>
</div>
{formData.amountType === "fixed" && (
<div className="space-y-2">
<Label htmlFor="amount"> ()</Label>
<Input
id="amount"
type="number"
step="0.01"
placeholder="请输入付款金额"
value={formData.amount}
onChange={(e) => handleChange("amount", e.target.value)}
/>
</div>
)}
<div className="space-y-2">
<Label htmlFor="description"></Label>
<Textarea
id="description"
placeholder="请输入付款描述,用户支付时可见"
value={formData.description}
onChange={(e) => handleChange("description", e.target.value)}
rows={3}
/>
</div>
</CardContent>
</Card>
<Card className="mb-4">
<CardContent className="p-4 space-y-4">
<h2 className="font-medium"></h2>
<div className="flex items-center justify-between">
<div className="space-y-1">
<Label htmlFor="enableDistribution"></Label>
<p className="text-xs text-gray-500"></p>
</div>
<Switch
id="enableDistribution"
checked={formData.enableDistribution}
onCheckedChange={(checked) => handleChange("enableDistribution", checked)}
/>
</div>
{formData.enableDistribution && (
<div className="space-y-4 pl-4 border-l-2 border-blue-100">
<div className="space-y-2">
<Label htmlFor="distributionType"></Label>
<Select
value={formData.distributionType}
onValueChange={(value) => handleChange("distributionType", value)}
>
<SelectTrigger id="distributionType">
<SelectValue placeholder="选择返利类型" />
</SelectTrigger>
<SelectContent>
<SelectItem value="percentage"></SelectItem>
<SelectItem value="fixed"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label htmlFor="distributionValue">
{formData.distributionType === "percentage" ? "返利比例 (%)" : "返利金额 (元)"}
</Label>
<Input
id="distributionValue"
type="number"
step={formData.distributionType === "percentage" ? "1" : "0.01"}
placeholder={formData.distributionType === "percentage" ? "例如10" : "例如5"}
value={formData.distributionValue}
onChange={(e) => handleChange("distributionValue", e.target.value)}
/>
</div>
</div>
)}
<div className="flex items-center justify-between">
<div className="space-y-1">
<Label htmlFor="enableRedPacket"></Label>
<p className="text-xs text-gray-500"></p>
</div>
<Switch
id="enableRedPacket"
checked={formData.enableRedPacket}
onCheckedChange={(checked) => handleChange("enableRedPacket", checked)}
/>
</div>
{formData.enableRedPacket && (
<div className="space-y-2 pl-4 border-l-2 border-blue-100">
<Label htmlFor="redPacketAmount"> ()</Label>
<Input
id="redPacketAmount"
type="number"
step="0.01"
placeholder="例如5"
value={formData.redPacketAmount}
onChange={(e) => handleChange("redPacketAmount", e.target.value)}
/>
</div>
)}
<div className="flex items-center justify-between">
<div className="space-y-1">
<Label htmlFor="enableAutoWelcome"></Label>
<p className="text-xs text-gray-500"></p>
</div>
<Switch
id="enableAutoWelcome"
checked={formData.enableAutoWelcome}
onCheckedChange={(checked) => handleChange("enableAutoWelcome", checked)}
/>
</div>
{formData.enableAutoWelcome && (
<div className="space-y-2 pl-4 border-l-2 border-blue-100">
<Label htmlFor="welcomeMessage"></Label>
<Textarea
id="welcomeMessage"
placeholder="请输入欢迎语内容"
value={formData.welcomeMessage}
onChange={(e) => handleChange("welcomeMessage", e.target.value)}
rows={3}
/>
</div>
)}
</CardContent>
</Card>
<Card>
<CardContent className="p-4 space-y-4">
<h2 className="font-medium"></h2>
<p className="text-sm text-gray-500"></p>
<div className="flex flex-wrap gap-2">
<Button variant="outline" size="sm" className="rounded-full">
</Button>
<Button variant="outline" size="sm" className="rounded-full">
</Button>
<Button variant="outline" size="sm" className="rounded-full">
</Button>
<Button variant="outline" size="sm" className="rounded-full text-blue-500">
+
</Button>
</div>
</CardContent>
</Card>
</div>
{/* 底部操作栏 */}
<div className="fixed bottom-0 left-0 right-0 bg-white border-t p-4 flex justify-between">
<Button variant="outline" onClick={() => router.back()}>
</Button>
<Button onClick={handleSubmit}></Button>
</div>
</div>
)
}