Commit 22320dc2 by 姜雷

限制密码输入

parent db9e2f7b
......@@ -3,5 +3,6 @@ export const APP_ID = 'wxf5912b79bba23663';
export const BASE_SERVER_URL = 'https://ex-test-dcxy-base-app.168cad.top';
export const CUSTOMER_SERVER_URL =
'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/';
......@@ -17,6 +17,7 @@ import agreeNotIcon from '../../images/login/icon_zhuce_nor@2x.png';
import { connect } from '@tarojs/redux';
import { UserState, updateUserInfo } from '../../store/rootReducers/userinfo';
import { wxUserRegister } from '../../api/customer';
import { replaceIllegalPwd } from '../../utils/pwd';
type PageStateProps = {
userinfo: UserState;
......@@ -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 {
const { name, cellphone, pwd, checkPwd } = this.state;
const {
......@@ -290,12 +299,9 @@ class Register extends Component {
placeholder='密码由6-20位组成'
maxLength={20}
value={pwd}
onInput={({ detail: { value } }) => {
this.setState({
pwd: value,
});
return value;
}}
onInput={({ detail: { value } }) =>
this.setPwdValue('pwd', value)
}
/>
<Image
className='registerBox-pwdIcon'
......@@ -311,12 +317,9 @@ class Register extends Component {
placeholder='确认密码'
maxLength={20}
value={checkPwd}
onInput={({ detail: { value } }) => {
this.setState({
checkPwd: value,
});
return value;
}}
onInput={({ detail: { value } }) =>
this.setPwdValue('checkPwd', value)
}
/>
<Image
className='registerBox-pwdIcon'
......
......@@ -8,6 +8,7 @@ import ToastBox from '../../components/ToastBox/ToastBox';
import './ResetPwd.scss';
import { changePwdByCellphone } from '../../api/customer';
import { replaceIllegalPwd } from '../../utils/pwd';
type PageOwnProps = {};
type PageState = {
......@@ -40,6 +41,14 @@ class ResetPwd extends Component {
};
}
setPwdValue(key: string, value: string) {
let val = replaceIllegalPwd(value);
this.setState({
[key]: val,
});
return val;
}
togglePwdBox() {
this.setState(({ showPwd }: PageState) => ({
showPwd: !showPwd,
......@@ -169,12 +178,9 @@ class ResetPwd extends Component {
placeholder='输入6-20位新密码'
maxLength={20}
value={pwd}
onInput={({ detail: { value } }) => {
this.setState({
pwd: value,
});
return value;
}}
onInput={({ detail: { value } }) =>
this.setPwdValue('pwd', value)
}
/>
<Image
className='registerBox-pwdIcon'
......@@ -190,12 +196,9 @@ class ResetPwd extends Component {
placeholder='确认6-20位新密码'
maxLength={20}
value={checkPwd}
onInput={({ detail: { value } }) => {
this.setState({
checkPwd: value,
});
return value;
}}
onInput={({ detail: { value } }) =>
this.setPwdValue('checkPwd', value)
}
/>
<Image
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