feat(layout): 添加企业邀请码加入功能
- 在 Basic.vue 中添加 JoinModal 组件,用于展示加入企业的模态框 - 添加 checkHasInviteCode 方法,在页面加载时检查邀请码 - 新增 getQueryParam 工具函数,用于获取 URL 参数 - 添加加入企业的相关 API 接口 - 实现 JoinModal 组件,包含加入企业的逻辑和界面
This commit is contained in:
47
src/components/join-modal.vue
Normal file
47
src/components/join-modal.vue
Normal file
@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<Modal title="加入企业" @ok="handleJoin">
|
||||
<div v-if="enterprise" class="join-body flex item-center">
|
||||
<img src="@/assets/warning.svg" alt="" />
|
||||
{{ `确定加入 “${enterprise.name}”吗?` }}
|
||||
</div>
|
||||
</Modal>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import Modal from '@components/modal.vue';
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { getQueryParam } from '@/utils/helper';
|
||||
|
||||
import { getEnterpriseByInviteCode, joinEnterpriseByInviteCode } from '@/api/all';
|
||||
const enterprise = ref();
|
||||
const inviteCode = ref();
|
||||
|
||||
async function getEnterprise() {
|
||||
inviteCode.value = getQueryParam('invite_code');
|
||||
if (inviteCode.value) {
|
||||
enterprise.value = await getEnterpriseByInviteCode(inviteCode.value);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleJoin() {
|
||||
await joinEnterpriseByInviteCode(inviteCode.value);
|
||||
AMessage.success('加入成功');
|
||||
}
|
||||
onMounted(() => {
|
||||
getEnterprise();
|
||||
});
|
||||
</script>
|
||||
<style lang="less">
|
||||
.join-body {
|
||||
margin: 0;
|
||||
font-family: Alibaba PuHuiTi, serif;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: var(--Text-1, rgba(33, 31, 36, 1));
|
||||
img {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-right: 12px;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user