import { MyBetaModalFormProps, MyButtons, MyModalFormProps, renderTextHelper, } from '@/common'; import { Apis } from '@/gen/Apis'; import { BillPaymentsTypeEnum, BillsStatusEnum } from '@/gen/Enums'; import { BetaSchemaForm, ProDescriptions } from '@ant-design/pro-components'; import { Form, QRCode, Tabs } from 'antd'; import { useState } from 'react'; export default function ShowQrCode(props: MyBetaModalFormProps) { const [form] = Form.useForm(); const [activeTab, setActiveTab] = useState('wechat'); const [wechatQrCode, setWechatQrCode] = useState(''); const [alipayQrCode, setAlipayQrCode] = useState(''); const fetchQrCode = (type: 'wechat' | 'alipay') => { if (!props?.item?.id) return; const params = { id: props.item.id, }; if (type === 'wechat') { Apis.Bill.Bills.GetPayCode(params).then((res: any) => { setWechatQrCode(res?.data?.qr_code || ''); }); } else { Apis.Bill.Bills.AlipayQrCode(params).then((res: any) => { setAlipayQrCode(res?.data?.payinfo || ''); }); } }; return ( {...MyModalFormProps.props} title={props.title} width="500px" wrapperCol={{ span: 24 }} trigger={ } form={form} submitter={false} onOpenChange={(open: any) => { if (open) { setWechatQrCode(''); setAlipayQrCode(''); setActiveTab('wechat'); fetchQrCode('wechat'); } }} columns={[ { title: '', colProps: { span: 24 }, key: 'qrcode', renderFormItem() { return (
{props?.item?.asset_project?.name || '-'} ¥{props?.item?.amount || 0} {props?.item?.remark || '-'} { setActiveTab(key); fetchQrCode(key as 'wechat' | 'alipay'); }} items={[ { key: 'wechat', label: '微信支付', children: (
{wechatQrCode ? ( 微信支付二维码 ) : (
加载中...
)}
), }, { key: 'alipay', label: '支付宝', children: (
{alipayQrCode ? ( ) : (
加载中...
)}
), }, ]} />
); }, }, ]} /> ); }