import React, { useEffect, useState } from 'react'; import { Input, Tag, Card, QRCode, Form, Descriptions, Typography, Alert, Button, Modal, Radio } from 'antd'; import { CheckCircleOutlined } from '@ant-design/icons'; import { CentToString } from 'oak-domain/lib/utils/money'; import Styles from './web.pc.module.less'; import * as dayJs from 'dayjs'; import duration from 'dayjs/plugin/duration'; import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; dayJs.extend(duration); export function RenderOffline(props) { const { pay, t, offline, offlines, updateOfflineId, updateExternalId } = props; const { iState, phantom3, externalId } = pay; const { type, channel, name, qrCode, color } = offline; const [show, setShow] = useState(false); const [showQrCode, setShowQrCode] = useState(false); const items2 = [ {`${t('channel.prefix')}`}}> {iState === 'paying' && offlines.length > 1 ? : {t(`offlineAccount:v.type.${type}`)}} , {t('code.label')}}> {phantom3} , {t('externalId.label')}}> { const { value } = currentTarget; updateExternalId(value); }} placeholder={t('externalId.help')} disabled={iState !== 'paying'}/> ]; if (type === 'bank') { items2.push( {channel} , {name} , {qrCode} ); } else { if (type === 'others') { items2.push( {channel} ); } if (name) { items2.push( {name} ); } if (qrCode) { items2.push( setShowQrCode(true)}> ); } } return (<> setShow(false)} closeIcon={null} footer={null}> { updateOfflineId(target.value); setShow(false); }} value={offline.id}> {offlines.map((ele, idx) => ( {t(`offlineAccount:v.type.${ele.type}`)} ))} setShowQrCode(false)}>
{items2}
); return null; } function Counter(props) { const { deadline } = props; const [counter, setCounter] = useState(''); const timerFn = () => { const now = Date.now(); if (now < deadline) { const duration = dayJs.duration(deadline - now); setCounter(duration.format('HH:mm:ss')); setTimeout(timerFn, 1000); } }; useEffect(() => { timerFn(); }, []); return ({counter}); } function RenderWechatPay(props) { const { pay, t } = props; const { externalId, wpProduct, timeoutAt, iState } = pay; if (iState === 'paid') { return (
{t('success')}
); } switch (wpProduct.type) { case 'native': { if (iState === 'paying') { return (
{process.env.NODE_ENV === 'production' ? : }
); } break; } } return null; } function RenderPayMeta(props) { const { pay, notSameApp, t, offlines, offline, updateOfflineId, updateExternalId } = props; const { iState, entity } = pay; if (entity !== 'offlineAccount' && notSameApp) { return ; } switch (entity) { case 'offlineAccount': { if (offline && offlines) { return (<> {iState === 'paying' && } ); } return null; } case 'wpProduct': { return ; } } // todo 要支持注入第三方支付的渲染组件 return null; } export default function Render(props) { const { pay, iStateColor, notSameApp, type, startPayable, oakExecutable, onClose, closable, offline, offlines } = props.data; const { t, update, execute, clean, goBack, startPay } = props.methods; if (pay) { const { iState, price, entity } = pay; const BtnPart = startPayable ? () : oakExecutable === true ? (<> ) : closable ? () : (); return ({t(`pay:v.iState.${iState}`)}}>
{t(`type.${type}`)}, }, { key: '1', label: t('pay:attr.price'), children: {`${t('common::pay.symbol')} ${CentToString(price, 2)}`}, }, { key: '2', label: t('pay:attr.entity'), children: {t(`payChannel::${entity}`)}, } ]}/>
{ execute(undefined, undefined, undefined, [ { entity: 'pay', operation: { id: await generateNewIdAsync(), action: 'update', data: { entity: 'offlineAccount', entityId, }, filter: { id: props.data.oakId, }, } } ]); }} updateExternalId={(externalId) => { update({ externalId, }); }}/>
{BtnPart}
); } return null; }