|
@@ -1,16 +1,15 @@
|
|
|
"use client";
|
|
|
-import { getFindPwdApi, getSendCodeApi } from "@/api/user";
|
|
|
+import { getFindPwdApi } from "@/api/user";
|
|
|
import ButtonOwn from "@/components/ButtonOwn";
|
|
|
import DomainFooter from "@/components/DomainFooter";
|
|
|
import HeaderBack from "@/components/HeaderBack";
|
|
|
-import { Link, useRouter } from "@/i18n/routing";
|
|
|
-import { useUserInfoStore } from "@/stores/useUserInfoStore";
|
|
|
+import { useLogout } from "@/hooks/useLogout";
|
|
|
import { Form, Input, Toast } from "antd-mobile";
|
|
|
import { FormInstance } from "antd-mobile/es/components/form";
|
|
|
import clsx from "clsx";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
import { useSearchParams } from "next/navigation";
|
|
|
-import { FC, useEffect, useRef, useState } from "react";
|
|
|
+import { FC, useRef, useState } from "react";
|
|
|
import { Simulate } from "react-dom/test-utils";
|
|
|
import "./page.scss";
|
|
|
import change = Simulate.change;
|
|
@@ -18,39 +17,19 @@ import change = Simulate.change;
|
|
|
interface Props {}
|
|
|
|
|
|
const ResetPhone: FC<Props> = () => {
|
|
|
- const router: any = useRouter();
|
|
|
- // confirmPasswordPage
|
|
|
const t = useTranslations();
|
|
|
+ const { logout } = useLogout();
|
|
|
|
|
|
let searchParams = useSearchParams();
|
|
|
let user_phone = searchParams.get("userPhone");
|
|
|
let code = searchParams.get("code");
|
|
|
|
|
|
- let alter = searchParams.get("alter");
|
|
|
- const sendCodeRequest = () => {
|
|
|
- if (!user_phone) return;
|
|
|
- getSendCodeApi({ user_phone }).then((res) => {
|
|
|
- if (res.code == 200) {
|
|
|
- return;
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
- useEffect(() => {
|
|
|
- alter && sendCodeRequest();
|
|
|
- // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
- }, [alter]);
|
|
|
-
|
|
|
- const { setUserInfo } = useUserInfoStore();
|
|
|
-
|
|
|
const findPwdRequest = ({ pwd }: { pwd: string }) => {
|
|
|
getFindPwdApi({ user_phone, code, pwd })
|
|
|
- .then((res) => {
|
|
|
+ .then(async (res) => {
|
|
|
if (res.code == 200) {
|
|
|
Toast.show({ icon: "success", content: t("code.200"), maskClickable: false });
|
|
|
- setUserInfo("");
|
|
|
- setTimeout(() => {
|
|
|
- router.replace("/login");
|
|
|
- }, 1000);
|
|
|
+ await logout();
|
|
|
}
|
|
|
})
|
|
|
.catch((error) => {
|
|
@@ -77,7 +56,7 @@ const ResetPhone: FC<Props> = () => {
|
|
|
};
|
|
|
const checkValidator = (rules: any, value: string) => {
|
|
|
const password = formRef.current?.getFieldValue("pwd");
|
|
|
- if (value === password) {
|
|
|
+ if (value !== password) {
|
|
|
return Promise.reject(new Error(t("form.checkPwdReg")));
|
|
|
}
|
|
|
return Promise.resolve();
|
|
@@ -123,26 +102,6 @@ const ResetPhone: FC<Props> = () => {
|
|
|
/>
|
|
|
</Form.Item>
|
|
|
|
|
|
- <Form.Item
|
|
|
- name="pwd"
|
|
|
- label=""
|
|
|
- extra={
|
|
|
- <span
|
|
|
- className={spanClassName}
|
|
|
- onClick={() => setVisible(!visible)}
|
|
|
- ></span>
|
|
|
- }
|
|
|
- rules={[
|
|
|
- { required: true, message: t("form.passwordReg") },
|
|
|
- { min: 6, max: 20, message: t("form.passwordMinReg") },
|
|
|
- ]}
|
|
|
- >
|
|
|
- <Input
|
|
|
- placeholder={t("form.newPwd")}
|
|
|
- maxLength={20}
|
|
|
- type={visible ? "text" : "password"}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
<Form.Item
|
|
|
name="checkPwd"
|
|
|
label=""
|
|
@@ -157,11 +116,6 @@ const ResetPhone: FC<Props> = () => {
|
|
|
<Input placeholder={t("form.checkPwd")} maxLength={20} type={"password"} />
|
|
|
</Form.Item>
|
|
|
</Form>
|
|
|
- <div className={"text-right"}>
|
|
|
- <Link href={"/resetPhone"} className={"text-[#fff]"}>
|
|
|
- {t("LoginPage.forgetPwd")}
|
|
|
- </Link>
|
|
|
- </div>
|
|
|
</div>
|
|
|
|
|
|
<DomainFooter />
|