From 4e7da95284bf1cc9f70ad296af2682f9d9b8de65 Mon Sep 17 00:00:00 2001 From: Xc Date: Fri, 17 May 2024 13:55:48 +0800 Subject: [PATCH] =?UTF-8?q?account/deposit=E7=9A=84=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/components/AbstractComponents.d.ts | 4 ++-- es/components/account/deposit/index.d.ts | 1 + es/components/account/deposit/index.js | 10 ++++++---- es/components/account/deposit/index.xml | 3 +++ es/components/account/deposit/web.d.ts | 1 + es/components/account/deposit/web.js | 10 +++++----- es/components/account/deposit/web.pc.d.ts | 1 + es/components/account/deposit/web.pc.js | 14 ++++++++------ .../account/deposit/web.pc.module.less | 3 +++ es/components/account/detail/index.js | 18 ++++++++++++++++-- .../account/detail/locales/zh-CN.json | 6 +++++- es/data/i18n.js | 6 +++++- lib/data/i18n.js | 6 +++++- src/components/account/deposit/index.ts | 1 + src/components/account/deposit/index.xml | 3 +++ .../account/deposit/web.pc.module.less | 3 +++ src/components/account/deposit/web.pc.tsx | 10 +++++++--- src/components/account/deposit/web.tsx | 7 +++++-- src/data/i18n.ts | 6 +++++- 19 files changed, 85 insertions(+), 28 deletions(-) diff --git a/es/components/AbstractComponents.d.ts b/es/components/AbstractComponents.d.ts index ab5bd062..ee7121a6 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" | "large" | "middle" | undefined; + size?: "small" | "middle" | "large" | undefined; scroll?: any; locale?: any; }) => React.ReactElement; diff --git a/es/components/account/deposit/index.d.ts b/es/components/account/deposit/index.d.ts index ef42a4b3..b0dd6f93 100644 --- a/es/components/account/deposit/index.d.ts +++ b/es/components/account/deposit/index.d.ts @@ -1,4 +1,5 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps void; diff --git a/es/components/account/deposit/index.js b/es/components/account/deposit/index.js index 2684fb33..ba0e98b5 100644 --- a/es/components/account/deposit/index.js +++ b/es/components/account/deposit/index.js @@ -2,6 +2,7 @@ import { ToCent, ToYuan } from 'oak-domain/lib/utils/money'; import { PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_OFFLINE_NAME } from '../../../types/PayConfig'; export default OakComponent({ properties: { + tips: '', depositMinCent: 0, depositMaxCent: 1000000, onSetPrice: (price) => undefined, @@ -39,19 +40,19 @@ export default OakComponent({ }, methods: { onPriceChange(price2) { - const { depositMaxCent, depositMinCent } = this.props; if (price2 === null) { this.props.onSetPrice(price2); this.setState({ price: price2, + priceStr: '', }); } else { - let price = Math.min(depositMaxCent, ToCent(price2)); - price = Math.max(depositMinCent || 0, price); + let price = ToCent(price2); this.props.onSetPrice(price); this.setState({ price, + priceStr: ToYuan(price), }); } }, @@ -72,12 +73,13 @@ export default OakComponent({ onChannelPickMp(channel) { this.props.onSetChannel(channel); }, onMetaSetMp(meta) { this.props.onSetMeta(meta); }, price: 0, + priceStr: '', }, lifetimes: { ready() { const { depositMinCent } = this.props; if (depositMinCent) { - this.onPriceChange(depositMinCent); + this.onPriceChange(ToYuan(depositMinCent)); } } } diff --git a/es/components/account/deposit/index.xml b/es/components/account/deposit/index.xml index 4a325e13..2b3d8475 100644 --- a/es/components/account/deposit/index.xml +++ b/es/components/account/deposit/index.xml @@ -1,5 +1,8 @@ + + {{tips}} + void; }>): React.JSX.Element | null; diff --git a/es/components/account/deposit/web.js b/es/components/account/deposit/web.js index 5d49d966..9b9a448b 100644 --- a/es/components/account/deposit/web.js +++ b/es/components/account/deposit/web.js @@ -1,21 +1,21 @@ import React from 'react'; import ChannelPicker from '../../pay/channelPicker'; -import { Form, Input } from 'antd-mobile'; -import { ToCent } from 'oak-domain/lib/utils/money'; +import { Form, Input, NoticeBar } from 'antd-mobile'; export default function Render(props) { - const { depositMax, payConfig, depositMin, price, channel, meta, priceStr, onSetChannel, onSetMeta } = props.data; + const { depositMax, payConfig, tips, price, channel, meta, priceStr, onSetChannel, onSetMeta } = props.data; const { t, onPriceChange } = props.methods; if (payConfig) { return (
+ {tips && } {t("label.depPrice")}:} extra={t('common::pay.symbol')}> - { + { if (value === '' || value === null) { onPriceChange(null); return; } const v = parseInt(value); if (!isNaN(v)) { - onPriceChange(ToCent(v)); + onPriceChange(v); } }}/> diff --git a/es/components/account/deposit/web.pc.d.ts b/es/components/account/deposit/web.pc.d.ts index a5c1d4dd..4816374a 100644 --- a/es/components/account/deposit/web.pc.d.ts +++ b/es/components/account/deposit/web.pc.d.ts @@ -12,6 +12,7 @@ export default function Render(props: WebComponentProps void; }>): React.JSX.Element | null; diff --git a/es/components/account/deposit/web.pc.js b/es/components/account/deposit/web.pc.js index a1fb8ad0..158df432 100644 --- a/es/components/account/deposit/web.pc.js +++ b/es/components/account/deposit/web.pc.js @@ -1,15 +1,17 @@ import React from 'react'; -import { Form, InputNumber } from 'antd'; +import { Form, InputNumber, Alert } from 'antd'; import ChannelPicker from '../../pay/channelPicker'; -import { ToYuan, ToCent } from 'oak-domain/lib/utils/money'; +import { ToYuan } from 'oak-domain/lib/utils/money'; +import Styles from './web.pc.module.less'; export default function Render(props) { - const { depositMax, payConfig, price, channel, meta, depositMin, onSetChannel, onSetMeta } = props.data; + const { depositMax, payConfig, price, channel, meta, tips, onSetChannel, onSetMeta } = props.data; const { t, onPriceChange } = props.methods; if (payConfig) { - return ( + return ( + {tips && } {t("label.depPrice")}:}> - { - onPriceChange(typeof value === 'number' ? ToCent(value) : null); + { + onPriceChange(value); }}/> {price > 0 ? diff --git a/es/components/account/deposit/web.pc.module.less b/es/components/account/deposit/web.pc.module.less index e69de29b..5a5abdb2 100644 --- a/es/components/account/deposit/web.pc.module.less +++ b/es/components/account/deposit/web.pc.module.less @@ -0,0 +1,3 @@ +.tips { + margin-bottom: 4px; +} \ No newline at end of file diff --git a/es/components/account/detail/index.js b/es/components/account/detail/index.js index 7490054c..7beeaf8a 100644 --- a/es/components/account/detail/index.js +++ b/es/components/account/detail/index.js @@ -1,4 +1,4 @@ -import { CentToString } from "oak-domain/lib/utils/money"; +import { CentToString, ToYuan } from "oak-domain/lib/utils/money"; import { generateNewIdAsync } from "oak-domain/lib/utils/uuid"; import assert from 'assert'; import { DATA_SUBSCRIBER_KEYS } from "../../../config/constants"; @@ -67,7 +67,21 @@ export default OakComponent({ async createDepositPay() { const { depPrice, depositChannel, depositMeta } = this.state; const payId = await generateNewIdAsync(); - const { oakId } = this.props; + const { oakId, depositMaxCent, depositMinCent } = this.props; + if (depPrice > depositMaxCent) { + this.setMessage({ + type: 'error', + content: this.t('error.maxOverflow', { value: ToYuan(depositMaxCent) }), + }); + return; + } + else if (depPrice < depositMinCent) { + this.setMessage({ + type: 'error', + content: this.t('error.minOverflow', { value: ToYuan(depositMinCent) }), + }); + return; + } this.setDepositing(true); try { await this.execute(undefined, undefined, undefined, [ diff --git a/es/components/account/detail/locales/zh-CN.json b/es/components/account/detail/locales/zh-CN.json index 76b6ec42..efa908e9 100644 --- a/es/components/account/detail/locales/zh-CN.json +++ b/es/components/account/detail/locales/zh-CN.json @@ -12,5 +12,9 @@ "content": "您有未支付的充值,请先完成支付", "go": "前往支付" }, - "history": "账单:" + "history": "账单:", + "error": { + "maxOverflow": "充值金额不得高于%{value}元", + "minOverflow": "充值金额不得低于%{value}元" + } } diff --git a/es/data/i18n.js b/es/data/i18n.js index a86db8ca..5896c2e2 100644 --- a/es/data/i18n.js +++ b/es/data/i18n.js @@ -34,7 +34,11 @@ const i18ns = [ "content": "您有未支付的充值,请先完成支付", "go": "前往支付" }, - "history": "账单:" + "history": "账单:", + "error": { + "maxOverflow": "充值金额不得高于%{value}元", + "minOverflow": "充值金额不得低于%{value}元" + } } }, { diff --git a/lib/data/i18n.js b/lib/data/i18n.js index b6a02f6a..3bd43efe 100644 --- a/lib/data/i18n.js +++ b/lib/data/i18n.js @@ -36,7 +36,11 @@ const i18ns = [ "content": "您有未支付的充值,请先完成支付", "go": "前往支付" }, - "history": "账单:" + "history": "账单:", + "error": { + "maxOverflow": "充值金额不得高于%{value}元", + "minOverflow": "充值金额不得低于%{value}元" + } } }, { diff --git a/src/components/account/deposit/index.ts b/src/components/account/deposit/index.ts index b53ab2d9..a3bd96ac 100644 --- a/src/components/account/deposit/index.ts +++ b/src/components/account/deposit/index.ts @@ -3,6 +3,7 @@ import { AccountPayConfig, OfflinePayConfig, PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_OFFLINE_NAME } from '../../../types/PayConfig'; export default OakComponent({ properties: { + tips: '', depositMinCent: 0, depositMaxCent: 1000000, onSetPrice: (price: null | number) => undefined as void, diff --git a/src/components/account/deposit/index.xml b/src/components/account/deposit/index.xml index 4a325e13..2b3d8475 100644 --- a/src/components/account/deposit/index.xml +++ b/src/components/account/deposit/index.xml @@ -1,5 +1,8 @@ + + {{tips}} + void; }>) { - const { depositMax, payConfig, price, channel, meta, depositMin, + const { depositMax, payConfig, price, channel, meta, tips, onSetChannel, onSetMeta } = props.data; const { t, onPriceChange } = props.methods; @@ -30,11 +32,13 @@ export default function Render(props: WebComponentProps + {tips && } {t("label.depPrice")}:}> void; }>) { - const { depositMax, payConfig, depositMin, + const { depositMax, payConfig, tips, price, channel, meta, priceStr, onSetChannel, onSetMeta } = props.data; const { t, onPriceChange } = props.methods; @@ -31,11 +32,13 @@ export default function Render(props: WebComponentProps + {tips && } {t("label.depPrice")}:} extra={t('common::pay.symbol')} >