Commit d698ac3f authored by 周宏民's avatar 周宏民

feat: 修改登录验证码

parent 0e5eecd5
Pipeline #94701 passed with stages
...@@ -21,6 +21,9 @@ export const API = { ...@@ -21,6 +21,9 @@ export const API = {
SEND_MESSAGE_CODE: 'CityInterface/rest/services/portal.svc/SendMessVerificationCode', // 获取验证码 前端校验 SEND_MESSAGE_CODE: 'CityInterface/rest/services/portal.svc/SendMessVerificationCode', // 获取验证码 前端校验
GetAliyunSMSVerificationCodeHasWay: '/PandaCore/Identity/GetAliyunSMSVerificationCode', // 获取验证码 走网关 GetAliyunSMSVerificationCodeHasWay: '/PandaCore/Identity/GetAliyunSMSVerificationCode', // 获取验证码 走网关
GetAliyunSMSVerificationCode: 'PandaCore/GCK/BussinessAuth/GetAliyunSMSVerificationCode', // 获取验证码 不走网关 GetAliyunSMSVerificationCode: 'PandaCore/GCK/BussinessAuth/GetAliyunSMSVerificationCode', // 获取验证码 不走网关
GetSMSVerificationCodeHasWay: '/PandaCore/Identity/GetSMSVerificationCode', // 获取验证码 走网关 通用(client必传)
GetSMSVerificationCode: 'PandaCore/GCK/BussinessAuth/GetSMSVerificationCode', // 获取验证码 不走网关 通用(client必传)
CHANGE_PASSWORD: 'cityinterface/rest/services.svc/changepassword', CHANGE_PASSWORD: 'cityinterface/rest/services.svc/changepassword',
CHANGE_PASSWORD_SAFE: '/PandaOMS/OMS/UserCenter/UpdateUserPassword', CHANGE_PASSWORD_SAFE: '/PandaOMS/OMS/UserCenter/UpdateUserPassword',
HD_AUTH_LOGIN: '/PandaCore/GCK/BussinessAuth/HDAuthLogin', HD_AUTH_LOGIN: '/PandaCore/GCK/BussinessAuth/HDAuthLogin',
...@@ -189,6 +192,16 @@ const services = { ...@@ -189,6 +192,16 @@ const services = {
method: constants.REQUEST_METHOD_GET, method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP, type: constants.REQUEST_HTTP,
}, },
GetSMSVerificationCodeHasWay: {
url: API.GetSMSVerificationCodeHasWay,
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
GetSMSVerificationCode: {
url: API.GetSMSVerificationCode,
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
updateAvatar: { updateAvatar: {
url: API.UPDATE_AVATAR, url: API.UPDATE_AVATAR,
method: constants.REQUEST_METHOD_GET, method: constants.REQUEST_METHOD_GET,
......
...@@ -97,7 +97,10 @@ const appReducer = (state = initialState, action) => { ...@@ -97,7 +97,10 @@ const appReducer = (state = initialState, action) => {
// 验证码配置 站点设置里配置 只针对该站点 // 验证码配置 站点设置里配置 只针对该站点
temp.isVerificationCode = action.data.VerificationConfig?.IsVerificationCode || false; temp.isVerificationCode = action.data.VerificationConfig?.IsVerificationCode || false;
temp.verificationCodeTimeOut = action.data.VerificationConfig?.VerificationCodeTimeOut || 1; temp.verificationCodeTimeOut = action.data.VerificationConfig?.VerificationCodeTimeOut || 1;
temp.verificationCodeType = action.data.VerificationConfig?.VerificationCodeType || ''; temp.verificationCodeType = temp.isVerificationCode
? action.data.VerificationConfig?.VerificationCodeType || ''
: '';
// temp.isVerificationCode 为false 时,不能用短信验证码
window.globalConfig = temp; window.globalConfig = temp;
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
...@@ -279,9 +282,9 @@ const appReducer = (state = initialState, action) => { ...@@ -279,9 +282,9 @@ const appReducer = (state = initialState, action) => {
pdView: action.data, pdView: action.data,
}); });
case CONFIG_INTEGRATED: case CONFIG_INTEGRATED:
localStorage.setItem('integrationConfig',action.data ? JSON.stringify(action.data) : ''); localStorage.setItem('integrationConfig', action.data ? JSON.stringify(action.data) : '');
return state.merge({ return state.merge({
integratedConfig: fromJS(action.data || {}) integratedConfig: fromJS(action.data || {}),
}); });
default: default:
return state; return state;
......
...@@ -38,7 +38,7 @@ const ValidateCode = props => { ...@@ -38,7 +38,7 @@ const ValidateCode = props => {
const codeUrl = window?.globalConfig?.hasGateWay const codeUrl = window?.globalConfig?.hasGateWay
? '/PandaCore/Identity/GetVerificationCode' ? '/PandaCore/Identity/GetVerificationCode'
: '/PandaCore/GCK/BussinessAuth/GetVerificationCode'; : '/PandaCore/GCK/BussinessAuth/GetVerificationCode';
const client = window?.globalConfig?.client || 'city';
const verificationCodeTimeOut = (window?.globalConfig?.verificationCodeTimeOut || 1) * 60; const verificationCodeTimeOut = (window?.globalConfig?.verificationCodeTimeOut || 1) * 60;
const onTimeOver = () => { const onTimeOver = () => {
console.log('超时了'); console.log('超时了');
...@@ -108,7 +108,7 @@ const ValidateCode = props => { ...@@ -108,7 +108,7 @@ const ValidateCode = props => {
<img className={styles.validate_invalid} src={invalidIcon} height={35} alt="" /> <img className={styles.validate_invalid} src={invalidIcon} height={35} alt="" />
</> </>
) : ( ) : (
<img src={`${codeUrl}?time=${count}`} alt="" /> <img src={`${codeUrl}?time=${count}&client=${client}`} alt="" />
)} )}
<div className={styles.validate_refresh} onClick={handeRefresh}> <div className={styles.validate_refresh} onClick={handeRefresh}>
...@@ -120,7 +120,7 @@ const ValidateCode = props => { ...@@ -120,7 +120,7 @@ const ValidateCode = props => {
}; };
const LoginItem = props => { const LoginItem = props => {
const { isVerificationCode, verificationCodeType, verificationCodeTimeOut } = window.globalConfig; const { client, isVerificationCode, verificationCodeType, verificationCodeTimeOut } = window.globalConfig;
const [count, setCount] = useState(props.countDown || (verificationCodeTimeOut || 1) * 60); const [count, setCount] = useState(props.countDown || (verificationCodeTimeOut || 1) * 60);
const [timing, setTiming] = useState(false); const [timing, setTiming] = useState(false);
const [ext, setExt] = useState(''); const [ext, setExt] = useState('');
...@@ -179,7 +179,46 @@ const LoginItem = props => { ...@@ -179,7 +179,46 @@ const LoginItem = props => {
}); });
} }
}, []); }, []);
const onGetPhoneCaptcha = useCallback(mobile => {
// eslint-disable-next-line no-undef
if (window.globalConfig?.hasGateWay) {
// 开户网关
appService
.GetSMSVerificationCodeHasWay({
phoneNumber: mobile,
ignoreSite: true,
cacheBust: true,
client,
})
.then(res => {
if (res) {
setExt(res.ext);
setTiming(true);
}
})
.catch(error => {
message.error(intl.formatMessage({ id: 'pages.login.phoneLogin.errorCodeMessage' }));
});
} else {
// 不开网关
appService
.GetSMSVerificationCode({
phoneNumber: mobile,
ignoreSite: true,
cacheBust: true,
client,
})
.then(res => {
if (res) {
setExt(res.ext);
setTiming(true);
}
})
.catch(error => {
message.error(intl.formatMessage({ id: 'pages.login.phoneLogin.errorCodeMessage' }));
});
}
}, []);
useEffect(() => { useEffect(() => {
let interval = 0; let interval = 0;
...@@ -263,7 +302,7 @@ const LoginItem = props => { ...@@ -263,7 +302,7 @@ const LoginItem = props => {
if (type === 'Validate') { if (type === 'Validate') {
// 短信验证码 // 短信验证码
if (verificationCodeType === '阿里云短信验证码') { if (verificationCodeType && verificationCodeType !== '图片验证码') {
const inputProps = omit(otherProps, ['onGetCaptcha', 'countDown']); const inputProps = omit(otherProps, ['onGetCaptcha', 'countDown']);
return ( return (
<> <>
...@@ -284,7 +323,7 @@ const LoginItem = props => { ...@@ -284,7 +323,7 @@ const LoginItem = props => {
onClick={() => { onClick={() => {
validateFields(['mobile']) validateFields(['mobile'])
.then(values => { .then(values => {
onGetCaptcha(values.mobile); onGetPhoneCaptcha(values.mobile);
}) })
.catch(error => { .catch(error => {
Logger.log(error); Logger.log(error);
......
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