Commit 22320dc2 by 姜雷

限制密码输入

parent db9e2f7b
...@@ -3,5 +3,6 @@ export const APP_ID = 'wxf5912b79bba23663'; ...@@ -3,5 +3,6 @@ export const APP_ID = 'wxf5912b79bba23663';
export const BASE_SERVER_URL = 'https://ex-test-dcxy-base-app.168cad.top'; export const BASE_SERVER_URL = 'https://ex-test-dcxy-base-app.168cad.top';
export const CUSTOMER_SERVER_URL = export const CUSTOMER_SERVER_URL =
'https://ex-test-dcxy-customer-app.168cad.top'; 'https://ex-test-dcxy-customer-app.168cad.top';
export const SCHOOL_MAIN_URL = 'https://internal-test-school-main.168cad.top'; export const SCHOOL_MAIN_URL =
'https://internal-test-school-home-bg.168cad.top';
export const ANN_LINK_URL = 'https://ex-test-wx.168cad.top/announcement/'; export const ANN_LINK_URL = 'https://ex-test-wx.168cad.top/announcement/';
...@@ -17,6 +17,7 @@ import agreeNotIcon from '../../images/login/icon_zhuce_nor@2x.png'; ...@@ -17,6 +17,7 @@ import agreeNotIcon from '../../images/login/icon_zhuce_nor@2x.png';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo'; import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import { wxUserRegister } from '../../api/customer'; import { wxUserRegister } from '../../api/customer';
import { replaceIllegalPwd } from '../../utils/pwd';
type PageStateProps = { type PageStateProps = {
userinfo: UserState; userinfo: UserState;
...@@ -79,6 +80,14 @@ class Register extends Component { ...@@ -79,6 +80,14 @@ class Register extends Component {
}); });
} }
setPwdValue(key: string, value: string) {
let val = replaceIllegalPwd(value);
this.setState({
[key]: val,
});
return val;
}
validateRegisterEntity(): boolean { validateRegisterEntity(): boolean {
const { name, cellphone, pwd, checkPwd } = this.state; const { name, cellphone, pwd, checkPwd } = this.state;
const { const {
...@@ -290,12 +299,9 @@ class Register extends Component { ...@@ -290,12 +299,9 @@ class Register extends Component {
placeholder='密码由6-20位组成' placeholder='密码由6-20位组成'
maxLength={20} maxLength={20}
value={pwd} value={pwd}
onInput={({ detail: { value } }) => { onInput={({ detail: { value } }) =>
this.setState({ this.setPwdValue('pwd', value)
pwd: value, }
});
return value;
}}
/> />
<Image <Image
className='registerBox-pwdIcon' className='registerBox-pwdIcon'
...@@ -311,12 +317,9 @@ class Register extends Component { ...@@ -311,12 +317,9 @@ class Register extends Component {
placeholder='确认密码' placeholder='确认密码'
maxLength={20} maxLength={20}
value={checkPwd} value={checkPwd}
onInput={({ detail: { value } }) => { onInput={({ detail: { value } }) =>
this.setState({ this.setPwdValue('checkPwd', value)
checkPwd: value, }
});
return value;
}}
/> />
<Image <Image
className='registerBox-pwdIcon' className='registerBox-pwdIcon'
......
...@@ -8,6 +8,7 @@ import ToastBox from '../../components/ToastBox/ToastBox'; ...@@ -8,6 +8,7 @@ import ToastBox from '../../components/ToastBox/ToastBox';
import './ResetPwd.scss'; import './ResetPwd.scss';
import { changePwdByCellphone } from '../../api/customer'; import { changePwdByCellphone } from '../../api/customer';
import { replaceIllegalPwd } from '../../utils/pwd';
type PageOwnProps = {}; type PageOwnProps = {};
type PageState = { type PageState = {
...@@ -40,6 +41,14 @@ class ResetPwd extends Component { ...@@ -40,6 +41,14 @@ class ResetPwd extends Component {
}; };
} }
setPwdValue(key: string, value: string) {
let val = replaceIllegalPwd(value);
this.setState({
[key]: val,
});
return val;
}
togglePwdBox() { togglePwdBox() {
this.setState(({ showPwd }: PageState) => ({ this.setState(({ showPwd }: PageState) => ({
showPwd: !showPwd, showPwd: !showPwd,
...@@ -169,12 +178,9 @@ class ResetPwd extends Component { ...@@ -169,12 +178,9 @@ class ResetPwd extends Component {
placeholder='输入6-20位新密码' placeholder='输入6-20位新密码'
maxLength={20} maxLength={20}
value={pwd} value={pwd}
onInput={({ detail: { value } }) => { onInput={({ detail: { value } }) =>
this.setState({ this.setPwdValue('pwd', value)
pwd: value, }
});
return value;
}}
/> />
<Image <Image
className='registerBox-pwdIcon' className='registerBox-pwdIcon'
...@@ -190,12 +196,9 @@ class ResetPwd extends Component { ...@@ -190,12 +196,9 @@ class ResetPwd extends Component {
placeholder='确认6-20位新密码' placeholder='确认6-20位新密码'
maxLength={20} maxLength={20}
value={checkPwd} value={checkPwd}
onInput={({ detail: { value } }) => { onInput={({ detail: { value } }) =>
this.setState({ this.setPwdValue('checkPwd', value)
checkPwd: value, }
});
return value;
}}
/> />
<Image <Image
className='registerBox-pwdIcon' className='registerBox-pwdIcon'
......
export const replaceIllegalPwd = (val: string) =>
val.replace(/[^a-zA-Z0-9]+/g, '');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment