1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/* eslint-disable */
/*
* @Author: hujinjie;
* @Date: 2022-4-14
* @Description: 华农登录页;
*/
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { withRouter } from '@wisdom-utils/runtime';
import { Modal } from 'antd';
import { HelmetProvider, Helmet } from 'react-helmet-async';
import FormLogin from './FormLogin';
import { actionCreators } from '@/containers/App/store';
import LoginAction from '../../login';
import styles from './index.less';
import { defaultApp } from '@/micro';
class HuaNongLogin extends Component {
constructor(props) {
super(props);
this.state = {
time: '16:00',
week: '星期一',
date: '2020-04-14',
title: '华中农业大学二级单位定额与建筑能耗管理系统',
type: 'Account',
status: 'normal',
submitting: false,
autoLogin: false,
visible: false,
action: new LoginAction(Object.assign({}, props, { history: props.history }), this.setVisible, true),
};
this.fromRef = React.createRef();
this.sliVerify = React.createRef();
}
handleSubmit = values => {
const { action, type, autoLogin } = this.state;
action &&
(type === 'Account'
? action.loginHandler(values.userName, values.password, null, autoLogin, this.sliVerify)
: type === 'Mobile'
? action.phoneLoginFormHandler(values.mobile, values.captcha)
: null);
this.setSubmitting(true);
this.props.updateCurrentIndex(-1);
};
onActinoChange = action => {
action &&
action.events.on('loginSuccess', event => {
this.setSubmitting(false);
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
this.props.history.push(`/?client=${this.props.global.client}`);
defaultApp();
});
action &&
action.events.on('loginError', event => {
this.setVisible(false);
this.setSubmitting(false);
});
action &&
action.events.on('loginVisible', status => {
this.setVisible(status);
});
};
setSubmitting = submitting => {
this.setState({ submitting });
};
setVisible = visible => {
this.setState({
visible,
});
};
setType = type => {
this.setState({
type,
});
};
setAutoLogin = autoLogin => {
this.setState({
autoLogin,
});
};
renderPlatform() {
const params = {
fromRef: this.formRef,
type: this.state.type,
setType: this.setType,
status: this.state.status,
submitting: this.state.submitting,
autoLogin: this.state.autoLogin,
setAutoLogin: this.setAutoLogin,
action: this.state.action,
onSubmit: this.handleSubmit,
loginMode: this.props.loginMode,
updateLoginMode: this.props.updateLoginMode,
};
return <FormLogin {...params} />;
}
getCurrentTime(callback) {
const date = new Date();
const week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
let minutes = date.getMinutes();
if (minutes < 10) {
minutes = '0' + minutes;
}
let second = date.getSeconds();
const time = `${date.getHours()}:${minutes}`;
const weekDay = week[date.getDay()];
const dateStr = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
const dateObj = {
time,
week: weekDay,
date: dateStr,
second,
};
callback && callback(dateObj);
}
showTime = (date) => {
this.clearTime();
this.setState({
...date,
});
const interval = 60 - date.second;
this.timeTimer = setInterval(() => {
this.getCurrentTime(this.showTime);
}, interval * 1000);
}
// 清除时间定时器
clearTime() {
this.timeTimer && clearInterval(this.timeTimer);
}
componentDidMount() {
console.log(this.props);
console.log(this);
this.onActinoChange(this.state.action);
this.getCurrentTime(this.showTime);
}
componentWillUnmount() {
this.clearTime();
}
render() {
return (
<HelmetProvider>
<div className={styles.quota}>
<div className={styles.head}>
<div className={styles.title}>
<img src={this.props.global && this.props.global.transformDevAssetsBaseURL && this.props.global.transformDevAssetsBaseURL(this.props.global.logo)} alt="" />
{/* <img src={require('@/assets/images/login/能源-定额/华农logo.png')} alt="" /> */}
<span>{this.props.global.title || this.state.title}</span>
</div>
<div className={styles.time_and_date}>
<div className={styles.time}>{this.state.time}</div>
<div className={styles.date}>
<span>{this.state.week}</span>
<span>{this.state.date}</span>
</div>
</div>
</div>
<div className={styles.wrap_content}>
<div className={styles.from}>
<div className={styles.slogan}>
<div className={styles.slogan_back} />
</div>
<div className={styles.login}>{this.renderPlatform()}</div>
</div>
</div>
<Modal
centered
visible={this.state.visible}
width={340}
footer={null}
closable={false}
bodyStyle={{ padding: '15px' }}
>
<div ref={this.sliVerify} />
</Modal>
</div>
</HelmetProvider>
);
}
}
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']),
loginMode: state.getIn(['global', 'loginMode']),
});
const mapDispatchToProps = dispatch => ({
updateConfig(config) {
dispatch(actionCreators.getConfig(config));
},
createContext(data) {
dispatch(actionCreators.createContext(data));
},
updateLoginMode(mode) {
dispatch(actionCreators.changeLoginMode(mode));
},
updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index));
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(withRouter(HuaNongLogin));