From c2e89373b684ffd8562b5fceaa2389e015dbc755 Mon Sep 17 00:00:00 2001 From: john Date: Thu, 13 Jun 2024 16:34:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20feat:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 注册添加密码 --- src/api/index.ts | 1 + src/components/EmailForm.tsx | 64 +++++++++++++++++++++++++++++++-- src/components/PhoneForm.tsx | 70 ++++++++++++++++++++++++++++++++++-- src/i18n/cn/translation.json | 6 +++- src/i18n/en/translation.json | 6 +++- src/pages/SignIn.tsx | 9 +++-- 6 files changed, 146 insertions(+), 10 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index 7cee2dd..0a38028 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -43,6 +43,7 @@ export const signUp = ( district?: string; // 二级区域:具体的区域 shareCode: string; // invitation code userName: string; // 用户名称 + password?: string; }, config: AxiosRequestConfig ) => diff --git a/src/components/EmailForm.tsx b/src/components/EmailForm.tsx index 011c879..cdfe9a3 100644 --- a/src/components/EmailForm.tsx +++ b/src/components/EmailForm.tsx @@ -21,6 +21,8 @@ function EmailForm() { const [email, setEmail] = useState(""); const [authCode, setAuthCode] = useState(""); const [shareCode, setShareCode] = useState(""); + const [password, setPassword] = useState(""); + const [confirmPassword, setConfirmPassword] = useState(""); const [remainingTime, setRemainingTime] = useState(0); const { Lang } = useUserStore(); const SilderVertifyRef = useRef(null); @@ -75,7 +77,7 @@ function EmailForm() { // start(60 * 1000); }, }); - if (res.data.code == 1014) { + if (res.data.code == 1021 || res.data.code == 1015) { SilderVertifyRef.current?._init(); return; } @@ -122,6 +124,7 @@ function EmailForm() { authCode: authCode, shareCode: shareCode || formRef.current?.getFieldValue("shareCode"), userName: "", + password: Md5.hashStr(password), }, config ); @@ -167,11 +170,14 @@ function EmailForm() { type="submit" color="primary" size="large" - onClick={handleSignUp} + // onClick={handleSignUp} > {t("register")} } + onFinish={() => { + handleSignUp(); + }} > setEmail(text)} /> + { + if (v && (v.length < 6 || v.length > 30)) { + return Promise.reject( + new Error( + t( + "Please ensure your password length is between 6 and 30 characters." + ) + ) + ); + } + return Promise.resolve(); + }, + }, + ]} + > + setPassword(v)} + /> + + { + if (v != password) { + return Promise.reject(new Error(t("Passwords do not match"))); + } + return Promise.resolve(); + }, + }, + ]} + > + setConfirmPassword(v)} + /> + (null); const gotoSelectCountry = () => { @@ -105,7 +113,7 @@ function PhoneForm() { // start(60 * 1000); }, }); - if (res.data.code == 1014) { + if (res.data.code == 1021 || res.data.code == 1015) { SilderVertifyRef.current?._init(); return; } @@ -151,6 +159,7 @@ function PhoneForm() { authCode: authCode, shareCode: shareCode || formRef.current?.getFieldValue("shareCode"), userName: "", + password: Md5.hashStr(password), }, config ); @@ -195,11 +204,14 @@ function PhoneForm() { type="submit" color="primary" size="large" - onClick={handleSignUp} + // onClick={handleSignUp} > {t("register")} } + onFinish={() => { + handleSignUp(); + }} > + { + if (v && (v.length < 6 || v.length > 30)) { + return Promise.reject( + new Error( + t("password length is between 6 and 30 characters.") + ) + ); + } + return Promise.resolve(); + }, + }, + ]} + > + setPassword(v)} + /> + + { + if (v != password) { + return Promise.reject(new Error(t("Passwords do not match"))); + } + return Promise.resolve(); + }, + }, + ]} + > + setConfirmPassword(v)} + /> +
- {/*
{t("E-mail")} -
*/} +
{t("phone")}
- {/* {selectIndex === 0 && } */} + {selectIndex === 0 && } {selectIndex === 1 && }

From a97072958a1678cbe21e8b2464860b41c7af7a33 Mon Sep 17 00:00:00 2001 From: john Date: Thu, 13 Jun 2024 16:38:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20feat:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 切换中文语言自动切换区号 --- src/pages/SignIn.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/SignIn.tsx b/src/pages/SignIn.tsx index be23e42..e64244c 100644 --- a/src/pages/SignIn.tsx +++ b/src/pages/SignIn.tsx @@ -11,6 +11,7 @@ import { useNavigate } from "react-router-dom"; import useUserStore from "../store/user.ts"; import { Popover } from "antd-mobile"; import EmailForm from "../components/EmailForm.tsx"; +import Area from "../i18n/area/area.json"; function SignIn() { const { t, i18n } = useTranslation(); @@ -20,7 +21,7 @@ function SignIn() { const [selectIndex, setSelectIndex] = useState(1); const { previousPathName, UpdatePreviousPathName } = useUserStore(); const navigate = useNavigate(); - const { UpdateLang } = useUserStore(); + const { UpdateLang, UpdateSelectCountry } = useUserStore(); const handleTabs = (num: number) => { return () => { UpdatePreviousPathName("/"); @@ -72,6 +73,8 @@ function SignIn() { i18n.changeLanguage("cn"); setVisible(false); UpdateLang("zh-TW"); + const areaItem = Area.find((v) => v.code == "+86"); + if (areaItem) UpdateSelectCountry(areaItem); }} > 中文(繁体) From 1bd2ab1312bf4de70308638c9c8f77929d655a85 Mon Sep 17 00:00:00 2001 From: john Date: Thu, 13 Jun 2024 18:41:06 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=90=8E=20ci:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.0.5 --- package.json | 2 +- src/api/request.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 04c0c09..e756fcf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "neer-app-h5", "private": true, - "version": "1.0.4", + "version": "1.0.5", "type": "module", "scripts": { "dev": "vite", diff --git a/src/api/request.ts b/src/api/request.ts index ada7700..44b358c 100644 --- a/src/api/request.ts +++ b/src/api/request.ts @@ -32,7 +32,7 @@ service.interceptors.request.use( config.headers = { ...config.headers, ...customHeaders, - appVersion: "1.0.4", + appVersion: "1.0.5", } as AxiosRequestHeaders; return config;