飞书授权添加系统码 及登录进入页面路由
This commit is contained in:
@@ -20,8 +20,11 @@
|
|||||||
const params = new URLSearchParams(window.location.search)
|
const params = new URLSearchParams(window.location.search)
|
||||||
const companyid = params.get('corp_id')
|
const companyid = params.get('corp_id')
|
||||||
const companyabbr = params.get('corp_abbr')
|
const companyabbr = params.get('corp_abbr')
|
||||||
|
const systemid = params.get('system_id')
|
||||||
|
const system_code = params.get('system_code')
|
||||||
if (companyid) {
|
if (companyid) {
|
||||||
userStore.setCompany(companyid, companyabbr || '')
|
userStore.setCompany(companyid, companyabbr || '')
|
||||||
|
userStore.setSystems(systemid || '', system_code || '')
|
||||||
// 你也可以加 localStorage/sessionStorage 备份
|
// 你也可以加 localStorage/sessionStorage 备份
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ export class UserService {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
//获取 飞书信息
|
//获取 飞书信息
|
||||||
static getfeishuAppList(params: { corp_id: string }) {
|
static getfeishuAppList(params: any) {
|
||||||
return request.get<Api.Brand.BrandInfo>({
|
return request.get<Api.Brand.BrandInfo>({
|
||||||
url: '/common/preset/feishu/app',
|
url: '/common/preset/feishu/app',
|
||||||
params
|
params
|
||||||
|
|||||||
@@ -138,7 +138,8 @@ export const useUserStore = defineStore(
|
|||||||
// 清空所有本地缓存
|
// 清空所有本地缓存
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
sessionStorage.clear()
|
sessionStorage.clear()
|
||||||
|
systemsabbr.value = ''
|
||||||
|
systemsid.value = ''
|
||||||
companyabbr.value = ''
|
companyabbr.value = ''
|
||||||
companyid.value = ''
|
companyid.value = ''
|
||||||
info.value = {}
|
info.value = {}
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ onMounted(async () => {
|
|||||||
const userInfo = await UserService.getUserInfo()
|
const userInfo = await UserService.getUserInfo()
|
||||||
userStore.setUserInfo(userInfo)
|
userStore.setUserInfo(userInfo)
|
||||||
userStore.setLoginStatus(true)
|
userStore.setLoginStatus(true)
|
||||||
router.replace('/')
|
router.push(data.home_url)
|
||||||
|
// router.replace('/')
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
error.value = e?.response?.data?.message || '登录失败,请重试'
|
error.value = e?.response?.data?.message || '登录失败,请重试'
|
||||||
router.replace('/')
|
router.replace('/')
|
||||||
|
|||||||
@@ -36,11 +36,11 @@
|
|||||||
<div class="form">
|
<div class="form">
|
||||||
<!-- 登录方式切换 tab -->
|
<!-- 登录方式切换 tab -->
|
||||||
<div class="login-type-tabs">
|
<div class="login-type-tabs">
|
||||||
<span
|
<!-- <span
|
||||||
:class="{ active: activeLoginType === 'password' }"
|
:class="{ active: activeLoginType === 'password' }"
|
||||||
@click="activeLoginType = 'password'"
|
@click="activeLoginType = 'password'"
|
||||||
>账号密码登录</span
|
>账号密码登录</span
|
||||||
>
|
> -->
|
||||||
<span
|
<span
|
||||||
:class="{ active: activeLoginType === 'qrcode' }"
|
:class="{ active: activeLoginType === 'qrcode' }"
|
||||||
@click="activeLoginType = 'qrcode'"
|
@click="activeLoginType = 'qrcode'"
|
||||||
@@ -255,7 +255,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getfeishuAppList = async () => {
|
const getfeishuAppList = async () => {
|
||||||
feishuresponse.value = await UserService.getfeishuAppList({ corp_id: companyid.value })
|
feishuresponse.value = await UserService.getfeishuAppList({
|
||||||
|
corp_id: companyid.value,
|
||||||
|
system_id: systemsid.value
|
||||||
|
})
|
||||||
if (activeLoginType.value == 'qrcode') {
|
if (activeLoginType.value == 'qrcode') {
|
||||||
feishulogin()
|
feishulogin()
|
||||||
}
|
}
|
||||||
@@ -265,6 +268,9 @@
|
|||||||
const systemsdata = systemsList.value.find((c: any) => c.id === systems)
|
const systemsdata = systemsList.value.find((c: any) => c.id === systems)
|
||||||
systemsid.value = systems
|
systemsid.value = systems
|
||||||
userStore.setSystems(systems, systemsdata?.code)
|
userStore.setSystems(systems, systemsdata?.code)
|
||||||
|
if (companyid.value && systemsid.value) {
|
||||||
|
getfeishuAppList()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//切换公司
|
//切换公司
|
||||||
|
|
||||||
@@ -274,8 +280,10 @@
|
|||||||
companyid.value = company
|
companyid.value = company
|
||||||
iscompany.value = company
|
iscompany.value = company
|
||||||
userStore.setCompany(company, companyt?.abbr)
|
userStore.setCompany(company, companyt?.abbr)
|
||||||
|
if (companyid.value && systemsid.value) {
|
||||||
getfeishuAppList()
|
getfeishuAppList()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (companyabbr != '') {
|
if (companyabbr != '') {
|
||||||
iscompany.value = true
|
iscompany.value = true
|
||||||
getfeishuAppList()
|
getfeishuAppList()
|
||||||
@@ -327,7 +335,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
watch(
|
watch(
|
||||||
(activeLoginType as import('vue').Ref<string>),
|
activeLoginType as import('vue').Ref<string>,
|
||||||
async (val) => {
|
async (val) => {
|
||||||
if (val === 'qrcode') {
|
if (val === 'qrcode') {
|
||||||
userStore.setLoginType('feishu')
|
userStore.setLoginType('feishu')
|
||||||
@@ -390,7 +398,7 @@
|
|||||||
|
|
||||||
// 登录成功处理
|
// 登录成功处理
|
||||||
showLoginSuccessNotice()
|
showLoginSuccessNotice()
|
||||||
router.push(HOME_PAGE)
|
router.push(data.home_url)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 处理 HttpError
|
// 处理 HttpError
|
||||||
if (error instanceof HttpError) {
|
if (error instanceof HttpError) {
|
||||||
@@ -435,10 +443,24 @@
|
|||||||
const companyabbr = Array.isArray(route.query.corp_abbr)
|
const companyabbr = Array.isArray(route.query.corp_abbr)
|
||||||
? route.query.corp_abbr[0]
|
? route.query.corp_abbr[0]
|
||||||
: route.query.corp_abbr
|
: route.query.corp_abbr
|
||||||
|
const system_id = Array.isArray(route.query.system_id)
|
||||||
|
? route.query.system_id[0]
|
||||||
|
: route.query.system_id
|
||||||
|
const system_code = Array.isArray(route.query.system_code)
|
||||||
|
? route.query.system_code[0]
|
||||||
|
: route.query.system_code
|
||||||
if (companyid) {
|
if (companyid) {
|
||||||
userStore.setCompany(companyid as string, (companyabbr as string) || '')
|
userStore.setCompany(companyid as string, (companyabbr as string) || '')
|
||||||
formData.company = Number(companyid)
|
formData.company = Number(companyid)
|
||||||
}
|
}
|
||||||
|
if (system_id) {
|
||||||
|
userStore.setSystems(companyid as string, (system_code as string) || '')
|
||||||
|
formData.systems = Number(system_id)
|
||||||
|
}
|
||||||
|
// 只有两个 id 都有值时才调用
|
||||||
|
if (companyid && systemsid.value) {
|
||||||
|
getfeishuAppList()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 切换主题
|
// 切换主题
|
||||||
|
|||||||
Reference in New Issue
Block a user