Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
isZhNum() {
if (!this.hanzi.length) {
this.$swal({
type: 'error',
title: '转换失败',
text: `ERROR: 你还没有输入`
});
return;
}
const regexlower = /^负?[零一二三四五六七八九十百千万亿]*点?[零一二三四五六七八九]*$/g;
const regexupper = /^负?[零壹贰叁肆伍陆柒捌玖拾佰仟万亿]*点?[零壹贰叁肆伍陆柒捌玖]*$/g;
if (regexlower.test(this.hanzi)) {
this.numResult = Nzh.cn.decodeS(this.hanzi);
} else if (regexupper.test(this.hanzi)) {
this.numResult = Nzh.cn.decodeB(this.hanzi);
} else {
this.$swal({
type: 'error',
title: '转换失败',
text: `ERROR: 请输入正确的大小写中文数字`
});
return;
}
}
}
import React, { Component } from 'react'
import { InputItem } from '@sishuguojixuefu/antd-mobile-rn'
import { View, Text, StyleSheet } from 'react-native'
import stringWidth from 'string-width'
import nzh from 'nzh'
import omit from 'lodash.omit'
import { SsAmountProps } from '../utils/PropTypes'
import getFieldDecorator from '../utils/getFieldDecorator'
import Label from './helper/Label'
import ErrorTip from './helper/ErrorTip'
const nzhCn = nzh.cn
export default class SsAmount extends Component {
private fieldDecorator: any
private chineseAmount = ''
static defaultProps = {
required: false,
placeholder: '请输入',
textAlign: 'right',
upper: true,
}
componentWillMount() {
const { form, id, initialValue, rules } = this.props
const defaultStrValue = initialValue && initialValue.toString()
this._getChineseAmount(defaultStrValue)
this.fieldDecorator = getFieldDecorator(form, id, defaultStrValue, rules ? [...rules, 'money'] : ['money'])
hans() {
const nzhcn = Nzh.cn;
const nzhhk = Nzh.hk;
let n = this.number;
let data = [
{
lang: 'cn',
data: [
{
name: '中文小写',
encode: [
nzhcn.encodeS(n),
nzhcn.encodeS(n, { tenMin: false })
]
},
{
name: '中文大写',
encode: [