account/deposit的一些细节
This commit is contained in:
parent
54b827447b
commit
4e7da95284
|
|
@ -20,7 +20,7 @@ declare const List: <T extends keyof EntityDict>(props: ReactComponentProps<Enti
|
|||
rowSelection?: any;
|
||||
hideHeader?: boolean | undefined;
|
||||
disableSerialNumber?: boolean | undefined;
|
||||
size?: "small" | "large" | "middle" | undefined;
|
||||
size?: "small" | "middle" | "large" | undefined;
|
||||
scroll?: ({
|
||||
x?: string | number | true | undefined;
|
||||
y?: string | number | undefined;
|
||||
|
|
@ -45,7 +45,7 @@ declare const ListPro: <T extends keyof EntityDict>(props: {
|
|||
tablePagination?: any;
|
||||
rowSelection?: any;
|
||||
disableSerialNumber?: boolean | undefined;
|
||||
size?: "small" | "large" | "middle" | undefined;
|
||||
size?: "small" | "middle" | "large" | undefined;
|
||||
scroll?: any;
|
||||
locale?: any;
|
||||
}) => React.ReactElement;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, boolean, {
|
||||
tips: string;
|
||||
depositMinCent: number;
|
||||
depositMaxCent: number;
|
||||
onSetPrice: (price: null | number) => void;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
<view class="container">
|
||||
<l-form>
|
||||
<block wx:if="{{tips}}">
|
||||
<l-notice-bar show="{{true}}">{{tips}}</l-notice-bar>
|
||||
</block>
|
||||
<l-form-item label="{{t('label.depPrice')}}">
|
||||
<l-input
|
||||
hide-label
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'account', f
|
|||
channel: string;
|
||||
meta: any;
|
||||
depositMin: number;
|
||||
tips: string;
|
||||
}, {
|
||||
onPriceChange: (price: null | number) => void;
|
||||
}>): React.JSX.Element | null;
|
||||
|
|
|
|||
|
|
@ -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 (<Form layout="horizontal">
|
||||
{tips && <NoticeBar content={tips} color='info'/>}
|
||||
<Form.Item label={<span>{t("label.depPrice")}:</span>} extra={t('common::pay.symbol')}>
|
||||
<Input type='number' placeholder={t('placeholder', { max: depositMax })} max={depositMax} min={depositMin} value={priceStr} onChange={(value) => {
|
||||
<Input autoFocus type='number' placeholder={t('placeholder', { max: depositMax })} value={priceStr} onChange={(value) => {
|
||||
if (value === '' || value === null) {
|
||||
onPriceChange(null);
|
||||
return;
|
||||
}
|
||||
const v = parseInt(value);
|
||||
if (!isNaN(v)) {
|
||||
onPriceChange(ToCent(v));
|
||||
onPriceChange(v);
|
||||
}
|
||||
}}/>
|
||||
</Form.Item>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ export default function Render(props: WebComponentProps<EntityDict, 'account', f
|
|||
channel: string;
|
||||
meta: any;
|
||||
depositMin: number;
|
||||
tips: string;
|
||||
}, {
|
||||
onPriceChange: (price: null | number) => void;
|
||||
}>): React.JSX.Element | null;
|
||||
|
|
|
|||
|
|
@ -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 (<Form labelCol={{ span: 4 }} wrapperCol={{ span: 14 }} layout="horizontal" style={{ minWidth: 600 }} colon={false}>
|
||||
return (<Form labelCol={{ span: 4 }} wrapperCol={{ span: 14 }} layout="horizontal" style={{ width: '100%' }} colon={false}>
|
||||
{tips && <Alert className={Styles.tips} type="info" message={tips}/>}
|
||||
<Form.Item label={<span>{t("label.depPrice")}:</span>}>
|
||||
<InputNumber placeholder={t('placeholder', { max: depositMax })} max={depositMax} min={depositMin} value={typeof price == 'number' ? ToYuan(price) : null} addonAfter={t('common::pay.symbol')} onChange={(value) => {
|
||||
onPriceChange(typeof value === 'number' ? ToCent(value) : null);
|
||||
<InputNumber autoFocus placeholder={t('placeholder', { max: depositMax })} value={typeof price == 'number' ? ToYuan(price) : null} addonAfter={t('common::pay.symbol')} onChange={(value) => {
|
||||
onPriceChange(value);
|
||||
}}/>
|
||||
</Form.Item>
|
||||
{price > 0 ? <Form.Item label={<span style={{ marginTop: 10 }}>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
.tips {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
|
@ -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, [
|
||||
|
|
|
|||
|
|
@ -12,5 +12,9 @@
|
|||
"content": "您有未支付的充值,请先完成支付",
|
||||
"go": "前往支付"
|
||||
},
|
||||
"history": "账单:"
|
||||
"history": "账单:",
|
||||
"error": {
|
||||
"maxOverflow": "充值金额不得高于%{value}元",
|
||||
"minOverflow": "充值金额不得低于%{value}元"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,11 @@ const i18ns = [
|
|||
"content": "您有未支付的充值,请先完成支付",
|
||||
"go": "前往支付"
|
||||
},
|
||||
"history": "账单:"
|
||||
"history": "账单:",
|
||||
"error": {
|
||||
"maxOverflow": "充值金额不得高于%{value}元",
|
||||
"minOverflow": "充值金额不得低于%{value}元"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,7 +36,11 @@ const i18ns = [
|
|||
"content": "您有未支付的充值,请先完成支付",
|
||||
"go": "前往支付"
|
||||
},
|
||||
"history": "账单:"
|
||||
"history": "账单:",
|
||||
"error": {
|
||||
"maxOverflow": "充值金额不得高于%{value}元",
|
||||
"minOverflow": "充值金额不得低于%{value}元"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
<view class="container">
|
||||
<l-form>
|
||||
<block wx:if="{{tips}}">
|
||||
<l-notice-bar show="{{true}}">{{tips}}</l-notice-bar>
|
||||
</block>
|
||||
<l-form-item label="{{t('label.depPrice')}}">
|
||||
<l-input
|
||||
hide-label
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
.tips {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
import React, { useState } from 'react';
|
||||
import { Form, InputNumber } from 'antd';
|
||||
import { Form, InputNumber, Alert } from 'antd';
|
||||
import { WebComponentProps } from 'oak-frontend-base';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import ChannelPicker from '../../pay/channelPicker';
|
||||
import { AccountPayConfig, PayConfig } from '@project/types/PayConfig';
|
||||
import { ToYuan, ToCent } from 'oak-domain/lib/utils/money';
|
||||
import Styles from './web.pc.module.less';
|
||||
|
||||
|
||||
export default function Render(props: WebComponentProps<EntityDict, 'account', false, {
|
||||
|
|
@ -17,10 +18,11 @@ export default function Render(props: WebComponentProps<EntityDict, 'account', f
|
|||
channel: string;
|
||||
meta: any;
|
||||
depositMin: number;
|
||||
tips: string;
|
||||
}, {
|
||||
onPriceChange: (price: null | number) => 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<EntityDict, 'account', f
|
|||
labelCol={{ span: 4 }}
|
||||
wrapperCol={{ span: 14 }}
|
||||
layout="horizontal"
|
||||
style={{ minWidth: 600 }}
|
||||
style={{ width: '100%' }}
|
||||
colon={false}
|
||||
>
|
||||
{tips && <Alert className={Styles.tips} type="info" message={tips} />}
|
||||
<Form.Item label={<span>{t("label.depPrice")}:</span>}>
|
||||
<InputNumber
|
||||
autoFocus
|
||||
placeholder={t('placeholder', { max: depositMax })}
|
||||
value={typeof price == 'number' ? ToYuan(price) : null}
|
||||
addonAfter={t('common::pay.symbol')}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { WebComponentProps } from 'oak-frontend-base';
|
|||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import ChannelPicker from '../../pay/channelPicker';
|
||||
import { AccountPayConfig, PayConfig } from '@project/types/PayConfig';
|
||||
import { Form, Input } from 'antd-mobile';
|
||||
import { Form, Input, NoticeBar } from 'antd-mobile';
|
||||
import { ToYuan, ToCent } from 'oak-domain/lib/utils/money';
|
||||
|
||||
|
||||
|
|
@ -18,10 +18,11 @@ export default function Render(props: WebComponentProps<EntityDict, 'account', f
|
|||
channel: string;
|
||||
meta: any;
|
||||
depositMin: number;
|
||||
tips: string;
|
||||
}, {
|
||||
onPriceChange: (price: null | number) => 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<EntityDict, 'account', f
|
|||
<Form
|
||||
layout="horizontal"
|
||||
>
|
||||
{tips && <NoticeBar content={tips} color='info' />}
|
||||
<Form.Item
|
||||
label={<span>{t("label.depPrice")}:</span>}
|
||||
extra={t('common::pay.symbol')}
|
||||
>
|
||||
<Input
|
||||
autoFocus
|
||||
type='number'
|
||||
placeholder={t('placeholder', { max: depositMax })}
|
||||
value={priceStr}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,11 @@ const i18ns: I18n[] = [
|
|||
"content": "您有未支付的充值,请先完成支付",
|
||||
"go": "前往支付"
|
||||
},
|
||||
"history": "账单:"
|
||||
"history": "账单:",
|
||||
"error": {
|
||||
"maxOverflow": "充值金额不得高于%{value}元",
|
||||
"minOverflow": "充值金额不得低于%{value}元"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue