引入 husky,并全局重新格式化
This commit is contained in:
@@ -38,7 +38,6 @@ export type RechargeModelProps = {
|
||||
}
|
||||
|
||||
export default function RechargeModal(props: RechargeModelProps) {
|
||||
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
const form = useForm<Schema>({
|
||||
@@ -154,63 +153,74 @@ export default function RechargeModal(props: RechargeModelProps) {
|
||||
setStep(0)
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button theme={`accent`} type={`button`} className={merge(`px-4 h-8`, props.classNames?.trigger)}>去充值</Button>
|
||||
<Button theme="accent" type="button" className={merge(`px-4 h-8`, props.classNames?.trigger)}>去充值</Button>
|
||||
</DialogTrigger>
|
||||
|
||||
<DialogContent>
|
||||
<DialogTitle className={`flex flex-col gap-2`}>
|
||||
<DialogTitle className="flex flex-col gap-2">
|
||||
充值中心
|
||||
</DialogTitle>
|
||||
|
||||
{step === 0 && (
|
||||
<Form form={form} onSubmit={createRecharge} className={`flex flex-col gap-8`}>
|
||||
<Form form={form} onSubmit={createRecharge} className="flex flex-col gap-8">
|
||||
|
||||
{/* 充值额度 */}
|
||||
<FormField<Schema> name={`amount`} label={`充值额度`} className={`flex flex-col gap-4`}>
|
||||
<FormField<Schema> name="amount" label="充值额度" className="flex flex-col gap-4">
|
||||
{({id, field}) => (
|
||||
<RadioGroup
|
||||
id={id}
|
||||
defaultValue={String(field.value)}
|
||||
onValueChange={v => field.onChange(Number(v))}
|
||||
className={`flex flex-col gap-2`}>
|
||||
className="flex flex-col gap-2">
|
||||
|
||||
<div className={`flex items-center gap-2`}>
|
||||
<div className="flex items-center gap-2">
|
||||
<FormOption
|
||||
id={`${id}-20`} value={`20`} label={`20元`}
|
||||
id={`${id}-20`}
|
||||
value="20"
|
||||
label="20元"
|
||||
compare={String(field.value)}
|
||||
className={`flex-1`}
|
||||
className="flex-1"
|
||||
/>
|
||||
<FormOption
|
||||
id={`${id}-50`} value={`50`} label={`50元`}
|
||||
id={`${id}-50`}
|
||||
value="50"
|
||||
label="50元"
|
||||
compare={String(field.value)}
|
||||
className={`flex-1`}
|
||||
className="flex-1"
|
||||
/>
|
||||
<FormOption
|
||||
id={`${id}-100`} value={`100`} label={`100元`}
|
||||
id={`${id}-100`}
|
||||
value="100"
|
||||
label="100元"
|
||||
compare={String(field.value)}
|
||||
className={`flex-1`}
|
||||
className="flex-1"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={`flex items-center gap-2`}>
|
||||
<div className="flex items-center gap-2">
|
||||
<FormOption
|
||||
id={`${id}-200`} value={`200`} label={`200元`}
|
||||
id={`${id}-200`}
|
||||
value="200"
|
||||
label="200元"
|
||||
compare={String(field.value)}
|
||||
className={`flex-1`}
|
||||
className="flex-1"
|
||||
/>
|
||||
<FormOption
|
||||
id={`${id}-500`} value={`500`} label={`500元`}
|
||||
id={`${id}-500`}
|
||||
value="500"
|
||||
label="500元"
|
||||
compare={String(field.value)}
|
||||
className={`flex-1`}
|
||||
className="flex-1"
|
||||
/>
|
||||
<FormOption
|
||||
id={`${id}-1000`} value={`1000`} label={`1000元`}
|
||||
id={`${id}-1000`}
|
||||
value="1000"
|
||||
label="1000元"
|
||||
compare={String(field.value)}
|
||||
className={`flex-1`}
|
||||
className="flex-1"
|
||||
/>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
@@ -218,74 +228,89 @@ export default function RechargeModal(props: RechargeModelProps) {
|
||||
</FormField>
|
||||
|
||||
{/* 支付方式 */}
|
||||
<FormField name={`method`} label={`支付方式`} className={`flex flex-col gap-4`}>
|
||||
<FormField name="method" label="支付方式" className="flex flex-col gap-4">
|
||||
{({id, field}) => (
|
||||
<RadioGroup
|
||||
id={id}
|
||||
defaultValue={field.value}
|
||||
onValueChange={field.onChange}
|
||||
className={`flex gap-2`}>
|
||||
className="flex gap-2">
|
||||
<FormOption
|
||||
id={`${id}-alipay`} value={`alipay`}
|
||||
id={`${id}-alipay`}
|
||||
value="alipay"
|
||||
compare={field.value}
|
||||
className={`flex-1 flex-row justify-center items-center`}>
|
||||
<Image src={alipay} alt={`支付宝 logo`} className={`w-6 h-6`}/>
|
||||
className="flex-1 flex-row justify-center items-center">
|
||||
<Image src={alipay} alt="支付宝 logo" className="w-6 h-6"/>
|
||||
<span>支付宝</span>
|
||||
</FormOption>
|
||||
<FormOption
|
||||
id={`${id}-wechat`} value={`wechat`}
|
||||
id={`${id}-wechat`}
|
||||
value="wechat"
|
||||
compare={field.value}
|
||||
className={`flex-1 flex-row justify-center items-center`}>
|
||||
<Image src={wechat} alt={`微信 logo`} className={`w-6 h-6`}/>
|
||||
className="flex-1 flex-row justify-center items-center">
|
||||
<Image src={wechat} alt="微信 logo" className="w-6 h-6"/>
|
||||
<span>微信</span>
|
||||
</FormOption>
|
||||
</RadioGroup>
|
||||
)}
|
||||
</FormField>
|
||||
|
||||
<DialogFooter className={`!flex !flex-row !justify-center`}>
|
||||
<Button className={`px-8 h-12 text-lg`}>立即支付</Button>
|
||||
<DialogFooter className="!flex !flex-row !justify-center">
|
||||
<Button className="px-8 h-12 text-lg">立即支付</Button>
|
||||
</DialogFooter>
|
||||
</Form>
|
||||
)}
|
||||
{step == 1 && <>
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
<div className="flex flex-col items-center gap-3">
|
||||
<div className="bg-gray-100 size-50 flex items-center justify-center">
|
||||
{payInfo ?
|
||||
method === 'alipay'
|
||||
? <iframe src={payInfo.pay_url} className="w-full h-full"/>
|
||||
: <canvas ref={canvas} className="w-full h-full"/>
|
||||
: (
|
||||
<Loader size={40} className={`animate-spin text-weak`}/>
|
||||
)}
|
||||
{step == 1 && (
|
||||
<>
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
<div className="flex flex-col items-center gap-3">
|
||||
<div className="bg-gray-100 size-50 flex items-center justify-center">
|
||||
{payInfo
|
||||
? method === 'alipay'
|
||||
? <iframe src={payInfo.pay_url} className="w-full h-full"/>
|
||||
: <canvas ref={canvas} className="w-full h-full"/>
|
||||
: (
|
||||
<Loader size={40} className="animate-spin text-weak"/>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-sm text-gray-600 text-center">
|
||||
请使用
|
||||
{method === 'alipay' ? '支付宝' : '微信'}
|
||||
扫码支付
|
||||
</p>
|
||||
</div>
|
||||
<div className="text-center space-y-1">
|
||||
<p className="font-medium">
|
||||
支付金额:
|
||||
<span className="text-accent">
|
||||
{amount}
|
||||
元
|
||||
</span>
|
||||
</p>
|
||||
<p className="text-xs text-gray-500">
|
||||
订单号:
|
||||
{payInfo?.trade_no || '创建订单中...'}
|
||||
</p>
|
||||
</div>
|
||||
<p className="text-sm text-gray-600 text-center">
|
||||
请使用{method === 'alipay' ? '支付宝' : '微信'}扫码支付
|
||||
</p>
|
||||
</div>
|
||||
<div className="text-center space-y-1">
|
||||
<p className="font-medium">支付金额: <span className="text-accent">{amount}元</span></p>
|
||||
<p className="text-xs text-gray-500">订单号: {payInfo?.trade_no || '创建订单中...'}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DialogFooter className={`!flex !flex-row !justify-center`}>
|
||||
<Button
|
||||
className={`px-8 text-lg`}
|
||||
onClick={confirmRecharge}
|
||||
>
|
||||
已完成支付
|
||||
</Button>
|
||||
<Button
|
||||
theme={`outline`}
|
||||
className={`px-8 text-lg`}
|
||||
onClick={closeDialog}
|
||||
>
|
||||
关闭
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</>}
|
||||
<DialogFooter className="!flex !flex-row !justify-center">
|
||||
<Button
|
||||
className="px-8 text-lg"
|
||||
onClick={confirmRecharge}
|
||||
>
|
||||
已完成支付
|
||||
</Button>
|
||||
<Button
|
||||
theme="outline"
|
||||
className="px-8 text-lg"
|
||||
onClick={closeDialog}
|
||||
>
|
||||
关闭
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</>
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user