From 16bc07d97001743e091275666472445a748cf735 Mon Sep 17 00:00:00 2001 From: amass <168062547@qq.com> Date: Wed, 21 Jun 2023 15:02:06 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=99=BB=E5=BD=95=E7=95=8C=E9=9D=A2=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E9=9A=90=E7=A7=81=E5=8D=8F=E8=AE=AE=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=202.=E5=8B=BE=E9=80=89=E6=A1=86=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/LoginPage.js | 107 ++++++++++++++++-------------- src/business/userSlice.js | 11 +-- src/components/Agreement.js | 16 +++++ src/components/DynamicCodeForm.js | 22 ++---- src/components/PasswordForm.js | 7 +- 5 files changed, 92 insertions(+), 71 deletions(-) create mode 100644 src/components/Agreement.js diff --git a/src/LoginPage.js b/src/LoginPage.js index aeea6de..e9aa857 100644 --- a/src/LoginPage.js +++ b/src/LoginPage.js @@ -1,12 +1,11 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState } from 'react'; import { useNavigate } from "react-router-dom"; -import Button from '@mui/material/Button'; import yzs from "./business/request.js"; import styles from './LoginPage.module.css'; import { useSelector, useDispatch } from 'react-redux' -import { setFlushToken, setAccessToken, setUserInfo } from "./business/userSlice.js" +import { setFlushToken, setAccessToken, setUserInfo, setAgreeAgreement } from "./business/userSlice.js" import logo from './assets/logo.png'; -import { Container, Tab, Box } from '@mui/material'; +import { Container, Tab, Box, Snackbar, Button } from '@mui/material'; import TabPanel from '@mui/lab/TabPanel'; import { TabList } from '@mui/lab'; import TabContext from '@mui/lab/TabContext'; @@ -39,11 +38,16 @@ export default function () { const account = useSelector(state => state.user.account) const password = useSelector(state => state.user.password) const verificationCode = useSelector(state => state.user.verificationCode) + const agreeAgreement = useSelector(state => state.user.agreeAgreement) const handleChange = (event, newValue) => { setValue(newValue); }; + const onAgreeChange = (event) => { + dispatch(setAgreeAgreement(!agreeAgreement)); + } + const accessToken = useSelector(state => state.user.accessToken) const flushToken = useSelector(state => state.user.flushToken) @@ -72,52 +76,59 @@ export default function () { }); }) + }).catch(error => { + console.log(error) }); }; - return ( -
-
- -

纽曼AI语记

-
- -
- - - - - - - - - - - - - - - - - - - - {/* */} -
+ return
+
+ +

纽曼AI语记

- ); + +
+ + + + + + + + + + + + + + + + + + + + {/* */} +
+ {/* */} +
} \ No newline at end of file diff --git a/src/business/userSlice.js b/src/business/userSlice.js index fd3b85a..592a519 100644 --- a/src/business/userSlice.js +++ b/src/business/userSlice.js @@ -10,9 +10,9 @@ export const userSlice = createSlice({ userName: "", nickName: "", avatarUrl: "", - agreeAgreement: true, - account: "13682423271", - password: "yzs123456", + agreeAgreement: false, + account: "", + password: "", verificationCode: "", }, reducers: { @@ -40,10 +40,13 @@ export const userSlice = createSlice({ setVerificationCode: (state, action) => { state.verificationCode = action.payload; }, + setAgreeAgreement: (state, action) => { + state.agreeAgreement = action.payload; + }, } }) // Action creators are generated for each case reducer function -export const { setFlushToken, setAccessToken, setUserInfo, setSelectInfo, setAccount, setPassword, setVerificationCode } = userSlice.actions +export const { setFlushToken, setAccessToken, setUserInfo, setSelectInfo, setAccount, setPassword, setVerificationCode, setAgreeAgreement } = userSlice.actions export default userSlice.reducer \ No newline at end of file diff --git a/src/components/Agreement.js b/src/components/Agreement.js new file mode 100644 index 0000000..532e3b4 --- /dev/null +++ b/src/components/Agreement.js @@ -0,0 +1,16 @@ +import { Container, Checkbox, Link, Stack, Typography } from "@mui/material"; + +export default function ({ agree, onChange }) { + return + + + 同意 + + 《纽曼隐私协议》 + + + +} \ No newline at end of file diff --git a/src/components/DynamicCodeForm.js b/src/components/DynamicCodeForm.js index 2b3cd0b..df58df3 100644 --- a/src/components/DynamicCodeForm.js +++ b/src/components/DynamicCodeForm.js @@ -1,15 +1,15 @@ -import { Container, TextField, InputAdornment, Link, Button, Stack, Typography } from "@mui/material"; +import { Container, TextField, InputAdornment, Link, Button } from "@mui/material"; import React, { useState, useEffect, useRef } from 'react'; import PhoneIphoneIcon from '@mui/icons-material/PhoneIphone'; import LockIcon from '@mui/icons-material/Lock'; import { useSelector, useDispatch } from 'react-redux' import { setAccount, setVerificationCode } from "../business/userSlice.js" import yzs from "../business/request.js"; +import Agreement from "./Agreement.js"; -export default function ({ udid }) { +export default function ({ udid, agreeAgreement, onAgreeChange }) { const dispatch = useDispatch(); const code = useRef(null); - const [checked, setChecked] = useState(true); const [seconds, setSeconds] = useState(0); // 倒计时 const account = useSelector(state => state.user.account) @@ -41,10 +41,6 @@ export default function ({ udid }) { setSeconds(60); }; - const onAgreeChange = (event) => { - setChecked(!checked); - } - return 注册/登录 - - - - 同意 《纽曼隐私协议》 - - - + } \ No newline at end of file diff --git a/src/components/PasswordForm.js b/src/components/PasswordForm.js index 67dba28..eba1fbd 100644 --- a/src/components/PasswordForm.js +++ b/src/components/PasswordForm.js @@ -1,11 +1,12 @@ -import React, { useState } from 'react'; +import React from 'react'; import { Container, TextField, Button, InputAdornment } from "@mui/material"; import PhoneIphoneIcon from '@mui/icons-material/PhoneIphone'; import LockIcon from '@mui/icons-material/Lock'; import { useSelector, useDispatch } from 'react-redux' import { setAccount, setPassword } from "../business/userSlice.js" +import Agreement from './Agreement.js'; -export default function () { +export default function ({ agreeAgreement, onAgreeChange }) { const dispatch = useDispatch(); const account = useSelector(state => state.user.account) const password = useSelector(state => state.user.password) @@ -61,6 +62,7 @@ export default function () { variant="contained" color="primary" fullWidth + disabled={!agreeAgreement} sx={{ backgroundColor: "#FF595A", '&:hover': { @@ -73,5 +75,6 @@ export default function () { > 登录 + } \ No newline at end of file