From 3c2e1a961faf760dc2e9fc1cad9f9da85e6eb0c4 Mon Sep 17 00:00:00 2001 From: Xc Date: Tue, 30 Apr 2024 12:27:56 +0800 Subject: [PATCH] =?UTF-8?q?pay-detail=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=AF=B9w?= =?UTF-8?q?echatpay-native=E7=9A=84=E6=B8=B2=E6=9F=93=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/components/AbstractComponents.d.ts | 8 ++--- es/components/pay/detail/web.pc.js | 45 ++++++++++++++++++++------- es/features/Pay.d.ts | 2 +- src/components/pay/detail/web.pc.tsx | 1 - 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/es/components/AbstractComponents.d.ts b/es/components/AbstractComponents.d.ts index 6c5d81fe..ab5bd062 100644 --- a/es/components/AbstractComponents.d.ts +++ b/es/components/AbstractComponents.d.ts @@ -20,7 +20,7 @@ declare const List: (props: ReactComponentProps(props: { tablePagination?: any; rowSelection?: any; disableSerialNumber?: boolean | undefined; - size?: "small" | "middle" | "large" | undefined; + size?: "small" | "large" | "middle" | undefined; scroll?: any; locale?: any; }) => React.ReactElement; @@ -56,14 +56,14 @@ declare const Detail: (props: ReactComponentProps; title?: string | undefined; bordered?: boolean | undefined; - layout?: "vertical" | "horizontal" | undefined; + layout?: "horizontal" | "vertical" | undefined; }>) => React.ReactElement; declare const Upsert: (props: ReactComponentProps; entity: T; attributes: OakAbsAttrUpsertDef[]; data: EntityDict[T]["Schema"]; - layout: "vertical" | "horizontal"; + layout: "horizontal" | "vertical"; mode: "default" | "card"; }>) => React.ReactElement; export { FilterPanel, List, ListPro, Detail, Upsert, ReactComponentProps, ColumnProps, RowWithActions, OakExtraActionProps, OakAbsAttrDef, onActionFnDef, }; diff --git a/es/components/pay/detail/web.pc.js b/es/components/pay/detail/web.pc.js index 4820d26a..34e982be 100644 --- a/es/components/pay/detail/web.pc.js +++ b/es/components/pay/detail/web.pc.js @@ -1,7 +1,10 @@ -import React from 'react'; -import { Input, Tag, Card, QRCode, Form, Descriptions, Alert, Select, Button, Modal } from 'antd'; +import React, { useEffect, useState } from 'react'; +import { Input, Tag, Card, QRCode, Form, Descriptions, Typography, Alert, Select, Button, Modal } from 'antd'; 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'; +dayJs.extend(duration); import { PAY_CHANNEL_OFFLINE_NAME, PAY_CHANNEL_WECHAT_APP_NAME, PAY_CHANNEL_WECHAT_H5_NAME, PAY_CHANNEL_WECHAT_JS_NAME, PAY_CHANNEL_WECHAT_MP_NAME, PAY_CHANNEL_WECHAT_NATIVE_NAME } from '../../../types/PayConfig'; export function RenderOffline(props) { const { pay, t, offline, updateMeta, metaUpdatable } = props; @@ -29,19 +32,39 @@ export function RenderOffline(props) { ); } +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, channel } = pay; + const { externalId, channel, timeoutAt, iState } = pay; switch (channel) { case PAY_CHANNEL_WECHAT_NATIVE_NAME: { - return (<> - -
- {process.env.NODE_ENV === 'production' ? - : - } -
- ); + if (iState === 'paying') { + return (<> + + +
+ {process.env.NODE_ENV === 'production' ? + : + } +
+ ); + } + break; } } return null; diff --git a/es/features/Pay.d.ts b/es/features/Pay.d.ts index d7cb8b7a..d65f4c71 100644 --- a/es/features/Pay.d.ts +++ b/es/features/Pay.d.ts @@ -5,5 +5,5 @@ export default class Pay extends Feature { private application; constructor(application: GeneralFeatures['application']); getPayChannels(): string[]; - getPayConfigs(): (import("../types/PayConfig").WechatPayConfig | import("../types/PayConfig").AccountPayConfig | import("../types/PayConfig").OfflinePayConfig)[]; + getPayConfigs(): (import("../types/PayConfig").OfflinePayConfig | import("../types/PayConfig").WechatPayConfig | import("../types/PayConfig").AccountPayConfig)[]; } diff --git a/src/components/pay/detail/web.pc.tsx b/src/components/pay/detail/web.pc.tsx index db9fad77..2d3a7544 100644 --- a/src/components/pay/detail/web.pc.tsx +++ b/src/components/pay/detail/web.pc.tsx @@ -3,7 +3,6 @@ import { Input, Space, Tag, Card, QRCode, Form, Descriptions, Typography, Alert, import { RowWithActions, WebComponentProps } from 'oak-frontend-base'; import { EntityDict } from '@project/oak-app-domain'; import { CentToString } from 'oak-domain/lib/utils/money'; -import { Detail } from '../../AbstractComponents'; import Styles from './web.pc.module.less'; import classNames from 'classnames'; import * as dayJs from 'dayjs';