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 && }