From 553c13a647f3fa960f85a91994afac7c989bcaae Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Tue, 6 Aug 2019 10:33:58 +0800 Subject: [PATCH] length --- .../src/modules/user/account/AccountBasicEdit.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/public/react/src/modules/user/account/AccountBasicEdit.js b/public/react/src/modules/user/account/AccountBasicEdit.js index ed55942c0..d2e5b0670 100644 --- a/public/react/src/modules/user/account/AccountBasicEdit.js +++ b/public/react/src/modules/user/account/AccountBasicEdit.js @@ -18,6 +18,8 @@ export function getHiddenName(name) { const newName = name.substr(0,1)+str; return newName } +const MAX_NAME_LENGTH = 10 +const MAX_NICKNAME_LENGTH = 20 class AccountBasic extends Component { constructor(props){ super(props); @@ -126,7 +128,7 @@ class AccountBasic extends Component { // 输入昵称时change剩余的字数 changeNickName=(e)=>{ - let num= 30 - parseInt(e.target.value.length); + let num= MAX_NICKNAME_LENGTH - parseInt(e.target.value.length); this.setState({ nameLength:num < 0 ? 0 : num }) @@ -394,11 +396,11 @@ class AccountBasic extends Component { } } checkNameLength = (rule, value, callback) => { - if (value && value.length <= 30) { + if (value && value.length <= MAX_NAME_LENGTH) { callback(); return; } - callback('请输入真实姓名,最大限制30个字符'); + callback(`请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`); } render() { @@ -498,8 +500,8 @@ class AccountBasic extends Component { message: '请输入您的昵称', }], })( - {String(nameLength)}/30 + {String(nameLength)}/{MAX_NICKNAME_LENGTH} }> )} @@ -512,11 +514,11 @@ class AccountBasic extends Component { rules: [{ // initialValue: this.state.cityDefaultValue, required: true, - message: '请输入真实姓名,最大限制30个字符', + message: `请输入真实姓名,最大限制${MAX_NAME_LENGTH}个字符`, validator: this.checkNameLength }], })( - this.showOrHide(showRealName)}> }>