处理密码修改

This commit is contained in:
al 2024-07-31 18:16:25 +08:00
parent 7de541fa74
commit e9a559cd6f
8 changed files with 54 additions and 32 deletions

View File

@ -18,7 +18,11 @@ body{
--background-end-rgb: 0, 0, 0;
}
} */
@media only screen and (min-device-width: 320px) and (max-device-width: 1024px) {
select:focus, textarea:focus, input:focus {
font-size: 16px !important;
}
}
.custom-tabs .adm-tabs {
border: none;
--active-line-color: #ff8383;

View File

@ -46,6 +46,7 @@ export default function RootLayout({ children }) {
type="image/x-icon"
></link>
<link rel="icon" href="/favicon.png" type="image/png"></link>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta
name="description"
content={metadata.description}

View File

@ -154,9 +154,9 @@ function Login({ handleLogin }) {
handleLogin({ isSignin: true, userToken: data.data.token });
router.push(
!data?.data?.is_enabled
? "/"
: "/my/setting/editPassword?is_enabled=" + data?.data?.is_enabled
(!data?.data?.is_enabled && type != "password")
? "/my/setting/editPassword?is_enabled=" + data?.data?.is_enabled
: "/"
);
} catch (error) {
console.error(error);
@ -205,8 +205,8 @@ function Login({ handleLogin }) {
}
};
return (
<div className="h-full lg:flex flex-col items-center ">
<div className={`lg:max-w-[450px] overflow-hidden mt-20 flex flex-col items-center `}>
<div className="lg:flex flex-col items-center ">
<div className={`lg:max-w-[450px] overflow-hidden pt-20 flex flex-col items-center `}>
<Image
src={process.env.NEXT_PUBLIC_CDN_URL + "/public/images/slogan.png"}
alt=""
@ -236,6 +236,7 @@ function Login({ handleLogin }) {
className="overflow-visible mt-6 "
direction="horizontal"
loop
allowTouchMove={false}
indicator={() => null}
ref={swiperRef}
defaultIndex={activeIndex}
@ -253,6 +254,7 @@ function Login({ handleLogin }) {
clearable
placeholder="请输入手机号"
// disabled={true}
name="phone_number"
type="number"
maxLength={11}
onChange={(value) =>
@ -261,7 +263,7 @@ function Login({ handleLogin }) {
value={loginInfo.mobilePhone}
style={{
"--color": "#FFFFFF",
"--font-size": "14px",
"--font-size": "16px",
"--placeholder-color": "#FFFFFF80",
}}
/>
@ -275,10 +277,11 @@ function Login({ handleLogin }) {
placeholder="请输入验证码"
onChange={(value) => setVeriCode(value)}
value={veriCode}
name="veriCode"
type="number"
style={{
"--placeholder-color": "#FFFFFF80",
"--font-size": "14px",
"--font-size": "16px",
}}
/>
<Button
@ -301,7 +304,7 @@ function Login({ handleLogin }) {
type={activeIndex ? "password" : "mobile"}
/>
</Swiper.Item>
<Swiper.Item className="px-10">
<Swiper.Item className="px-6">
<div className="border-2 border-[#2c2b2f] rounded-2xl p-3">
<div className="flex flex-row flex-nowrap items-center mb-4">
<p className="text-base text-white mr-4">
@ -312,6 +315,7 @@ function Login({ handleLogin }) {
placeholder="请输入手机号"
// disabled={true}
type="number"
name="phone_number"
maxLength={11}
onChange={(value) =>
setLoginInfo({ ...loginInfo, mobilePhone: value })
@ -332,6 +336,7 @@ function Login({ handleLogin }) {
<Input
clearable
placeholder="请输入密码"
name="password"
onChange={(value) =>
setLoginInfo({ ...loginInfo, password: value })
}
@ -345,7 +350,7 @@ function Login({ handleLogin }) {
</div>
</div>
<div
onClick={() => router.push(`/my/setting/editPassword`)}
onClick={() => router.push(`/my/setting/editPassword?forgetPassword=true`)}
className="w-full text-[#FF669E] text-xs mt-2 text-right"
>
忘记密码

View File

@ -32,7 +32,7 @@ export default function AddToHome() {
<p className="text-xs mt-4 mb-2">1.在浏览器中打开主界面点击浏览器中的[分享]按钮</p>
<div className="flex justify-center">
<Image
src={"/images/addToHome1.png"}
src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/addToHome1.png"}
placeholder=""
className="w-[60%]"
/>
@ -40,7 +40,7 @@ export default function AddToHome() {
<p className="text-xs mt-4 mb-2">2.打开分享弹框后点击[添加到主屏幕]</p>
<div className="flex justify-center">
<Image
src={"/images/addToHome2.png"}
src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/addToHome2.png"}
placeholder=""
className="w-[60%]"
/>
@ -48,7 +48,7 @@ export default function AddToHome() {
<p className="text-xs mt-4 mb-2">3.打开添加到主屏幕弹框后点击[添加]按钮即可成功添加到主屏幕</p>
<div className="flex justify-center">
<Image
src={"/images/addToHome3.png"}
src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/addToHome3.png"}
placeholder=""
className="w-[60%]"
/>

View File

@ -13,13 +13,16 @@ const My = () => {
useEffect(() => {
const userInfo = get("account");
if (userInfo) {
setUserInfo(userInfo);
// setUserInfo(userInfo);
getData(userInfo);
}
// getData(userInfo);
}, []);
const getData = async (oldUserInfo) => {
const data =
await requireAPI("POST", "/api/account_relation/count", null, true);
const account =
await requireAPI("POST", "/api/account/list_by_mid", null, true);
if (data.ret === -1) {
Toast.show({
icon: "fail",
@ -28,7 +31,7 @@ const My = () => {
});
return;
}
setUserInfo({ ...oldUserInfo, ...data.data });
setUserInfo({ ...oldUserInfo, ...data.data,...account.data.account });
};
return (
<div className={`h-screen p-4 pb-20 bg-no-repeat bg-contain bg-top`}
@ -350,7 +353,7 @@ const My = () => {
<Image
className="mr-2"
width={32}
src={"/icons/32DP/toScreen.png"}
src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/icons/32DP/toScreen.png"}
placeholder=""
/>
<span className="text-base">添加到主屏幕</span>

View File

@ -1,7 +1,7 @@
"use client";
import React, { useState, useEffect } from "react";
import { Button, Input, Divider } from "antd-mobile";
import { Button, Input, Divider, Toast } from "antd-mobile";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faAngleLeft } from "@fortawesome/free-solid-svg-icons";
import { useRouter, useSearchParams } from "next/navigation";
@ -66,7 +66,7 @@ export default function EditPassword() {
});
return;
}
if (!veriCode) {
if (!veriCode && searchParams.get("is_enabled") != "0") {
Toast.show({
icon: "fail",
content: "请输入验证码",
@ -113,14 +113,17 @@ export default function EditPassword() {
//MD5加密新旧密码
const encryptedNewPassword = cryptoPassword(newPassword);
//发送修改密码请求
try {
const data = await requireAPI("POST", `/api/login/logout`, {
body: {
const body = {
mobile_phone: mobile_phone,
region_code: regionCode,
veri_code: veriCode,
new_password: encryptedNewPassword,
},
};
if(searchParams.get("is_enabled")!="0"){
body.veri_code=veriCode
}
try {
const data = await requireAPI("POST", `/api/login/${searchParams.get("is_enabled")=="0"?"set_password":"reset_password"}`, {
body
});
if (data.ret === -1) {
Toast.show({
@ -135,7 +138,11 @@ export default function EditPassword() {
content: "修改成功,请重新登录",
position: "top",
});
signOut();
if(searchParams.get("is_enabled") == "0"){
router.push("/")
}else{
router.push("/login");signOut()
}
} catch (error) {
console.error(error);
}
@ -171,7 +178,7 @@ export default function EditPassword() {
<p className="text-base text-white mr-4">+{regionCode}</p>
<Input
placeholder="请输入手机号"
disabled={mobilePhone && searchParams.get("is_enabled") == "0"}
disabled={!searchParams.get("forgetPassword")}
type="number"
maxLength={11}
onChange={(value) => {

View File

@ -1,11 +1,13 @@
import { checkAuth } from "@/utils/auth";
import { useRouter, usePathname } from "next/navigation";
import { useRouter, usePathname, useSearchParams } from "next/navigation";
import { useEffect } from "react";
import { get } from "@/utils/storeInfo";
import { Toast } from "antd-mobile";
export default function WithAuth(WrappedComponent) {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
useEffect(() => {
if(!pathname.includes("webView") && !pathname.includes("login") ){
@ -35,7 +37,7 @@ export default function WithAuth(WrappedComponent) {
}
}
}
} else {
} else if(!searchParams.get("forgetPassword")) {
router.push("/login");
}
};

View File

@ -24,7 +24,7 @@ export default function customFetch(method, url, options = {}, mid) {
newBody.mid = mid;
}
const body = JSON.stringify({ ...base, ...newBody });
console.log("newBody", body);
// console.log("newBody", body);
// 合并选项
const mergedOptions = { ...defaultOptions, body };