Merge remote-tracking branch 'origin/feature/0905_登录注册流程重构' into test

# Conflicts:
#	src/views/components/login/index.vue
This commit is contained in:
rd
2025-09-09 17:28:14 +08:00
24 changed files with 1475 additions and 52 deletions

View File

@ -1,6 +1,6 @@
<template>
<a-config-provider :locale="zhCN" size="small" :theme="redTheme">
<router-view v-if="$route.path === '/login' || ['ExploreList', 'ExploreDetail'].includes($route.name)" />
<router-view v-if="$route.path === '/login' || ['ExploreList', 'ExploreDetail', 'Trial'].includes($route.name)" />
<LayoutBasic v-else />
</a-config-provider>
</template>

View File

@ -72,3 +72,8 @@ export const getImagePreSignedUrl = (params = {}) => {
export const getVideoPreSignedUrl = (params = {}) => {
return Http.get('/v1/oss/video-pre-signed-url', params);
};
// 清除限流
export const postClearRateLimiter = (params = {}) => {
return Http.post(`/v1/rate-limiter/clear`, params);
};

View File

@ -47,3 +47,28 @@ export const fetchBindPhone = (params = {}) => {
export const fetchEnterpriseInfo = (id: number) => {
return Http.get(`/v1/enterprises/${id}`);
};
// 手机密码登录
export const postLoginPassword = (params = {}) => {
return Http.post('/v1/authorizations/password', params);
};
// 用户注册
export const postRegister = (params = {}) => {
return Http.post('/v1/users/register', params);
};
// 发送注册验证码
export const postRegisterCaptcha = (params = {}) => {
return Http.post('/v1/sms/register-captcha', params);
};
// 发送忘记密码验证码
export const postForgetPasswordCaptcha = (params = {}) => {
return Http.post('/v1/sms/forget-password-captcha', params);
};
// 忘记密码
export const postForgetPassword = (params = {}) => {
return Http.post('/v1/users/forget-password', params);
};

View File

@ -60,8 +60,8 @@ export class Request {
this.instance.interceptors.response.use(
(res: AxiosResponse) => {
const { data } = res;
switch (data.code) {
const { data, status } = res;
switch (status) {
case HttpStatusCode.Success:
return data;
default:

Binary file not shown.

After

Width:  |  Height:  |  Size: 738 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 B

View File

@ -8,42 +8,42 @@
width: 560px;
height: 36px;
padding: 0 2px 0 16px;
border-radius: 50px;
background: rgba(255, 255, 255, 0.6);
border-radius: 50px !important;
background-color: rgba(255, 255, 255, 0.6) !important;
backdrop-filter: blur(8px);
border-color: #fff;
border-color: #fff !important;
box-shadow: none;
transition: all 0.3s;
display: flex;
align-items: center;
&.ant-input-affix-wrapper-focused {
border-color: #6d4cfe;
caret-color: #6d4cfe;
border-color: #6d4cfe !important;
caret-color: #6d4cfe !important;
}
&:hover {
border-color: #6d4cfe;
border-color: #6d4cfe !important;
}
.ant-input-suffix {
margin-inline-start: 0;
margin-inline-start: 0 !important;
}
.ant-input {
padding-right: 16px;
border: none !important;
background-color: transparent;
background-color: transparent !important;
box-shadow: none;
font-family: $font-family-regular;
color: #211f24;
font-size: 12px;
font-size: 12px !important;
font-style: normal;
font-weight: 400;
line-height: 20px;
&::placeholder {
color: #939499;
color: #939499 !important;
}
&:focus-within {
&::after {
border-width: 1px;
border-width: 1px !important;
}
}
}

View File

@ -18,7 +18,7 @@ export const router = createRouter({
{
path: '/login',
name: 'UserLogin',
component: () => import('@/views/components/login/index.vue'),
component: () => import('@/views/login/index.vue'),
meta: {
requiresAuth: false,
requireLogin: false,
@ -32,14 +32,23 @@ export const router = createRouter({
requiresAuth: false,
requireLogin: true,
group: GROUP_MAIN_NAME,
}
},
},
{
path: '/chat/:conversationId?',
name: 'Home',
component: () => import('@/views/home/index.vue'),
meta: {
requiresAuth: false,
requiresAuth: true,
requireLogin: true,
},
},
{
path: '/trial',
name: 'Trial',
component: () => import('@/views/trial/index.vue'),
meta: {
requiresAuth: true,
requireLogin: true,
},
},

View File

@ -1,5 +1,5 @@
.ant-btn {
border-radius: 2px !important;
border-radius: 4px !important;
border: 1px solid #d7d7d9 !important;
color: #3c4043 !important;
font-family: $font-family-regular;

View File

@ -6,12 +6,7 @@
background-color: #fff !important;
padding: 0 12px;
}
.ant-input-affix-wrapper {
@include box;
&.ant-input-affix-wrapper-disabled {
background-color: var(--BG-200, #f2f3f5) !important;
}
}
.ant-input,
.ant-input-password {
@include box;
@ -32,7 +27,7 @@
&.ant-input-focus,
&.ant-textarea-focus {
background-color: var(--color-bg-2) !important;
border-color: rgb(var(--primary-6)) !important;
border-color: $color-primary !important;
box-shadow: 0 0 0 0 var(--color-primary-light-2) !important;
}
&.ant-input-disabled {
@ -44,9 +39,11 @@
}
&.ant-input-status-error,
&.ant-input-affix-wrapper-status-error {
&:not(.ant-input-disabled) {
border-color: $color-error !important;
}
}
}
input.ant-input {
height: 32px;
&.ant-input-lg {
@ -62,9 +59,20 @@ textarea.ant-input {
.ant-input-affix-wrapper {
padding-top: 0;
padding-bottom: 0;
@include box;
&.ant-input-affix-wrapper-disabled {
background-color: var(--BG-200, #f2f3f5) !important;
}
&.ant-input-affix-wrapper-status-error {
&:not(.ant-input-affix-wrapper-disabled) {
border-color: $color-error !important;
}
}
&:focus,
&-focused {
box-shadow: none !important;
border-color: $color-primary !important;
}
.ant-input {
height: 30px;

View File

@ -53,4 +53,20 @@
}
}
}
&.ant-steps-dot {
.ant-steps-item-process {
.ant-steps-item-tail {
&::after {
background-color: #e6e6e8 !important;
}
}
}
.ant-steps-item-finish {
.ant-steps-item-tail {
&::after {
background-color: #6d4cfe !important;
}
}
}
}
}

View File

@ -18,27 +18,27 @@
}
.font-family-regular {
font-family: $font-family-regular;
font-family: $font-family-regular !important;
}
.font-family-medium {
font-family: $font-family-medium;
font-family: $font-family-medium !important;
}
.font-family-light {
font-family: $font-family-light;
font-family: $font-family-light !important;
}
.font-family-bold {
font-family: $font-family-bold;
font-family: $font-family-bold !important;
}
.font-family-manrope-regular {
font-family: $font-family-manrope-regular;
font-family: $font-family-manrope-regular !important;
}
.font-family-manrope-medium {
font-family: $font-family-manrope-medium;
font-family: $font-family-manrope-medium !important;
}
.font-family-manrope-bold {
font-family: $font-family-manrope-bold;
font-family: $font-family-manrope-bold !important;
}
.font-family-manrope-semiBold {
font-family: $font-family-manrope-semiBold;
font-family: $font-family-manrope-semiBold !important;
}

View File

@ -0,0 +1,371 @@
<!-- eslint-disable vue/no-duplicate-attributes -->
<template>
<div class="flex items-center w-400 h-100%">
<div class="w-full bg-#fff rounded-16px px-40px py-32px flex flex-col items-center">
<img src="@/assets/img/icon-logo.png" alt="" width="144" height="36" class="mb-24px" />
<Tabs v-model:activeKey="activeKey" class="mb-24px" @change="onTabChange">
<TabPane tab="密码登录" key="1" />
<TabPane tab="短信登录" key="2" />
</Tabs>
<Form ref="formRef" :model="loginForm" :rules="formRules" class="w-320 form-wrap">
<FormItem name="mobile">
<Input
v-model:value="loginForm.mobile"
placeholder="请输入手机号"
allowClear
:maxlength="11"
@change="clearErrorMsg"
/>
</FormItem>
<FormItem v-if="isCaptchaLogin" name="captcha" class="captcha-form-item">
<Input v-model:value="loginForm.captcha" placeholder="请输入验证码" :maxlength="6" @change="clearErrorMsg">
<template #suffix>
<div class="w-79px flex justify-center whitespace-nowrap">
<span
class="color-#939499 font-family-regular text-16px font-400 lh-24px cursor-not-allowed"
:class="{
'!color-#6D4CFE': isLegalMobile || countdown > 0,
'!cursor-pointer': canGetCaptcha,
}"
@click="getCode"
>{{ countdown > 0 ? `${countdown}s` : hasGetCode ? '重新发送' : '发送验证码' }}</span
>
</div>
</template>
</Input>
<p class="color-#F64B31 text-12px font-400 lh-20px font-family-regular" v-show="errMsg">
{{ errMsg }}
</p>
</FormItem>
<FormItem v-else name="password" class="password-form-item">
<Input.Password v-model:value="loginForm.password" placeholder="请输入密码" @change="clearErrorMsg">
<template #iconRender="visible">
<img :src="visible ? icon2 : icon1" width="20" height="20" class="cursor-pointer" />
</template>
</Input.Password>
<p class="color-#F64B31 text-12px font-400 lh-20px font-family-regular" v-show="errMsg">
{{ errMsg }}
</p>
</FormItem>
<FormItem class="mt-52px">
<div class="text-12px flex justify-center items-center mb-16px">
<Checkbox v-model:checked="hasCheck" class="mr-8px"></Checkbox>
<span class="text-12px color-#737478 font-400 lh-20px font-family-regular"
>登录即代表同意<span class="color-#6D4CFE"> 用户协议 </span><span class="color-#6D4CFE">
隐私政策</span
></span
>
</div>
<Button
type="primary"
class="w-full h-48 mb-8px !text-16px !font-500 !rounded-8px btn-login"
:class="disabledSubmitBtn ? 'cursor-no-drop' : 'cursor-pointer'"
:disabled="disabledSubmitBtn"
@click="handleSubmit"
>
登录
</Button>
<div class="flex justify-between btn-row">
<Button
type="text"
class="!color-#939499 !p-0 !h-22px hover:color-#6D4CFE"
size="small"
@click="onForgetPassword"
>
忘记密码
</Button>
<Button
type="text"
class="!color-#939499 !p-0 !h-22px hover:color-#6D4CFE"
size="small"
@click="onRegister"
>
注册
</Button>
</div>
</FormItem>
</Form>
</div>
</div>
<PuzzleVerification
:show="isVerificationVisible"
@submit="handleVerificationSubmit"
@cancel="isVerificationVisible = false"
/>
<SelectAccountModal ref="selectAccountModalRef" :mobileNumber="mobileNumber" :accounts="accounts" />
</template>
<script setup lang="ts">
import {
Checkbox,
Modal,
Button,
Form,
FormItem,
Input,
Space,
message,
Typography,
Card,
List,
Tabs,
} from 'ant-design-vue';
const { Link } = Typography;
const { TabPane } = Tabs;
import PuzzleVerification from '../PuzzleVerification.vue';
import SelectAccountModal from '../select-account-modal/index.vue';
import { fetchLoginCaptCha, fetchAuthorizationsCaptcha, fetchProfileInfo, postLoginPassword } from '@/api/all/login';
import { postClearRateLimiter } from '@/api/all/common';
import { joinEnterpriseByInviteCode } from '@/api/all';
import { ref, reactive, onUnmounted, computed } from 'vue';
import { useUserStore } from '@/stores';
import { useEnterpriseStore } from '@/stores/modules/enterprise';
import { handleUserLogin, goUserLogin } from '@/utils/user';
import router from '@/router';
import { useRoute } from 'vue-router';
import icon1 from '@/assets/img/login/icon-close.png';
import icon2 from '@/assets/img/login/icon-open.png';
const setPageType = inject('setPageType');
const formRef = ref();
const route = useRoute();
const userStore = useUserStore();
const enterpriseStore = useEnterpriseStore();
const countdown = ref(0);
let timer = ref();
const isLogin = ref(true);
const isVerificationVisible = ref(false);
const hasGetCode = ref(false);
const submitting = ref(false);
const hasCheck = ref(false);
const mobileNumber = ref('');
const selectAccountModalRef = ref(null);
const accounts = ref([]);
const activeKey = ref('1');
const isLegalMobile = ref(false);
const errMsg = ref('');
const loginForm = reactive({
mobile: '',
captcha: '',
password: '',
});
// 表单校验规则
const formRules = {
mobile: [
{
required: true,
validator: (_rule: any, value: string) => {
if (!value) {
isLegalMobile.value = false;
// return Promise.reject('手机号不能为空');
}
if (value && !/^1[3-9]\d{9}$/.test(value)) {
isLegalMobile.value = false;
return Promise.reject('手机号格式不正确');
} else {
isLegalMobile.value = true;
return Promise.resolve();
}
},
trigger: ['blur'],
},
],
password: [
{
// required: true,
// validator: (_rule: any, value: string) => {
// if (!value) {
// return Promise.reject('请输入密码');
// }
// if (value.length < 6) {
// return Promise.reject('密码长度不能小于6位');
// }
// return Promise.resolve();
// },
// trigger: ['blur'],
},
],
captcha: [
{
// required: true,
// validator: (_rule: any, value: string) => {
// if (!value) {
// return Promise.reject('请输入验证码');
// }
// if (!/^\d{6}$/.test(value)) {
// return Promise.reject('验证码必须是6位数字');
// } else {
// return Promise.resolve();
// }
// },
// trigger: ['blur'],
},
],
};
const isCaptchaLogin = computed(() => {
return activeKey.value === '2';
});
const canGetCaptcha = computed(() => {
return isLegalMobile.value && countdown.value === 0;
});
const clearErrorMsg = () => {
errMsg.value = '';
};
const disabledSubmitBtn = computed(() => {
if (isCaptchaLogin.value) {
return !hasCheck.value || !isLegalMobile.value || !loginForm.captcha.trim() || !/^\d{6}$/.test(loginForm.captcha);
}
// 密码登录时的验证逻辑
return !hasCheck.value || !isLegalMobile.value || !loginForm.password.trim();
});
const validateField = (field: string) => {
formRef.value.validateFields(field);
};
const clearError = (field: string) => {
formRef.value.clearValidate(field);
};
const getCode = async () => {
if (!canGetCaptcha.value) return;
formRef.value.validateFields('mobile').then(() => {
getCaptcha();
});
};
const getCaptcha = async () => {
try {
const { code, message: msg } = await fetchLoginCaptCha({ mobile: loginForm.mobile });
if (code === 200) {
startCountdown();
message.success(msg);
}
} catch (error) {
// 重置倒计时
countdown.value = 0;
clearInterval(timer.value);
if (error.status === 429) {
isVerificationVisible.value = true;
}
}
};
// 验证码验证通过后
const handleVerificationSubmit = async () => {
isVerificationVisible.value = false;
await postClearRateLimiter();
getCaptcha();
};
const onTabChange = () => {
errMsg.value = '';
};
// 获取用户信息
const getProfileInfo = async () => {
const { code, data } = await fetchProfileInfo();
if (code === 200) {
let enterprises = data['enterprises'];
mobileNumber.value = data['mobile'];
accounts.value = enterprises;
if (enterprises.length > 0) {
enterpriseStore.setEnterpriseInfo(data.enterprises[0]);
if (enterprises.length === 1) {
handleUserLogin();
} else {
// 多个企业时候需要弹窗让用户选择企业
selectAccountModalRef.value.open();
}
}
}
};
// 提交表单
const handleSubmit = async () => {
console.log('handleSubmit', disabledSubmitBtn.value);
if (disabledSubmitBtn.value) return;
try {
// 校验所有字段
await formRef.value.validate();
if (!hasCheck.value) {
message.error('请先勾选同意用户协议');
return;
}
submitting.value = true;
const _fn = isCaptchaLogin.value ? fetchAuthorizationsCaptcha : postLoginPassword;
const { code, data, message: errorInfo } = await _fn(loginForm);
console.log(code, errorInfo);
if (code === 10001) {
errMsg.value = errorInfo;
return;
}
if (code === 200) {
// 处理登录成功逻辑
message.success('登录成功');
userStore.setToken(data.access_token);
const { invite_code } = route.query;
if (invite_code) {
const { code } = await joinEnterpriseByInviteCode(invite_code as string);
if (code === 200) {
message.success('加入企业成功');
}
}
getProfileInfo();
}
} finally {
submitting.value = false;
}
};
// 开始倒计时
const startCountdown = () => {
countdown.value = 60;
hasGetCode.value = true;
timer.value = setInterval(() => {
countdown.value--;
if (countdown.value <= 0) {
clearInterval(timer.value as number);
timer.value = null;
}
}, 1000);
};
const onForgetPassword = () => {
setPageType('resetPasswordForm');
};
const onRegister = () => {
console.log('onRegister');
setPageType('registerForm');
};
onUnmounted(() => {
if (timer.value) {
clearInterval(timer.value);
}
});
</script>
<style scoped lang="scss">
@import './style.scss';
</style>

View File

@ -0,0 +1,34 @@
:deep(.ant-tabs) {
.ant-tabs-nav {
padding: 0;
&::before {
display: none;
}
.ant-tabs-nav-list {
.ant-tabs-tab {
padding: 0 0 4px;
.ant-tabs-tab-btn {
color: #939499;
font-size: 18px;
font-style: normal;
font-weight: 500;
line-height: 26px;
font-family: $font-family-medium;
}
&.ant-tabs-tab-active {
.ant-tabs-tab-btn {
color: #211f24;
}
}
}
.ant-tabs-ink-bar {
border-radius: 4px;
background: var(--Brand-6, #6d4cfe);
width: 24px !important;
height: 4px;
margin-left: 24px;
}
}
}
}

View File

@ -0,0 +1,389 @@
<!-- eslint-disable vue/no-duplicate-attributes -->
<template>
<div class="flex items-center w-400 h-100%">
<div class="w-full bg-#fff rounded-16px px-40px py-32px flex flex-col items-center">
<div class="flex items-center mb-24px w-full cursor-pointer" @click="onBack">
<icon-left size="24" class="mr-4px color-#000" />
<span class="color-#000 text-20px font-500 lh-28px font-family-medium">{{
isResetPassword ? '重置密码' : '手机注册'
}}</span>
</div>
<Form ref="formRef" :model="formData" :rules="formRules" auto-label-width class="w-320 form-wrap">
<FormItem name="mobile">
<Input
v-model:value="formData.mobile"
placeholder="请输入手机号"
allowClear
:maxlength="11"
@change="clearErrorMsg"
/>
</FormItem>
<FormItem name="password" class="password-form-item">
<Input.Password v-model:value="formData.password" placeholder="新密码" @change="clearErrorMsg">
<template #iconRender="visible">
<img :src="visible ? icon2 : icon1" width="20" height="20" class="cursor-pointer" />
</template>
</Input.Password>
</FormItem>
<FormItem name="confirm_password" class="password-form-item">
<Input.Password v-model:value="formData.confirm_password" placeholder="密码确认" @change="clearErrorMsg">
<template #iconRender="visible">
<img :src="visible ? icon2 : icon1" width="20" height="20" class="cursor-pointer" />
</template>
</Input.Password>
</FormItem>
<FormItem name="captcha" class="captcha-form-item">
<Input v-model:value="formData.captcha" placeholder="请输入验证码" :maxlength="6" @change="clearErrorMsg">
<template #suffix>
<div class="w-79px flex justify-center whitespace-nowrap">
<span
class="color-#939499 font-family-regular text-16px font-400 lh-24px cursor-not-allowed"
:class="{
'!color-#6D4CFE': (isPassPassword && isLegalMobile) || countdown > 0,
'!cursor-pointer': canGetCaptcha,
}"
@click="getCode"
>{{ countdown > 0 ? `${countdown}s` : hasGetCode ? '重新发送' : '发送验证码' }}</span
>
</div>
</template>
</Input>
<p class="color-#F64B31 text-12px font-400 lh-20px font-family-regular" v-show="errMsg">
{{ errMsg }}
</p>
</FormItem>
<FormItem class="mt-52px">
<div class="text-12px flex justify-center items-center mb-16px">
<Checkbox v-model:checked="hasCheck" class="mr-8px"></Checkbox>
<span class="text-12px color-#737478 font-400 lh-20px font-family-regular"
>登录即代表同意<span class="color-#6D4CFE"> 用户协议 </span><span class="color-#6D4CFE">
隐私政策</span
></span
>
</div>
<Button
type="primary"
class="w-full h-48 mb-8px !text-16px !font-500 !rounded-8px btn-login"
:class="disabledSubmitBtn ? 'cursor-no-drop' : 'cursor-pointer'"
:disabled="disabledSubmitBtn"
@click="handleSubmit"
>
{{ isResetPassword ? '重置' : '注册' }}
</Button>
</FormItem>
</Form>
</div>
</div>
<PuzzleVerification
:show="isVerificationVisible"
@submit="handleVerificationSubmit"
@cancel="isVerificationVisible = false"
/>
<SelectAccountModal ref="selectAccountModalRef" :mobileNumber="mobileNumber" :accounts="accounts" />
</template>
<script setup lang="js">
import {
Checkbox,
Modal,
Button,
Form,
FormItem,
Input,
Space,
message,
Typography,
Card,
List,
Tabs,
} from 'ant-design-vue';
const { Link } = Typography;
const { TabPane } = Tabs;
import PuzzleVerification from '../PuzzleVerification.vue';
import SelectAccountModal from '../select-account-modal/index.vue';
import { postClearRateLimiter } from '@/api/all/common';
import { postRegisterCaptcha,postForgetPasswordCaptcha, fetchProfileInfo, postRegister, postForgetPassword } from '@/api/all/login';
import { joinEnterpriseByInviteCode } from '@/api/all';
import { ref, reactive, onUnmounted, computed } from 'vue';
import { useUserStore } from '@/stores';
import { useEnterpriseStore } from '@/stores/modules/enterprise';
import { handleUserLogin, goUserLogin } from '@/utils/user';
import router from '@/router';
import { useRoute } from 'vue-router';
import icon1 from '@/assets/img/login/icon-close.png';
import icon2 from '@/assets/img/login/icon-open.png';
const setPageType = inject('setPageType');
const pageType = inject('pageType');
const formRef = ref();
const route = useRoute();
const userStore = useUserStore();
const enterpriseStore = useEnterpriseStore();
const countdown = ref(0);
let timer = ref();
const isLogin = ref(true);
const isVerificationVisible = ref(false);
const hasGetCode = ref(false);
const submitting = ref(false);
const hasCheck = ref(false);
const mobileNumber = ref('');
const selectAccountModalRef = ref(null);
const accounts = ref([]);
const isLegalMobile = ref(false);
const errMsg = ref('');
const formData = ref({
mobile: '',
captcha: '',
password: '',
confirm_password: '',
});
// 表单校验规则
const formRules = {
mobile: [
{
required: true,
validator: (_rule, value) => {
if (!value) {
isLegalMobile.value = false;
}
if (value && !/^1[3-9]\d{9}$/.test(value)) {
isLegalMobile.value = false;
return Promise.reject('手机号格式不正确');
} else {
isLegalMobile.value = true;
return Promise.resolve();
}
},
trigger: ['blur'],
},
],
password: [
{
required: true,
validator: (_rule, value) => {
// if (!value) {
// return Promise.reject('请输入新密码');
// }
// if (value.length < 6) {
// return Promise.reject('密码长度不能小于6位');
// }
if(formData.value.confirm_password) {
formRef.value.validateFields('confirm_password');
}
return Promise.resolve();
},
trigger: ['blur'],
},
],
confirm_password: [
{
required: true,
validator: (_rule, value) => {
// if (!value) {
// return Promise.reject('请输入密码确认');
// }
// if (value.length < 6) {
// return Promise.reject('密码长度不能小于6位');
// }
if (value !== formData.value.password) {
return Promise.reject('确认密码与设置的密码不同');
}
return Promise.resolve();
},
trigger: ['blur'],
},
],
captcha: [
// {
// required: true,
// validator: (_rule, value) => {
// // if (!value) {
// // return Promise.reject('请输入验证码');
// // }
// if (value && !/^\d{6}$/.test(value)) {
// return Promise.reject('验证码必须是6位数字');
// } else {
// return Promise.resolve();
// }
// },
// trigger: ['blur'],
// },
],
};
// 重置密码
const isResetPassword = computed(() => {
return pageType.value === 'resetPasswordForm';
});
const isPassPassword = computed(() => {
return (
formData.value.confirm_password &&
formData.value.password &&
formData.value.confirm_password === formData.value.password
);
});
const canGetCaptcha = computed(() => {
return isLegalMobile.value && countdown.value === 0 && isPassPassword.value;
});
const disabledSubmitBtn = computed(() => {
return !isPassPassword.value || !hasCheck.value || !isLegalMobile.value || !formData.value.password.trim();
});
const clearErrorMsg = () => {
errMsg.value = '';
};
const validateField = (field) => {
formRef.value.validateFields(field);
};
const clearError = (field) => {
formRef.value.clearValidate(field);
};
const getCode = async () => {
if (!canGetCaptcha.value) {
if (!formData.value.mobile.trim()) {
formRef.value.validateFields('mobile');
return;
}
return;
}
formRef.value.validateFields('mobile').then(() => {
getCaptcha();
});
};
const getCaptcha = async () => {
try {
const fn = isResetPassword.value ? postForgetPasswordCaptcha : postRegisterCaptcha;
const { code, message: msg } = await fn({ mobile: formData.value.mobile });
if (code === 200) {
startCountdown()
message.success(msg);
}
} catch (error) {
// 重置倒计时
countdown.value = 0;
clearInterval(timer.value);
if (error.status === 429) {
isVerificationVisible.value = true;
}
}
};
// 验证码验证通过后
const handleVerificationSubmit = async () => {
isVerificationVisible.value = false;
await postClearRateLimiter();
getCaptcha();
};
// 获取用户信息
const getProfileInfo = async () => {
const { code, data } = await fetchProfileInfo();
if (code === 200) {
let enterprises = data['enterprises'];
mobileNumber.value = data['mobile'];
accounts.value = enterprises;
if (enterprises.length > 0) {
enterpriseStore.setEnterpriseInfo(data.enterprises[0]);
if (enterprises.length === 1) {
setTimeout(() => {
handleUserLogin();
}, 1500);
} else {
selectAccountModalRef.value.open();
}
}
}
};
// 提交表单
const handleSubmit = async () => {
if (disabledSubmitBtn.value) return;
try {
// 校验所有字段
await formRef.value.validate();
if (!hasCheck.value) {
message.error('请先勾选同意用户协议');
return;
}
submitting.value = true;
const _fn = isResetPassword.value ? postForgetPassword : postRegister;
const { code, data, message: errorInfo } = await _fn(formData.value);
if (code === 10001) {
errMsg.value = errorInfo;
return;
}
if (code === 200) {
message.success(isResetPassword.value ? '重置成功' : '注册成功');
// 注册成功后跳转登录页
if(!isResetPassword.value) {
setTimeout(() => {
setPageType('loginForm');
}, 1500);
return;
};
userStore.setToken(data.access_token);
const { invite_code } = route.query;
if (invite_code) {
const { code } = await joinEnterpriseByInviteCode(invite_code);
if (code === 200) {
message.success('加入企业成功');
}
}
getProfileInfo();
}
} finally {
submitting.value = false;
}
};
const onBack = () => {
setPageType('loginForm');
};
// 开始倒计时
const startCountdown = () => {
countdown.value = 60;
hasGetCode.value = true;
timer.value = setInterval(() => {
countdown.value--;
if (countdown.value <= 0) {
clearInterval(timer.value );
timer.value = null;
}
}, 1000);
};
onUnmounted(() => {
if (timer.value) {
clearInterval(timer.value);
}
});
</script>
<style scoped lang="scss">
@import './style.scss';
</style>

View File

@ -0,0 +1,171 @@
<template>
<Modal v-model:open="visible" centered unmountOnClose @cancel="handleCancel">
<template #title>
<span style="text-align: left; width: 100%">选择账号</span>
</template>
<div class="account-bind-container">
<Card :bordered="false" class="bind-card">
<div class="bind-header">
<Typography.Text class="mobile-number">{{ mobileNumber }} 已在以下企业绑定了账号</Typography.Text>
</div>
<List :bordered="false" :split="false" class="account-list">
<List.Item
v-for="(account, index) in accounts"
:key="index"
class="account-item"
:class="{
selected: selectedAccountIndex === index,
'cursor-no-drop': account.status === 0,
'cursor-pointer': account.status !== 0,
}"
@click="selectAccount(account, index)"
>
<List.Item.Meta>
<template #title>
<div style="display: flex; align-items: center; gap: 12px">
<Checkbox :checked="selectedAccountIndex === index" />
<Typography.Text>{{ account.name || '-' }}</Typography.Text>
</div>
</template>
</List.Item.Meta>
</List.Item>
</List>
</Card>
</div>
<template #footer>
<div class="flex">
<Button type="primary" @click="handleOk">确定</Button>
</div>
</template>
</Modal>
</template>
<script setup lang="ts">
import { Checkbox, Modal, Button, message, Card, List, Typography } from 'ant-design-vue';
import { handleUserLogin } from '@/utils/user';
import { useEnterpriseStore } from '@/stores/modules/enterprise';
const props = defineProps({
mobileNumber: {
type: String,
default: '',
},
accounts: {
type: Array,
default: () => [],
},
});
const enterpriseStore = useEnterpriseStore();
const visible = ref(false);
const selectedAccountIndex = ref(0);
const open = () => {
visible.value = true;
};
const handleCancel = () => {
visible.value = false;
};
const handleOk = async () => {
visible.value = false;
handleUserLogin();
};
const selectAccount = (account, index) => {
if (account.status === 0) {
return;
}
enterpriseStore.setEnterpriseInfo(account);
selectedAccountIndex.value = index;
};
defineExpose({
open,
});
</script>
<style scoped lang="scss">
.account-bind-container {
width: 100%;
max-width: 400px;
margin: 0 auto;
display: flex;
.bind-card {
background-color: var(--color-bg-2);
width: 100%;
flex-direction: column;
align-items: start;
box-shadow: none;
}
.bind-header {
margin-bottom: 8px;
text-align: left;
}
.phone-number {
font-size: 14px;
color: var(--color-text-4);
text-align: left;
}
.account-list {
margin-top: 16px;
.account-item {
padding: 12px 16px;
margin-bottom: 8px;
background-color: var(--color-bg-2);
border-radius: 4px;
cursor: pointer;
transition: all 0.2s ease;
display: flex;
align-items: center;
}
.account-item {
padding: 12px 16px;
margin-bottom: 8px;
background-color: var(--color-bg-2);
border-radius: 4px;
cursor: pointer;
transition: all 0.2s ease;
border: 1px solid var(--color-border-2);
box-shadow: 0 2px 4px 0 #b1b2b5;
&.selected {
border-color: #6d4cfe;
background-color: rgba(109, 76, 254, 0.1);
box-shadow: 0 2px 4px 0 rgba(109, 76, 254, 0.5);
}
:deep(.ant-list-item-meta-title) {
margin: 0;
}
}
.account-item:deep(.arco-list-item-main) {
padding: 0;
}
:deep(.arco-list-item-actions) {
margin-left: 12px;
}
:deep(.arco-checkbox) {
margin-right: 0;
}
:deep(.arco-checkbox-checked .arco-checkbox-mask) {
background-color: #6d4cfe;
border-color: #6d4cfe;
}
}
}
</style>

40
src/views/login/index.vue Normal file
View File

@ -0,0 +1,40 @@
<!-- eslint-disable vue/no-duplicate-attributes -->
<template>
<div
class="relative w-100vw h-100vh min-h-175 flex justify-center items-center bg-cover bg-center bg-#f0edff login-wrap"
>
<section class="login-bg"></section>
<section class="relative flex justify-between w-1200 h-100% my-0 mx-auto">
<div class="flex flex-col justify-center flex-column h-100% mt--12.5">
<img src="@/assets/img/Frame.svg" class="w-480 h-480 mr-40" alt="" />
</div>
<component :is="pageType === 'loginForm' ? LoginForm : RegisterForm" ref="formRef" :pageType="pageType" />
<section class="login-footer">
<p class="text">闽公网安备 352018502850842 闽ICP备20250520582号 © 2025小题科技</p>
</section>
</section>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import LoginForm from './components/login-form/index.vue';
import RegisterForm from './components/register-form/index.vue';
type ShowPageType = 'loginForm' | 'registerForm' | 'resetPasswordForm';
const pageType = ref<ShowPageType>('loginForm');
const formRef = ref(null);
const setPageType = (val: ShowPageType) => {
pageType.value = val;
};
provide('setPageType', setPageType);
provide('pageType', pageType);
</script>
<style scoped lang="scss">
@import './style.scss';
</style>

View File

@ -1,17 +1,57 @@
.login-wrap {
.arco-input-wrapper,
.arco-select-view-single,
.arco-textarea-wrapper,
.arco-picker,
.arco-select-view-multiple {
border-radius: 4px;
border-color: #d7d7d9 !important;
background-color: #fff !important;
&:focus-within,
&.arco-input-focus {
background-color: var(--color-bg-2);
// border-color: rgb(var(--primary-6));
box-shadow: 0 0 0 0 var(--color-primary-light-2);
:deep(.ant-form) {
.ant-form-item {
&:not(:last-child) {
margin-bottom: 24px !important;
}
.ant-input-affix-wrapper {
height: 48px;
padding: 0 10px;
border-radius: 8px !important;
.ant-input {
border-radius: 8px !important;
font-size: 16px;
font-style: normal;
font-weight: 400;
line-height: 24px;
height: 24px;
}
}
}
.captcha-form-item {
.ant-input-suffix {
position: relative;
&::before {
content: '';
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 0;
width: 1px;
height: 16px;
background-color: #d7d7d9;
}
margin-inline-start: 0;
padding-left: 16px;
// border-left: 1px solid #d7d7d9;
}
}
.password-form-item {
.ant-input-suffix {
cursor: pointer;
padding: 0;
}
}
}
:deep(.btn-login) {
&:disabled {
background-color: #c5b7ff !important;
}
&:not(:disabled) {
&:hover {
background-color: $color-primary-3 !important;
}
}
}
.login-bg {
@ -26,11 +66,6 @@
background-position: center;
background-size: cover;
}
.form-link {
color: #211f24;
font-size: 12px;
margin: 0px;
}
.login-footer {
position: absolute;
@ -64,6 +99,7 @@
width: 100%;
flex-direction: column;
align-items: start;
box-shadow: none;
}
.bind-header {
@ -106,6 +142,9 @@
background-color: rgba(109, 76, 254, 0.1);
box-shadow: 0 2px 4px 0 rgba(109, 76, 254, 0.5);
}
:deep(.ant-list-item-meta-title) {
margin: 0;
}
}
.account-item:deep(.arco-list-item-main) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

221
src/views/trial/index.vue Normal file
View File

@ -0,0 +1,221 @@
<template>
<Layout class="flex justify-center items-center trial-wrap">
<Layout.Header class="header-wrap">
<div class="h-full px-24px">
<div class="w-full h-full relative flex justify-between">
<div class="flex items-center cursor-pointer" @click="handleUserHome">
<img src="@/assets/img/icon-logo.png" alt="" width="96" height="24" />
</div>
<RightSide />
</div>
</div>
</Layout.Header>
<Layout class="flex trial-content items-center">
<div class="w-800px">
<!-- 未建联 -->
<section class="w-full" v-if="status === 1">
<div class="rounded-16px mb-16px bg-#fff px-24px py-16px flex justify-between">
<div class="flex items-center">
<span class="cts !text-18px !lh-26px !color-#000 mr-8px">申请试用</span>
<div class="rounded-2px bg-#F0EDFF px-8px flex items-center">
<span class="cts !color-#6D4CFE">0-3个工作日</span>
</div>
</div>
</div>
<div class="rounded-16px mb-16px bg-#fff p-24px">
<p class="cts !text-16px !lh-24px !color-#000 mb-32px">基本信息</p>
<Form ref="formRef" :model="formData" :rules="formRules" layout="vertical" class="w-full form-wrap">
<FormItem name="name" label="联系人">
<Input
v-model:value="formData.name"
placeholder="请输入您的姓名"
size="large"
allowClear
class="w-500px"
/>
</FormItem>
<FormItem name="company_name" label="公司名称">
<Input
v-model:value="formData.company_name"
placeholder="请输入您的公司名称,个人用户写无"
size="large"
allowClear
class="w-500px"
/>
</FormItem>
<FormItem name="mobile" label="联系电话">
<Input
v-model:value="formData.mobile"
placeholder="请输入您的联系电话"
size="large"
allowClear
class="w-500px"
/>
</FormItem>
</Form>
</div>
<div class="rounded-16px bg-#fff px-24px py-16px">
<Button type="primary" class="mb-10px" @click="handleSubmit">免费申请</Button>
<span class="cts !font-400 !color-#737478"
>申请成功后您可开启
<span class="color-#6D4CFE !font-500">7</span>
天免费试用试用结束后若满意可直接升级正式版数据将自动保留</span
>
</div>
</section>
<!-- 建立商务联系中 -->
<section class="w-full" v-if="status === 2">
<div class="rounded-16px bg-#fff px-36px pt-80px pb-60px flex flex-col items-center">
<img :src="icon2" width="96" height="96" class="mb-8px" />
<p class="cts !text-18px !lh-26px mb-8px">您的试用申请已提交</p>
<p class="cts !font-400 !color-#737478 font-family-regular">
我们将在 1-3 个工作日内完成审核审核结果会通过电话/短信告知您
</p>
<p class="cts !font-400 !color-#737478 font-family-regular mb-40px">
若超过 3 个工作日未收到通知可拨打客服电话 <span class="!color-#6D4CFE">153 5932 0192</span> 咨询
</p>
<div class="px-24px py-16px rounded-12px bg-#F2F3F5 w-full">
<p class="mb-16px cts !color-#000 !text-18px !lh-26px">进度</p>
<Steps :current="1" :items="trialingStepsItems">
<template #progressDot="{ prefixCls }">
<span :class="`${prefixCls}-icon-dot`" />
</template>
</Steps>
</div>
</div>
</section>
<!-- 试用到期 -->
<section class="w-full" v-if="status === 3">
<div class="rounded-16px bg-#fff px-36px pt-80px pb-60px flex flex-col items-center">
<img :src="icon1" width="96" height="96" class="mb-8px" />
<p class="cts !text-18px !lh-26px mb-8px">试用已到期</p>
<p class="cts !font-400 !color-#737478 font-family-regular">
您的 7 天产品试用已到期若想继续使用可拨打客服电话
</p>
<p class="cts !font-400 !color-#737478 font-family-regular mb-40px">
<span class="!color-#6D4CFE">153 5932 0192</span> 咨询续用事宜
</p>
<div class="px-24px py-16px rounded-12px bg-#F2F3F5 w-full">
<p class="mb-16px cts !color-#000 !text-18px !lh-26px">进度</p>
<Steps :current="2" :items="trialEndStepsItems">
<template #progressDot="{ prefixCls }">
<span :class="`${prefixCls}-icon-dot`" />
</template>
</Steps>
</div>
</div>
</section>
</div>
</Layout>
</Layout>
</template>
<script setup lang="ts">
import { Layout, Form, Button, FormItem, Input, Steps } from 'ant-design-vue';
import RightSide from '@/layouts/components/navbar/components/right-side/index.vue';
import { handleUserHome } from '@/utils/user';
import icon1 from './img/icon-info.png';
import icon2 from './img/icon-check.png';
type Status = 1 | 2 | 3;
const formRef = ref();
const submitting = ref(false);
const status = ref<Status>(1);
const formData = ref({
mobile: '',
name: '',
company_name: '',
});
const formRules = {
name: {
required: true,
trigger: ['blur'],
validator: (_rule, value) => {
if (!value) {
return Promise.reject('请填写姓名');
} else {
return Promise.resolve();
}
},
},
company_name: {
required: true,
trigger: ['blur'],
validator: (_rule, value) => {
if (!value) {
return Promise.reject('请填写公司名称');
} else {
return Promise.resolve();
}
},
},
mobile: {
required: true,
trigger: ['blur'],
validator: (_rule, value) => {
if (!value) {
return Promise.reject('请填写联系电话');
} else {
return Promise.resolve();
}
},
},
};
const trialingStepsItems = computed(() => {
return [
{
title: '提交申请',
description: '2025/09/01 12:00:00',
},
{
title: '人工审核',
description: '处理中',
},
{
title: '开始试用',
description: '等待',
},
];
});
const trialEndStepsItems = computed(() => {
return [
{
title: '提交申请',
description: '2025/09/01 12:00:00',
},
{
title: '人工审核',
description: '已完成',
},
{
title: '试用到期',
description: '已完成',
},
];
});
const handleSubmit = async () => {
submitting.value = true;
formRef.value
.validate()
.then(() => {
console.log('验证通过');
})
.finally(() => {
submitting.value = false;
});
};
</script>
<style scoped lang="scss">
@import './style.scss';
</style>

View File

@ -0,0 +1,95 @@
.trial-wrap {
background: transparent;
min-width: 1200px;
.cts {
color: #211f24;
font-family: $font-family-medium;
font-size: 14px;
font-style: normal;
font-weight: 500;
line-height: 22px;
}
:deep(.ant-steps) {
.ant-steps-item {
margin-left: 0;
.ant-steps-item-icon {
width: 10px;
height: 10px;
}
.ant-steps-item-content {
margin-top: 8px;
.ant-steps-item-title {
color: var(--Text-1, #211f24);
font-family: $font-family-regular;
font-size: 16px;
font-style: normal;
font-weight: 400;
line-height: 24px;
}
.ant-steps-item-description {
color: var(--Text-3, #737478);
font-family: $font-family-regular;
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px;
}
}
&.ant-steps-item-wait {
.ant-steps-icon {
.ant-steps-icon-dot {
background: #d7d7d9;
}
}
}
&.ant-steps-item-active,
&.ant-steps-item-finish {
.ant-steps-icon {
.ant-steps-icon-dot {
background: #6d4cfe;
}
}
.ant-steps-item-content {
.ant-steps-item-title {
padding: 0;
font-family: $font-family-medium;
}
}
}
}
}
.header-wrap {
background: transparent;
height: $navbar-height;
line-height: $navbar-height;
padding-inline: inherit;
color: inherit;
width: 100%;
min-width: $layout-min-width;
:deep(.right-wrap) {
.task-icon,
.agent-entry {
display: none;
}
}
}
.trial-content {
width: 100%;
height: 100%;
background: transparent;
min-height: calc(100vh - $navbar-height);
:deep(.ant-form) {
.ant-form-item {
&:not(:last-child) {
margin-bottom: 24px !important;
}
.ant-form-item-label {
> label {
font-family: $font-family-medium;
font-weight: 500;
}
}
}
}
}
}