feat: 创建企业逻辑对接
This commit is contained in:
@ -31,10 +31,9 @@ const redTheme = {
|
||||
const init = async () => {
|
||||
const { isLogin } = userStore;
|
||||
|
||||
// 已开通
|
||||
if (isLogin) {
|
||||
await initApp();
|
||||
|
||||
sidebarStore.startUnreadInfoPolling();
|
||||
} else {
|
||||
sidebarStore.stopUnreadInfoPolling();
|
||||
}
|
||||
@ -42,6 +41,7 @@ const init = async () => {
|
||||
|
||||
onMounted(() => {
|
||||
init();
|
||||
|
||||
// 监听全局未处理错误
|
||||
window.addEventListener('unhandledrejection', (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
@ -72,3 +72,18 @@ export const postForgetPasswordCaptcha = (params = {}) => {
|
||||
export const postForgetPassword = (params = {}) => {
|
||||
return Http.post('/v1/users/forget-password', params);
|
||||
};
|
||||
|
||||
// 创建企业
|
||||
export const postCreateEnterprises = (params = {}) => {
|
||||
return Http.post('/v1/enterprises', params);
|
||||
};
|
||||
|
||||
// 获取我的企业列表
|
||||
export const getMyEnterprises = () => {
|
||||
return Http.get('/v1/me/enterprises');
|
||||
};
|
||||
|
||||
// 获取我的主企业信息
|
||||
export const getMyPrimaryEnterprise = () => {
|
||||
return Http.get('/v1/me/primary-enterprise');
|
||||
};
|
||||
@ -1,7 +1,7 @@
|
||||
import router from '@/router';
|
||||
import { defineStore } from 'pinia';
|
||||
import { fetchProfileInfo } from '@/api/all/login';
|
||||
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||
// import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||
import { glsWithCatch, slsWithCatch, rlsWithCatch } from '@/utils/stroage';
|
||||
|
||||
interface UserInfo {
|
||||
@ -10,6 +10,8 @@ interface UserInfo {
|
||||
head_image: String;
|
||||
current_enterprise_id: number;
|
||||
mobile: string;
|
||||
primary_enterprise: any; // 主企业信息
|
||||
[key: string]: any;
|
||||
// 添加其他用户属性...
|
||||
}
|
||||
|
||||
@ -37,6 +39,10 @@ export const useUserStore = defineStore('user', {
|
||||
isLogin(): boolean {
|
||||
return !!this.token;
|
||||
},
|
||||
// 是否开通企业
|
||||
isOpenEnterprise(): boolean {
|
||||
return this.userInfo?.primary_enterprise?.subscribe_status === 1;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
// 设置 Token
|
||||
|
||||
@ -27,20 +27,21 @@ export const getUserEnterpriseInfo = async () => {
|
||||
export async function initApp() {
|
||||
const userStore = useUserStore();
|
||||
const chatStore = useChatStore();
|
||||
|
||||
await chatStore.getAgentInfo(); // 初始化智能体信息
|
||||
const sidebarStore = useSidebarStore();
|
||||
await userStore.getUserInfo(); // 初始化用户信息
|
||||
|
||||
if (!userStore.isOpenEnterprise) return;
|
||||
|
||||
await getUserEnterpriseInfo(); // 初始化企业信息、navbar菜单、允许访问的路由
|
||||
await chatStore.getAgentInfo(); // 初始化智能体信息
|
||||
|
||||
sidebarStore.startUnreadInfoPolling(); // 初始化未读信息
|
||||
}
|
||||
|
||||
// 登录处理
|
||||
export async function handleUserLogin() {
|
||||
const sidebarStore = useSidebarStore();
|
||||
|
||||
await initApp();
|
||||
|
||||
sidebarStore.startUnreadInfoPolling(); // 初始化未读信息
|
||||
|
||||
handleUserHome();
|
||||
}
|
||||
|
||||
|
||||
@ -277,7 +277,9 @@ const onTabChange = () => {
|
||||
const getProfileInfo = async () => {
|
||||
const { code, data } = await fetchProfileInfo();
|
||||
if (code === 200) {
|
||||
let enterprises = data['enterprises'];
|
||||
// 已开通
|
||||
if (data.primary_enterprise?.subscribe_status === 1) {
|
||||
const enterprises = data['enterprises'];
|
||||
mobileNumber.value = data['mobile'];
|
||||
accounts.value = enterprises;
|
||||
|
||||
@ -290,6 +292,9 @@ const getProfileInfo = async () => {
|
||||
selectAccountModalRef.value.open();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
router.push({name: 'Trial'})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -312,7 +317,6 @@ const handleSubmit = async () => {
|
||||
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;
|
||||
|
||||
@ -293,7 +293,9 @@ const handleVerificationSubmit = async () => {
|
||||
const getProfileInfo = async () => {
|
||||
const { code, data } = await fetchProfileInfo();
|
||||
if (code === 200) {
|
||||
let enterprises = data['enterprises'];
|
||||
// 已开通
|
||||
if (data.primary_enterprise?.subscribe_status === 1) {
|
||||
const enterprises = data['enterprises'];
|
||||
mobileNumber.value = data['mobile'];
|
||||
accounts.value = enterprises;
|
||||
|
||||
@ -307,6 +309,9 @@ const getProfileInfo = async () => {
|
||||
selectAccountModalRef.value.open();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
router.push({name: 'Trial'})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<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">
|
||||
<div class="flex items-center">
|
||||
<img src="@/assets/img/icon-logo.png" alt="" width="96" height="24" />
|
||||
</div>
|
||||
<RightSide />
|
||||
@ -13,7 +13,7 @@
|
||||
<Layout class="flex trial-content items-center">
|
||||
<div class="w-800px">
|
||||
<!-- 未建联 -->
|
||||
<section class="w-full" v-if="status === 1">
|
||||
<section class="w-full" v-if="!primary_enterprise">
|
||||
<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>
|
||||
@ -25,18 +25,18 @@
|
||||
<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="联系人">
|
||||
<FormItem name="contact" label="联系人">
|
||||
<Input
|
||||
v-model:value="formData.name"
|
||||
v-model:value="formData.contact"
|
||||
placeholder="请输入您的姓名"
|
||||
size="large"
|
||||
allowClear
|
||||
class="w-500px"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem name="company_name" label="公司名称">
|
||||
<FormItem name="name" label="公司名称">
|
||||
<Input
|
||||
v-model:value="formData.company_name"
|
||||
v-model:value="formData.name"
|
||||
placeholder="请输入您的公司名称,个人用户写无"
|
||||
size="large"
|
||||
allowClear
|
||||
@ -65,7 +65,7 @@
|
||||
</section>
|
||||
|
||||
<!-- 建立商务联系中 -->
|
||||
<section class="w-full" v-if="status === 2">
|
||||
<section class="w-full" v-if="primary_enterprise.audit_status === 1">
|
||||
<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>
|
||||
@ -87,7 +87,7 @@
|
||||
</section>
|
||||
|
||||
<!-- 试用到期 -->
|
||||
<section class="w-full" v-if="status === 3">
|
||||
<section class="w-full" v-if="primary_enterprise.subscribe_status === 4">
|
||||
<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>
|
||||
@ -115,24 +115,28 @@
|
||||
<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 { postCreateEnterprises } from '@/api/all/login';
|
||||
import { exactFormatTime } from '@/utils/tools';
|
||||
import { handleUserHome } from '@/utils/user';
|
||||
import { useUserStore } from '@/stores';
|
||||
|
||||
import icon1 from './img/icon-info.png';
|
||||
import icon2 from './img/icon-check.png';
|
||||
|
||||
type Status = 1 | 2 | 3;
|
||||
// 0-未开通,1-已开通,2-试用中,3-已到期,4-试用结束
|
||||
type Status = 0 | 1 | 2 | 3 | 4;
|
||||
|
||||
const userStore = useUserStore();
|
||||
const formRef = ref();
|
||||
const submitting = ref(false);
|
||||
const status = ref<Status>(1);
|
||||
// const status = ref<Status>(1);
|
||||
const formData = ref({
|
||||
mobile: '',
|
||||
contact: '',
|
||||
name: '',
|
||||
company_name: '',
|
||||
});
|
||||
const formRules = {
|
||||
name: {
|
||||
contact: {
|
||||
required: true,
|
||||
trigger: ['blur'],
|
||||
|
||||
@ -144,7 +148,7 @@ const formRules = {
|
||||
}
|
||||
},
|
||||
},
|
||||
company_name: {
|
||||
name: {
|
||||
required: true,
|
||||
trigger: ['blur'],
|
||||
|
||||
@ -170,11 +174,13 @@ const formRules = {
|
||||
},
|
||||
};
|
||||
|
||||
const primary_enterprise = computed(() => userStore.userInfo?.primary_enterprise);
|
||||
|
||||
const trialingStepsItems = computed(() => {
|
||||
return [
|
||||
{
|
||||
title: '提交申请',
|
||||
description: '2025/09/01 12:00:00',
|
||||
description: exactFormatTime(primary_enterprise.value?.created_at),
|
||||
},
|
||||
{
|
||||
title: '人工审核',
|
||||
@ -190,7 +196,7 @@ const trialEndStepsItems = computed(() => {
|
||||
return [
|
||||
{
|
||||
title: '提交申请',
|
||||
description: '2025/09/01 12:00:00',
|
||||
description: exactFormatTime(primary_enterprise.value?.created_at),
|
||||
},
|
||||
{
|
||||
title: '人工审核',
|
||||
@ -207,8 +213,11 @@ const handleSubmit = async () => {
|
||||
submitting.value = true;
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
console.log('验证通过');
|
||||
.then(async () => {
|
||||
const { code } = await postCreateEnterprises(formData.value);
|
||||
if (code === 200) {
|
||||
userStore.getUserInfo();
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false;
|
||||
|
||||
@ -43,7 +43,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
'/api': {
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||
target: 'https://lingjiapi.lvfunai.com/api',
|
||||
target: 'http://192.168.40.12/api',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user