diff --git a/env/.env.development b/env/.env.development index bf1327c..5a99f98 100644 --- a/env/.env.development +++ b/env/.env.development @@ -5,7 +5,7 @@ VITE_DELETE_CONSOLE=false #本地环境 #VITE_SERVER_BASEURL=http://liuyao.nat100.top/meiguowaimai -#VITE_SERVER_BASEURL=http://192.168.5.64:8080 -VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api +VITE_SERVER_BASEURL=http://192.168.5.58:8080 +#VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api #VITE_SERVER_BASEURL=http://192.168.1.8:8811 #VITE_SERVER_BASEURL=http://mifengchuantou.natapp1.cc/meiguowaimai diff --git a/src/locale/en.json b/src/locale/en.json index 854cd85..65c4810 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -204,6 +204,7 @@ "login-successfully": "Login successful", "prompt": { "confirm-email": "Please enter your confirmation email address", + "confirm-password": "Please enter confirmation password", "email": "Please enter your email address", "email-verify": "Please enter the correct email address", "first-name": "Please enter a name", @@ -212,10 +213,12 @@ "password-verify": "Please enter a 6-20 digit password", "phone-number": "Please enter your mobile phone number", "phone-number-verify": "Please enter the correct mobile phone number", + "two-passwords-inconsistent": "The password is inconsistent when entered twice", "reset-success": "Reset successfully" }, "sign-up": { "confirm-email": "Confirm email", + "confirm-password": "Confirm password", "first-name": "First name", "last-name": "Last name", "password": "Password", diff --git a/src/locale/zh-Hans.json b/src/locale/zh-Hans.json index 7274fea..f67d222 100644 --- a/src/locale/zh-Hans.json +++ b/src/locale/zh-Hans.json @@ -198,6 +198,7 @@ "login-successfully": "登录成功", "prompt": { "confirm-email": "请输入确认邮箱", + "confirm-password": "请输入确认密码", "email": "请输入邮箱", "email-verify": "请输入正确的邮箱", "first-name": "请输入名", @@ -206,10 +207,12 @@ "password-verify": "请输入6-20位密码", "phone-number": "请输入手机号", "phone-number-verify": "请输入正确的手机号", + "two-passwords-inconsistent": "两次输入的密码不一致", "reset-success": "重置成功" }, "sign-up": { "confirm-email": "确认邮箱", + "confirm-password": "确认密码", "first-name": "名", "last-name": "姓", "password": "密码", diff --git a/src/manifest.json b/src/manifest.json index 5d95e61..47f5426 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,8 +2,8 @@ "name" : "CHEFLINK Merchant", "appid" : "__UNI__BB8E3C9", "description" : "美国外卖商户端", - "versionName" : "1.0.16", - "versionCode" : 116, + "versionName" : "1.0.17", + "versionCode" : 117, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/src/pages-login/pages/index.vue b/src/pages-login/pages/index.vue index 85d0bb4..8ac7c27 100644 --- a/src/pages-login/pages/index.vue +++ b/src/pages-login/pages/index.vue @@ -68,7 +68,7 @@ function handleSubmit() { email, userPort: 2, // 登录端口2 商户端 }, - options: {} + options: {} as any }).then(res => { console.log('email', res) if (res.data) { @@ -82,7 +82,7 @@ function handleSubmit() { // 用户没注册 logicStore.registerForm.type = type; logicStore.registerForm.confirmEmail = email; - uni.navigateTo({url: '/pages-login/pages/sign-up/index'}) + uni.navigateTo({url: `/pages-login/pages/sign-up/index?type=${type}`}) } }).finally(() => { btnLoading.value = false @@ -95,7 +95,7 @@ function handleSubmit() { phone: email, userPort: 2, // 登录端口2 商户端 }, - options: {} + options: {} as any }).then(res => { type = 'phone'; if (res.data) { @@ -109,7 +109,7 @@ function handleSubmit() { logicStore.registerForm.phone = email; logicStore.registerForm.email = ''; logicStore.registerForm.confirmEmail = ''; - uni.navigateTo({url: '/pages-login/pages/sign-up/index'}) + uni.navigateTo({url: `/pages-login/pages/sign-up/index?type=${type}`}) } }).finally(() => { btnLoading.value = false diff --git a/src/pages-login/pages/sign-up/index.vue b/src/pages-login/pages/sign-up/index.vue index ba1610d..55403ee 100644 --- a/src/pages-login/pages/sign-up/index.vue +++ b/src/pages-login/pages/sign-up/index.vue @@ -5,7 +5,6 @@ import {useLogicStore} from "@/pages-login/store/module/logic"; import {Agreement} from "@/constant/enums"; import {debounce} from "throttle-debounce"; import Config from "@/config"; -import VerificationCode from "../../components/verification-code.vue"; import {appUserRegisterPost} from "@/service"; import {useUserStore} from "@/store"; @@ -20,17 +19,39 @@ const logicStore = useLogicStore() const isAgreed = ref(false) -const FormSchema = z.object({ - firstName: z.string().min(1, {message: t('pages-login.prompt.first-name')}), - surname: z.string().min(1, {message: t('pages-login.prompt.last-name')}), - phone: z.string().min(1, {message: t('pages-login.prompt.phone-number')}).regex(/^\d{6,11}$/, {message: t('pages-login.prompt.phone-number-verify')}), - loginPwd: z.string().min(1, {message: t('pages-login.prompt.password')}), - email: z.string().email({message: t('pages-login.prompt.email-verify')}), - confirmEmail: z.string().email({message: t('pages-login.prompt.email-verify')}), -}) +function getFormSchema(type: string) { + const base = z.object({ + firstName: z.string().min(1, {message: t('pages-login.prompt.first-name')}), + surname: z.string().min(1, {message: t('pages-login.prompt.last-name')}), + loginPwd: z.string().min(1, {message: t('pages-login.prompt.password')}), + newPwd: z.string().min(1, {message: t('pages-login.prompt.confirm-password')}), + }) + + if (type === 'phone') { + return base.extend({ + phone: z.string().min(1, {message: t('pages-login.prompt.phone-number')}).regex(/^\d{6,11}$/, {message: t('pages-login.prompt.phone-number-verify')}), + }) + .refine((v: any) => v.loginPwd === v.newPwd, { + message: t('pages-login.prompt.two-passwords-inconsistent'), + path: ['newPwd'], + }) + } + + return base.extend({ + email: z.string().email({message: t('pages-login.prompt.email-verify')}), + confirmEmail: z.string().email({message: t('pages-login.prompt.email-verify')}), + }).refine((v) => v.email === v.confirmEmail, { + message: t('pages-login.prompt.confirm-email'), + path: ['confirmEmail'], + }) + .refine((v: any) => v.loginPwd === v.newPwd, { + message: t('pages-login.prompt.two-passwords-inconsistent'), + path: ['newPwd'], + }) +} function checkForm(): boolean { - const validateFormField = FormSchema.safeParse(logicStore.registerForm) + const validateFormField = getFormSchema(logicStore.registerForm.type).safeParse(logicStore.registerForm) if (!validateFormField.success) { const fieldErrorMessage = validateFormField.error.flatten().fieldErrors const errorMessage: string | undefined = R.path([0, 0], R.values(fieldErrorMessage)) @@ -69,7 +90,7 @@ function codeSubmit() { userPort: 2, // 登录端口2 商户端 } }).then((res) => { - userStore.token = res.data.token; + ;(userStore as any).token = (res as any).data?.token; logicStore.reset() uni.showToast({ title: t('pages-login.sign-up.register-success'), @@ -98,6 +119,15 @@ function navigateTo(url: string) { const emailIsReadonly = ref(false) const phoneIsReadonly = ref(false) +const showEmail = computed(() => logicStore.registerForm.type !== 'phone') +const showPhone = computed(() => logicStore.registerForm.type === 'phone') + +onLoad((options: any) => { + const type = options?.type + if (type === 'phone' || type === 'email') { + logicStore.registerForm.type = type + } +}) onMounted(() => { const {email, type} = logicStore.registerForm if (type === 'phone') { @@ -118,7 +148,7 @@ onMounted(() => { - + {{ t("common.email") }} { - + {{ t("pages-login.sign-up.confirm-email") }} @@ -177,6 +207,25 @@ onMounted(() => { + + + {{ t("pages-login.sign-up.confirm-password") }} + + + + + {{ t("pages-login.sign-up.first-name") }} @@ -214,7 +263,7 @@ onMounted(() => { - + {{ t("pages-login.sign-up.phone-number") }} diff --git a/src/pages-login/store/module/logic.ts b/src/pages-login/store/module/logic.ts index fc7256c..1b93e68 100644 --- a/src/pages-login/store/module/logic.ts +++ b/src/pages-login/store/module/logic.ts @@ -16,6 +16,7 @@ export const useLogicStore = defineStore('login-logic', () => { surname: '', phone: '', loginPwd: '', + newPwd: '', areaCode: defaultAreaCode.value, captcha: "", }) @@ -53,6 +54,7 @@ export const useLogicStore = defineStore('login-logic', () => { surname: '', phone: '', loginPwd: '', + newPwd: '', areaCode: defaultAreaCode.value, captcha: "", } @@ -83,6 +85,7 @@ export const useLogicStore = defineStore('login-logic', () => { surname: '', phone: '', loginPwd: '', + newPwd: '', areaCode: defaultAreaCode.value, captcha: "", }