|
1 | 1 | import React from "react";
|
| 2 | +import SwipeableViews from "react-swipeable-views"; |
| 3 | +import Logo from "../static/logo.png"; |
2 | 4 |
|
3 |
| -class Login extends React.Component { |
4 |
| - render() { |
5 |
| - return <div>Login</div>; |
6 |
| - } |
| 5 | +import { |
| 6 | + CssBaseline, |
| 7 | + Container, |
| 8 | + CardContent, |
| 9 | + Typography, |
| 10 | + TextField, |
| 11 | + Link, |
| 12 | + Button, |
| 13 | + Grid, |
| 14 | + FormControlLabel, |
| 15 | + Checkbox, |
| 16 | + LinearProgress, |
| 17 | + Collapse, |
| 18 | + Tabs, |
| 19 | + Tab, |
| 20 | +} from "@material-ui/core"; |
| 21 | +import { createMuiTheme, ThemeProvider } from "@material-ui/core/styles"; |
| 22 | + |
| 23 | +import FlexCard from "../component/flex_card.js"; |
| 24 | +import TabPanel from "../component/tab_panel.js"; |
| 25 | +import Setting from "../config/config.js"; |
| 26 | +import "../static/css/logcommon.css"; |
| 27 | +import "../static/css/login.css"; |
| 28 | + |
| 29 | +const theme = createMuiTheme({ |
| 30 | + palette: { |
| 31 | + primary: { |
| 32 | + main: "#1890FF", |
| 33 | + }, |
| 34 | + secondary: { |
| 35 | + main: "#64b5f6", |
| 36 | + }, |
| 37 | + }, |
| 38 | +}); |
| 39 | + |
| 40 | +function Login() { |
| 41 | + let [protocol, setProtocol] = React.useState(false); |
| 42 | + let [clientWidth, setClientWidth] = React.useState(document.body.clientWidth); |
| 43 | + let [page, setPage] = React.useState(1); |
| 44 | + let [loading, setLoading] = React.useState(false); |
| 45 | + let [tabs, setTabs] = React.useState(0); |
| 46 | + |
| 47 | + let handleResize = () => { |
| 48 | + setClientWidth(document.body.clientWidth); |
| 49 | + }; |
| 50 | + |
| 51 | + let handleProtocolChange = (event) => { |
| 52 | + setProtocol(event.target.checked); |
| 53 | + }; |
| 54 | + |
| 55 | + let handleNextPage = (event) => { |
| 56 | + // 验证表单 |
| 57 | + |
| 58 | + setLoading(true); |
| 59 | + setTimeout(() => { |
| 60 | + setLoading(false); |
| 61 | + setPage(2); |
| 62 | + }, 1000); |
| 63 | + }; |
| 64 | + |
| 65 | + let handleChangeTab = (event, newValue) => { |
| 66 | + setTabs(newValue); |
| 67 | + }; |
| 68 | + |
| 69 | + let handleChangeIndex = (index) => { |
| 70 | + setTabs(index); |
| 71 | + }; |
| 72 | + |
| 73 | + window.addEventListener("resize", handleResize); |
| 74 | + |
| 75 | + return ( |
| 76 | + <> |
| 77 | + <ThemeProvider theme={theme}> |
| 78 | + <CssBaseline /> |
| 79 | + <Collapse in={loading}> |
| 80 | + <LinearProgress /> |
| 81 | + </Collapse> |
| 82 | + <Container maxWidth={clientWidth <= 600 ? false : "xs"} className={clientWidth <= 600 ? "" : "container"}> |
| 83 | + <div> |
| 84 | + <FlexCard size={clientWidth <= 600 ? "small" : "large"}> |
| 85 | + <Collapse in={page === 1}> |
| 86 | + <CardContent className={page === 1 ? "validation-card" : "validation-card-none"}> |
| 87 | + <div className="register-tip"> |
| 88 | + <img className="logo" src={Logo} alt="Logo" /> |
| 89 | + <Typography className="register-tip-text" variant="h1"> |
| 90 | + 登录 |
| 91 | + </Typography> |
| 92 | + <p className="project-tip-text">一个账号,畅享BlueAirLive所有服务</p> |
| 93 | + <Tabs |
| 94 | + value={tabs} |
| 95 | + onChange={handleChangeTab} |
| 96 | + indicatorColor="primary" |
| 97 | + textColor="primary" |
| 98 | + variant="fullWidth" |
| 99 | + > |
| 100 | + <Tab label="密码登录" /> |
| 101 | + <Tab label="短信验证码登录" /> |
| 102 | + </Tabs> |
| 103 | + <div className="tab-view"> |
| 104 | + <SwipeableViews |
| 105 | + axis={theme.direction === "rtl" ? "x-reverse" : "x"} |
| 106 | + index={tabs} |
| 107 | + onChangeIndex={handleChangeIndex} |
| 108 | + > |
| 109 | + <TabPanel value={tabs} index={0} dir={theme.direction}> |
| 110 | + <TextField className="input" label="邮箱或手机号码" /> |
| 111 | + <TextField className="input" label="密码" /> |
| 112 | + </TabPanel> |
| 113 | + <TabPanel value={tabs} index={1} dir={theme.direction}> |
| 114 | + <TextField className="input" label="手机号码" /> |
| 115 | + <TextField className="input" label="验证码" /> |
| 116 | + </TabPanel> |
| 117 | + </SwipeableViews> |
| 118 | + </div> |
| 119 | + |
| 120 | + <Grid container justify="center" alignItems="center"> |
| 121 | + <Grid item xs={6} className="options-left"> |
| 122 | + <Link href="/#/register">注册账号</Link> |
| 123 | + </Grid> |
| 124 | + <Grid item xs={6} className="options-right"> |
| 125 | + <Button variant="contained" color="primary" onClick={handleNextPage} disableElevation> |
| 126 | + 下一步 |
| 127 | + </Button> |
| 128 | + </Grid> |
| 129 | + </Grid> |
| 130 | + </div> |
| 131 | + </CardContent> |
| 132 | + </Collapse> |
| 133 | + <Collapse in={page === 2}> |
| 134 | + <CardContent className={page === 2 ? "register-card" : "register-card-none"}> |
| 135 | + <div className="register-tip"> |
| 136 | + <img className="logo" src={Logo} alt="Logo" /> |
| 137 | + <Typography className="register-tip-text" variant="h1"> |
| 138 | + 登录验证 |
| 139 | + </Typography> |
| 140 | + <p className="project-tip-text">一个账号,畅享BlueAirLive所有服务</p> |
| 141 | + </div> |
| 142 | + 请手动返回 |
| 143 | + |
| 144 | + </CardContent> |
| 145 | + </Collapse> |
| 146 | + </FlexCard> |
| 147 | + </div> |
| 148 | + </Container> |
| 149 | + </ThemeProvider> |
| 150 | + </> |
| 151 | + ); |
7 | 152 | }
|
8 | 153 |
|
| 154 | + |
9 | 155 | export default Login;
|
0 commit comments