登录添加加载状态

This commit is contained in:
al 2024-12-04 14:23:24 +08:00
parent 5359bf0a6e
commit 4b5781959f
2 changed files with 17 additions and 7 deletions

View File

@ -35,6 +35,7 @@ function Login({ handleLogin }) {
const [activeIndex, setActiveIndex] = useState(0);
const [veriCode, setVeriCode] = useState("");
const [isCounting, setIsCounting] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [seconds, setSeconds] = useState(60);
const [deviceType, setDeviceType] = useState("");
const [loginInfo, setLoginInfo] = useState({
@ -145,6 +146,7 @@ function Login({ handleLogin }) {
...body,
veri_code: veriCode,
};
setIsLoading(true);
try {
const data = await requireAPI(
"POST",
@ -155,7 +157,9 @@ function Login({ handleLogin }) {
body,
}
);
if (data.ret === -1) {
setIsLoading(false);
Toast.show({
icon: "fail",
content: data.msg,
@ -172,12 +176,14 @@ function Login({ handleLogin }) {
} else {
save("firstLogin", 0);
}
setIsLoading(false);
router.push(
!data?.data?.is_enabled && type != "password"
? "/my/setting/editPassword?is_enabled=" + data?.data?.is_enabled
: "/"
);
} catch (error) {
setIsLoading(false);
// console.error(error);
}
};
@ -437,6 +443,7 @@ function Login({ handleLogin }) {
</span>
</div>
<LoginBtn
isLoading={isLoading}
loginInfo={loginInfo}
setLoginInfo={setLoginInfo}
handleSubmit={handleSubmit}
@ -450,7 +457,13 @@ function Login({ handleLogin }) {
);
}
const LoginBtn = ({ loginInfo, setLoginInfo, type, handleSubmit }) => {
const LoginBtn = ({
loginInfo,
setLoginInfo,
type,
handleSubmit,
isLoading,
}) => {
const router = useRouter();
useEffect(() => {}, []);
return (
@ -493,6 +506,7 @@ const LoginBtn = ({ loginInfo, setLoginInfo, type, handleSubmit }) => {
<Button
shape="rounded"
size="middle"
loading={isLoading}
block
onClick={() => handleSubmit(type)}
style={{

View File

@ -8,7 +8,6 @@ export default function AlreadyAddWechat({ zid, currentIndex }) {
const [offset, setOffset] = useState(0);
const [more, setMore] = useState(1);
const [data, setData] = useState([]);
const [modalVisible, setModalVisible] = useState(false);
const getData = async () => {
if (zid === undefined || !more || currentIndex != 0) return;
try {
@ -85,13 +84,9 @@ export default function AlreadyAddWechat({ zid, currentIndex }) {
</div>
<div
onClick={() => {
setModalVisible(!modalVisible);
Modal.show({
content: (
<div
onClick={() => setModalVisible(false)}
className="flex-1 justify-center items-center bg-[#00000080]"
>
<div className="flex-1 justify-center items-center bg-[#000000]">
<div className="p-4 rounded-2xl bg-[#1E1C29] items-center">
{item.consumer_wechat ? (
<div className="flex flex-col w-full">
@ -180,6 +175,7 @@ export default function AlreadyAddWechat({ zid, currentIndex }) {
</div>
</div>
),
destroyOnHide: true,
closeOnMaskClick: true,
bodyStyle: {
background: "none",