import React, { useEffect, useState } from 'react'; import { Card, Tag, List, Button, Modal, Form, Selector, Input, Popup } from 'antd-mobile'; import { QRCode, Alert } from 'antd'; import Styles from './web.mobile.module.less'; import * as dayJs from 'dayjs'; import duration from 'dayjs/plugin/duration'; dayJs.extend(duration); import { CentToString } from 'oak-domain/lib/utils/money'; import { PayCircleOutline, GlobalOutline, InformationCircleOutline, CheckCircleOutline } from 'antd-mobile-icons'; import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; export function RenderOffline(props) { const { pay, t, offline, offlines, updateOfflineId, updateExternalId } = props; const { meta, iState, phantom3, externalId } = pay; const { type, channel, name, qrCode, color } = offline || {}; const [show, setShow] = useState(false); const items2 = [ {`${t('channel.prefix')}`}}> {iState === 'paying' && offlines.length > 1 ? : {t(`offlineAccount:v.type.${type}`)}} , {t('code.label')}}> {phantom3} , {t('externalId.label')}}> { 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( Modal.show({ content: , closeOnMaskClick: true, })}> ); } } return (<> { setShow(false); }} onClose={() => { setShow(false); }} position='bottom' bodyStyle={{ padding: 18 }}> ({ label: t(`offlineAccount:v.type.${ele.type}`), value: ele.id, }))} value={offline ? [offline.id] : []} onChange={(arr) => { updateOfflineId(arr[0]); setShow(false); }}/>
{items2}
); } 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 ; } } 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; let BtnPart = closable ? () : startPayable ? () : oakExecutable === true ? (<>
) : (); return (
{t(`pay:v.iState.${iState}`)}}>
} extra={t(`type.${type}`)}> {t('type.label')} } extra={CentToString(price, 2)}> {t('pay:attr.price')} } extra={t(`payChannel::${entity}`)}> {t('pay:attr.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; }