dev_hjm
hjm 6 years ago
parent c414beaa5b
commit 553c13a647

@ -18,6 +18,8 @@ export function getHiddenName(name) {
const newName = name.substr(0,1)+str; const newName = name.substr(0,1)+str;
return newName return newName
} }
const MAX_NAME_LENGTH = 10
const MAX_NICKNAME_LENGTH = 20
class AccountBasic extends Component { class AccountBasic extends Component {
constructor(props){ constructor(props){
super(props); super(props);
@ -126,7 +128,7 @@ class AccountBasic extends Component {
// 输入昵称时change剩余的字数 // 输入昵称时change剩余的字数
changeNickName=(e)=>{ changeNickName=(e)=>{
let num= 30 - parseInt(e.target.value.length); let num= MAX_NICKNAME_LENGTH - parseInt(e.target.value.length);
this.setState({ this.setState({
nameLength:num < 0 ? 0 : num nameLength:num < 0 ? 0 : num
}) })
@ -394,11 +396,11 @@ class AccountBasic extends Component {
} }
} }
checkNameLength = (rule, value, callback) => { checkNameLength = (rule, value, callback) => {
if (value && value.length <= 30) { if (value && value.length <= MAX_NAME_LENGTH) {
callback(); callback();
return; return;
} }
callback('请输入真实姓名最大限制30个字符'); callback(`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`);
} }
render() { render() {
@ -498,8 +500,8 @@ class AccountBasic extends Component {
message: '请输入您的昵称', message: '请输入您的昵称',
}], }],
})( })(
<Input placeholder="请输入您的昵称最大限制30个字符" onInput={this.changeNickName} maxLength="30" suffix ={ <Input placeholder={`请输入您的昵称,最大限制${MAX_NICKNAME_LENGTH}个字符`} onInput={this.changeNickName} maxLength={MAX_NICKNAME_LENGTH} suffix ={
<span className="color-grey-6 font-13">{String(nameLength)}/30</span> <span className="color-grey-6 font-13">{String(nameLength)}/{MAX_NICKNAME_LENGTH}</span>
}></Input> }></Input>
)} )}
</Form.Item> </Form.Item>
@ -512,11 +514,11 @@ class AccountBasic extends Component {
rules: [{ rules: [{
// initialValue: this.state.cityDefaultValue, // initialValue: this.state.cityDefaultValue,
required: true, required: true,
message: '请输入真实姓名最大限制30个字符', message: `请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`,
validator: this.checkNameLength validator: this.checkNameLength
}], }],
})( })(
<Input placeholder="请输入真实姓名最大限制30个字符" disabled={!showRealName && this.state.forDisable == true } suffix={ <Input placeholder={`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`} disabled={!showRealName && this.state.forDisable == true } suffix={
<i className={showRealName?"iconfont icon-xianshi font-18 color-blue":"iconfont icon-yincang font-18 color-blue"} <i className={showRealName?"iconfont icon-xianshi font-18 color-blue":"iconfont icon-yincang font-18 color-blue"}
onClick={()=>this.showOrHide(showRealName)}></i> onClick={()=>this.showOrHide(showRealName)}></i>
}></Input> }></Input>

Loading…
Cancel
Save