Reset label

This commit is contained in:
saplf
2019-09-09 15:04:03 +08:00
parent 5c324a7863
commit 37d19c5e87
3 changed files with 14 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ import Header from '@/components/Header';
import styles from './style.less'; import styles from './style.less';
import h5plus from '@/utils/h5plus'; import h5plus from '@/utils/h5plus';
import { displayLabel } from '@/utils/transform';
const Option = Select.Option; const Option = Select.Option;
@@ -44,7 +45,7 @@ const DrawPage: React.FC<DispatchProp & DrawModelState> = ({
<div className={styles.none}>{formatMessage({ id: 'common.loadError' })}</div> <div className={styles.none}>{formatMessage({ id: 'common.loadError' })}</div>
); );
} else if (pageState === PageState.Success) { } else if (pageState === PageState.Success) {
const coinLabel = coin && coin.label.toUpperCase(); const coinLabel = displayLabel(coin && coin.label);
const onScan = async () => { const onScan = async () => {
if (h5plus.isApp()) { if (h5plus.isApp()) {
const result = await h5plus.scan(); const result = await h5plus.scan();
@@ -99,7 +100,7 @@ const DrawPage: React.FC<DispatchProp & DrawModelState> = ({
<Option <Option
key={it.id} key={it.id}
value={it.id} value={it.id}
>{(it.label || '').toUpperCase()}</Option> >{displayLabel(it.label)}</Option>
))} ))}
</Select> </Select>
</div> </div>

View File

@@ -14,6 +14,7 @@ import { PageState } from '@/types/common';
import Header from '@/components/Header'; import Header from '@/components/Header';
import styles from './style.less'; import styles from './style.less';
import { displayLabel } from '@/utils/transform';
const Option = Select.Option; const Option = Select.Option;
@@ -56,7 +57,7 @@ const MinePage: React.FC<DispatchProp & MineModelState> = ({
<Option <Option
key={it.id} key={it.id}
value={it.id} value={it.id}
>{(it.label || '').toUpperCase()}</Option> >{displayLabel(it.label)}</Option>
))} ))}
</Select> </Select>
</div> </div>
@@ -67,14 +68,14 @@ const MinePage: React.FC<DispatchProp & MineModelState> = ({
value={srcValue} value={srcValue}
onChange={e => dispatch({ type: 'mine/changeSrc', payload: e.target.value })} onChange={e => dispatch({ type: 'mine/changeSrc', payload: e.target.value })}
type="number" type="number"
/> {coin && coin.label.toUpperCase()} = {dstValue} {formatMessage({ id: 'mine.mine' })} /> {displayLabel(coin && coin.label)} = {dstValue} {formatMessage({ id: 'mine.mine' })}
</div> </div>
</div> </div>
<div <div
className={`${styles.section} ${styles.main}`} className={`${styles.section} ${styles.main}`}
> >
<div>{formatMessage({ id: 'mine.addressTitle' }, { label: coin && coin.label.toUpperCase() })}</div> <div>{formatMessage({ id: 'mine.addressTitle' }, { label: displayLabel(coin && coin.label) })}</div>
<Clipboard <Clipboard
component="div" component="div"
data-clipboard-text={coin && coin.address} data-clipboard-text={coin && coin.address}

View File

@@ -55,3 +55,10 @@ export function displayPhone(phone: string): string {
export function displayTime(time: string | Moment): string { export function displayTime(time: string | Moment): string {
return moment(time).format('YYYY-MM-DD HH:mm'); return moment(time).format('YYYY-MM-DD HH:mm');
} }
export function displayLabel(label?: string | null): string | null | undefined {
if (label && label.toLowerCase().startsWith('usdt')) {
return 'USDT(erc20)';
}
return label;
}