mirror of
https://github.com/MrXujiang/h5-Dooring.git
synced 2026-01-06 19:58:10 +00:00
:update: 优化登录页面,优化操作按钮
This commit is contained in:
parent
22c4ef16bd
commit
20d508e2de
@ -1,31 +1,41 @@
|
|||||||
import { Form, Input, Button } from 'antd';
|
import { Form, Input, Button, Popover } from 'antd';
|
||||||
import http from '@/utils/req';
|
import React from 'react';
|
||||||
|
import req from '@/utils/req';
|
||||||
|
import CodeImg from '@/assets/code.png';
|
||||||
import { history } from 'umi';
|
import { history } from 'umi';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
import React from 'react';
|
|
||||||
import { ValidateErrorEntity, Store } from 'rc-field-form/lib/interface';
|
interface FormValues {
|
||||||
import { RouteComponentProps } from 'react-router-dom';
|
n: string;
|
||||||
|
co: string;
|
||||||
|
}
|
||||||
|
|
||||||
const layout = {
|
const layout = {
|
||||||
labelCol: { span: 6 },
|
labelCol: { span: 6 },
|
||||||
wrapperCol: { span: 16 },
|
wrapperCol: { span: 16 },
|
||||||
};
|
};
|
||||||
|
|
||||||
const tailLayout = {
|
const tailLayout = {
|
||||||
wrapperCol: { offset: 6, span: 16 },
|
wrapperCol: { offset: 6, span: 16 },
|
||||||
};
|
};
|
||||||
|
|
||||||
const Login = (props: RouteComponentProps) => {
|
const content = (
|
||||||
const onFinish = (values: Store) => {
|
<>
|
||||||
http
|
<div style={{ textAlign: 'center' }}>
|
||||||
.post<Store, { token: string }>('/login', { ...values })
|
<img style={{ width: '180px' }} src={CodeImg} alt="趣谈前端-徐小夕" />
|
||||||
.then(res => {
|
</div>
|
||||||
localStorage.setItem('token', res.token);
|
<p style={{ width: '240px' }}>扫描上方二维码,关注【趣谈前端】公众号,回复"登录码" 即可获取</p>
|
||||||
localStorage.setItem('user', values.username);
|
</>
|
||||||
history.push('/');
|
);
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const onFinishFailed = (errorInfo: ValidateErrorEntity) => {
|
const Login = () => {
|
||||||
console.log('Failed:', errorInfo);
|
const onFinish = (values: FormValues) => {
|
||||||
|
const { n, co } = values;
|
||||||
|
req.post('/vip/check', { n, co }).then((res: any) => {
|
||||||
|
localStorage.setItem('nickname', res.n);
|
||||||
|
localStorage.setItem('h5', JSON.stringify(res.h5));
|
||||||
|
history.push('/');
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -36,38 +46,30 @@ const Login = (props: RouteComponentProps) => {
|
|||||||
className={styles.formWrap}
|
className={styles.formWrap}
|
||||||
initialValues={{ remember: true }}
|
initialValues={{ remember: true }}
|
||||||
onFinish={onFinish}
|
onFinish={onFinish}
|
||||||
onFinishFailed={onFinishFailed}
|
|
||||||
>
|
>
|
||||||
<div className={styles.tit}>
|
<div className={styles.tit}>
|
||||||
Doring开放平台
|
Dooring开放平台
|
||||||
<span style={{ marginLeft: '20px', fontSize: '18px', color: '#06c' }}>登录</span>
|
<span style={{ marginLeft: '20px', fontSize: '18px', color: '#06c' }}>登录</span>
|
||||||
</div>
|
</div>
|
||||||
<Form.Item
|
<Form.Item label="用户名" name="n" rules={[{ required: true, message: '请输入用户名!' }]}>
|
||||||
label="用户名"
|
|
||||||
name="username"
|
|
||||||
rules={[{ required: true, message: '请输入用户名!' }]}
|
|
||||||
>
|
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item label="密码" name="co" rules={[{ required: true, message: '请输入密码!' }]}>
|
||||||
label="密码"
|
|
||||||
name="password"
|
|
||||||
rules={[{ required: true, message: '请输入密码!' }]}
|
|
||||||
>
|
|
||||||
<Input.Password />
|
<Input.Password />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
|
<div style={{ margin: '-16px 0 12px 116px' }}>
|
||||||
|
<Popover placement="topLeft" content={content} trigger="click">
|
||||||
|
<Button type="link">如何获取登录码?</Button>
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Form.Item {...tailLayout}>
|
<Form.Item {...tailLayout}>
|
||||||
<Button type="primary" htmlType="submit" block>
|
<Button type="primary" htmlType="submit" block>
|
||||||
登录
|
登录
|
||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item {...tailLayout}>
|
|
||||||
<Button block onClick={() => props.history.push(`/editor?tid=${123456}`)}>
|
|
||||||
直接使用
|
|
||||||
</Button>
|
|
||||||
</Form.Item>
|
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user