Commit da1eaf6f authored by 杨思琦's avatar 杨思琦

fix: 密码框修改

parent cbc336f3
Pipeline #64060 passed with stages
import 'kit_logger';
import React, {
useCallback,
useEffect,
useState,
} from 'react';
import {
Button,
Form,
Input,
message,
} from 'antd';
import React, { useCallback, useEffect, useState } from 'react';
import { Button, Form, Input, message } from 'antd';
import omit from 'omit.js';
import { useIntl } from '@wisdom-utils/components';
......@@ -26,12 +17,7 @@ import ItemMap from './map';
const FormItem = Form.Item;
// eslint-disable-next-line no-undef
const Logger = logger('loginForm');
const getFormItemOptions = ({
onChange,
defaultValue,
customProps = {},
rules,
}) => {
const getFormItemOptions = ({ onChange, defaultValue, customProps = {}, rules }) => {
const options = {
rules: rules || customProps.rules,
};
......@@ -78,7 +64,7 @@ const LoginItem = props => {
}
})
.catch(error => {
message.error(intl.formatMessage({id: 'pages.login.phoneLogin.errorCodeMessage'}));
message.error(intl.formatMessage({ id: 'pages.login.phoneLogin.errorCodeMessage' }));
});
}, []);
......@@ -98,7 +84,7 @@ const LoginItem = props => {
}, 1000);
}
return () => clearInterval(interval);
}, [timing]);
}, [props, timing]);
if (!name) {
return null;
......@@ -114,7 +100,7 @@ const LoginItem = props => {
return Promise.resolve();
}
// eslint-disable-next-line prefer-promise-reject-errors
return Promise.reject(intl.formatMessage({id: 'pages.login.phoneLogin.errorMessage'}));
return Promise.reject(intl.formatMessage({ id: 'pages.login.phoneLogin.errorMessage' }));
};
// eslint-disable-next-line no-shadow
const rules = [
......@@ -126,7 +112,7 @@ const LoginItem = props => {
delete options.rules;
return (
<FormItem shouldUpdate style={{marginBottom: '14px'}}>
<FormItem shouldUpdate style={{ marginBottom: '14px' }}>
{({ getFieldValue, validateFields }) => (
<>
<FormItem name={name} {...options} rules={rules}>
......@@ -147,8 +133,8 @@ const LoginItem = props => {
}}
>
{timing
? `${intl.formatMessage({id: 'pages.login.phoneLogin.sendCationCode'})}(${count})`
: intl.formatMessage({id: 'pages.login.phoneLogin.getVerificationCode'})}
? `${intl.formatMessage({ id: 'pages.login.phoneLogin.sendCationCode' })}(${count})`
: intl.formatMessage({ id: 'pages.login.phoneLogin.getVerificationCode' })}
</Button>
</>
)}
......@@ -156,6 +142,13 @@ const LoginItem = props => {
);
}
if (type === 'Password') {
return (
<FormItem name={name} {...options}>
<Input.Password {...customProps} {...otherProps} />
</FormItem>
);
}
return (
<FormItem name={name} {...options}>
<Input {...customProps} {...otherProps} />
......@@ -169,15 +162,7 @@ Object.keys(ItemMap).forEach(key => {
const item = ItemMap[key];
LoginItems[key] = props => (
<LoginContext.Consumer>
{context => (
<LoginItem
customProps={item.props}
rules={item.rules}
{...props}
type={key}
{...context}
/>
)}
{context => <LoginItem customProps={item.props} rules={item.rules} {...props} type={key} {...context} />}
</LoginContext.Consumer>
);
});
......
......@@ -5,6 +5,8 @@ import {
MailOutlined,
MobileOutlined,
UserOutlined,
EyeInvisibleOutlined,
EyeTwoTone,
} from '@ant-design/icons';
import styles from './index.less';
......@@ -27,9 +29,7 @@ export default {
NewYearPassword: {
props: {
size: 'large',
prefix: (
<LockOutlined className={styles.prefixIcon} twoToneColor="#ff9600" />
),
prefix: <LockOutlined className={styles.prefixIcon} twoToneColor="#ff9600" />,
type: 'password',
id: 'password',
placeholder: '888888',
......@@ -45,6 +45,7 @@ export default {
props: {
size: 'large',
prefix: <LockOutlined className={styles.prefixIcon} />,
iconRender: visible => (visible ? <EyeTwoTone /> : <EyeInvisibleOutlined />),
type: 'password',
id: 'password',
placeholder: '888888',
......@@ -90,9 +91,7 @@ export default {
NewYearMobile: {
props: {
size: 'large',
prefix: (
<MobileOutlined className={styles.prefixIcon} twoToneColor="#ff9600" />
),
prefix: <MobileOutlined className={styles.prefixIcon} twoToneColor="#ff9600" />,
placeholder: 'mobile number',
id: 'mobile',
},
......@@ -110,9 +109,7 @@ export default {
NewYearCaptcha: {
props: {
size: 'large',
prefix: (
<MailOutlined className={styles.prefixIcon} twoToneColor="#ff9600" />
),
prefix: <MailOutlined className={styles.prefixIcon} twoToneColor="#ff9600" />,
placeholder: '请输入短信验证码',
},
rules: [
......
......@@ -511,7 +511,7 @@ class Login {
if (url.indexOf('&code') !== -1) {
// 判断是否存在参数
// eslint-disable-next-line no-useless-escape
url = url.replace(/(\&code|#)[^'"]*/, ''); // 去除参数
url = url.replace(/(\&code|#)[^'"]*/, '&code=success'); // 去除参数
window.history.pushState({}, 0, url);
}
self.isSignIn = true;
......
......@@ -8,10 +8,7 @@ import LoginAction from './login';
import { defaultApp } from '../../../micro';
const Login = forwardRef((props, _ref) => {
const history = useHistory();
const [action, setAction] = useState(
() =>
new LoginAction(Object.assign({}, props, { history }), () => {}, false),
);
const [action, setAction] = useState(() => new LoginAction(Object.assign({}, props, { history }), () => {}, false));
const [redirect] = useState(() => {
const param = params.getParams('redirect')?.replaceAll(';', '&');
return param ? decodeURIComponent(escape(param)) : null;
......@@ -21,11 +18,12 @@ const Login = forwardRef((props, _ref) => {
const hasLogin = useRef();
useEffect(() => {
action.globalConfig = props.global;
// eslint-disable-next-line no-prototype-builtins
if (props.global && props.global.hasOwnProperty('products') && hasLogin.current !== true) {
hasLogin.current = true;
action.init();
}
}, [action.globalConfig, props.global]);
}, [action, action.globalConfig, props.global]);
useEffect(() => {
action &&
......@@ -35,17 +33,15 @@ const Login = forwardRef((props, _ref) => {
// homepage: params.getParams('redirect')
// }));
// props.history.push('/' + params.getParams('redirect'))
props.history.push(
`/?client=${props.global.client}`,
);
props.history.push(`/?client=${props.global.client}`);
// window.share.event.emit('triggerMicro', props.global);
// initMicroApps();
defaultApp(redirect);
});
return () => {
action && action.events && action.events.removeAllListeners('loginSuccess');
}
}, [action, props.global.client, props.global.generateType, props.history]);
return () => {
action && action.events && action.events.removeAllListeners('loginSuccess');
};
}, [action, props.global.client, props.global.generateType, props.history, redirect]);
return <div>{props.children}</div>;
});
......
......@@ -3,12 +3,14 @@ import 'kit_utils/lib/format';
import React, { forwardRef, useEffect, useRef, useState } from 'react';
import { Modal } from 'antd';
// eslint-disable-next-line import/no-unresolved
import classNames from 'classnames';
import { dom } from '@wisdom-utils/utils/lib/helpers';
import { Helmet, HelmetProvider } from 'react-helmet-async';
import { connect } from 'react-redux';
import { useHistory } from '@wisdom-utils/runtime';
import { actionCreators } from '@/containers/App/store';
import Cookies from 'js-cookie';
import defaultSetting from '../../../../../config/defaultSetting';
import LoginAction from '../login';
import styles from '../style.less';
......@@ -32,11 +34,11 @@ const Login = forwardRef((props, _ref) => {
const [type, setType] = useState('Account');
const [visible, setVisible] = useState(false);
const history = useHistory();
const [action, setAction] = useState(
() =>
new LoginAction(Object.assign({}, props, { history }), setVisible, false),
);
const [action, setAction] = useState(() => new LoginAction(Object.assign({}, props, { history }), setVisible, false));
const [showVideo, setShowVideo] = useState(false);
let { ddCode } = props.global;
const loginMode = Cookies.get('loginMode') || null;
if (loginMode && loginMode === 'iotWechat') ddCode = null;
// useEffect(() => {
// action.globalConfig = props.global;
// }, [props.global]);
......@@ -116,22 +118,27 @@ const Login = forwardRef((props, _ref) => {
}, []);
useEffect(() => {
if (videoRef && videoRef.current) {
videoRef.current.addEventListener('ended', function() {
dom.removeClass(loginRef.current, styles.caseHide);
dom.addClass(loginRef.current, styles.loginTimeShow);
videoTimeout = setTimeout(() => {
dom.removeClass(timeRef.current, styles.caseHide);
dom.addClass(timeRef.current, 'animate__fadeIn');
dom.removeClass(loginFormRef.current, styles.caseHide);
dom.addClass(loginFormRef.current, 'animate__fadeInUp');
dom.removeClass(footerRef.current, styles.caseHide);
dom.addClass(footerRef.current, 'animate__slideInUp');
dom.removeClass(titleRef.current, styles.caseHide);
dom.addClass(titleRef.current, 'animte__fadeInUp');
}, 500);
if(ddCode && loginMode === 'qywx') {
setShowVideo(false);
} else {
setShowVideo(true);
setTimeout(() => {
if (videoRef && videoRef.current) {
videoRef.current.addEventListener('ended', function() {
dom.removeClass(loginRef.current, styles.caseHide);
dom.addClass(loginRef.current, styles.loginTimeShow);
videoTimeout = setTimeout(() => {
dom.removeClass(timeRef.current, styles.caseHide);
dom.addClass(timeRef.current, 'animate__fadeIn');
dom.removeClass(loginFormRef.current, styles.caseHide);
dom.addClass(loginFormRef.current, 'animate__fadeInUp');
dom.removeClass(footerRef.current, styles.caseHide);
dom.addClass(footerRef.current, 'animate__slideInUp');
dom.removeClass(titleRef.current, styles.caseHide);
dom.addClass(titleRef.current, 'animte__fadeInUp');
}, 500);
});
}
});
}
......@@ -178,14 +185,14 @@ const Login = forwardRef((props, _ref) => {
<meta name="description" content={props.global.title || defaultSetting.title} />
</Helmet>
<div className={styles.main}>
<video
{showVideo && <video
src={require("../../../../assets/videos/beforPage.mp4") }
className={styles.videLayer}
autoPlay="autoPlay"
muted
playsInline="playsinline"
ref={videoRef}
/>
/>}
<div className={styles.inner}>
<div
className={classNames(styles.loginTime, styles.caseHide)}
......
......@@ -16,7 +16,7 @@ import useRenderQcode from '../../js/useRenderQcode';
import Account from '../../js/useAccount';
import IotComponent from '../../js/useIOTComponent';
import CloudForm from './cloudForm';
import { initMicroApps } from '../../../../../micro';
import { defaultApp } from '../../../../../micro';
import useTime from '../../js/useTime';
const isRQcodeFunc = loginFunc => {
......@@ -25,8 +25,10 @@ const isRQcodeFunc = loginFunc => {
};
const loginFuncImg = loginFunc => {
if (isRQcodeFunc(loginFunc)) {
// eslint-disable-next-line global-require
return require('@/assets/images/login/cloud/func_pwd.png');
}
// eslint-disable-next-line global-require
return require('@/assets/images/login/cloud/func_rqcode.png');
};
......@@ -48,7 +50,10 @@ const Login = forwardRef((props, _ref) => {
const [visible, setVisible] = useState(false);
const history = useHistory();
const [action, setAction] = useState(() => new LoginAction(Object.assign({}, props, { history }), setVisible, true));
const [showVideo, setShowVideo] = useState(false);
let { ddCode } = props.global;
const loginMode = Cookies.get('loginMode') || null;
if (loginMode && loginMode === 'iotWechat') ddCode = null;
const handleSubmit = values => {
/* eslint-disable */
action &&
......@@ -70,7 +75,8 @@ const Login = forwardRef((props, _ref) => {
props.updateCurrentIndex && props.updateCurrentIndex(0);
props.history.push(`/?client=${props.global.client}`);
// window.share.event.emit('triggerMicro', props.global);
initMicroApps();
// initMicroApps();
defaultApp();
});
action &&
action.events.on('loginError', event => {
......@@ -92,28 +98,34 @@ const Login = forwardRef((props, _ref) => {
let videoTimeout = null;
useEffect(() => {
if (videoRef && videoRef.current) {
videoRef.current.addEventListener('ended', function() {
dom.removeClass(loginRef.current, styles.caseHide);
dom.addClass(loginRef.current, styles.loginTimeShow);
videoTimeout = setTimeout(() => {
dom.removeClass(timeRef.current, styles.caseHide);
dom.addClass(timeRef.current, 'animate__fadeIn');
dom.removeClass(loginFormRef.current, styles.caseHide);
dom.addClass(loginFormRef.current, 'animate__fadeInUp');
dom.removeClass(footerRef.current, styles.caseHide);
dom.addClass(footerRef.current, 'animate__slideInUp');
dom.removeClass(titleRef.current, styles.caseHide);
dom.addClass(titleRef.current, 'animte__fadeInUp');
}, 500);
if(ddCode && loginMode === 'qywx') {
setShowVideo(false);
} else {
setShowVideo(true);
setTimeout(() => {
if (videoRef && videoRef.current) {
videoRef.current.addEventListener('ended', function() {
dom.removeClass(loginRef.current, styles.caseHide);
dom.addClass(loginRef.current, styles.loginTimeShow);
videoTimeout = setTimeout(() => {
dom.removeClass(timeRef.current, styles.caseHide);
dom.addClass(timeRef.current, 'animate__fadeIn');
dom.removeClass(loginFormRef.current, styles.caseHide);
dom.addClass(loginFormRef.current, 'animate__fadeInUp');
dom.removeClass(footerRef.current, styles.caseHide);
dom.addClass(footerRef.current, 'animate__slideInUp');
dom.removeClass(titleRef.current, styles.caseHide);
dom.addClass(titleRef.current, 'animte__fadeInUp');
}, 500);
});
}
});
}
return () => {
videoTimeout && clearTimeout(videoTimeout);
videoRef.current.removeEventListener('ended', () => {});
videoRef.current && videoRef.current.removeEventListener('ended', () => {});
};
}, [videoRef]);
useEffect(() => {
......@@ -164,14 +176,17 @@ const Login = forwardRef((props, _ref) => {
<meta name="description" content={props.global.title || defaultSetting.title} />
</Helmet>
<div className={styles.main}>
<video
src={require('@/assets/videos/beforPage.mp4')}
className={styles.videLayer}
autoPlay="autoPlay"
muted
playsInline="playsinline"
ref={videoRef}
/>
{
showVideo && <video
src={require('@/assets/videos/beforPage.mp4')}
className={styles.videLayer}
autoPlay="autoPlay"
muted
playsInline="playsinline"
ref={videoRef}
/>
}
{/* main content */}
<div className={styles.inner}>
<div className={classNames(styles.loginTime, styles.caseHide)} ref={loginRef}>
......
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