feat: 🚀 钉钉跳转
This commit is contained in:
@@ -7,10 +7,13 @@
|
||||
<script setup lang="ts" name="home">
|
||||
//登录请求接口
|
||||
import { getOrgsApi, getWarehousesListApi } from "@/api/modules/global";
|
||||
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
//用户信息存储
|
||||
import { useUserStore } from "@/stores/modules/user";
|
||||
const userStore = useUserStore();
|
||||
//路由;
|
||||
const $route = useRoute();
|
||||
const $router = useRouter();
|
||||
//获取组织
|
||||
const getOrgs = async () => {
|
||||
const result = await getOrgsApi();
|
||||
@@ -48,6 +51,16 @@ const getWarehousesList = async () => {
|
||||
}
|
||||
};
|
||||
getWarehousesList();
|
||||
|
||||
const init = () => {
|
||||
let redirect_path: any = $route.query.redirect_path;
|
||||
if (redirect_path) {
|
||||
setTimeout(() => {
|
||||
$router.push({ path: redirect_path });
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
init();
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -23,13 +23,18 @@ const loginHttp = async (code: any) => {
|
||||
const result: Record<string, any> = await loginApi(code);
|
||||
if (result.code === 0) {
|
||||
userStore.setToken(result?.data?.access_token);
|
||||
console.log(result?.data?.access_token, "=data.access_token=");
|
||||
// 设置用户信息
|
||||
userStore.setUserInfo(result?.data?.user_data);
|
||||
//设置好了token和用户信息跳转到首页
|
||||
setTimeout(() => {
|
||||
$router.push({ path: "/" });
|
||||
}, 500);
|
||||
let redirect_path: any = $route.query.redirect_path;
|
||||
if (redirect_path) {
|
||||
setTimeout(() => {
|
||||
$router.replace({ path: redirect_path });
|
||||
}, 500);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
$router.replace({ path: "/" });
|
||||
}, 500);
|
||||
}
|
||||
} else {
|
||||
location.href = usePathUrl();
|
||||
}
|
||||
@@ -37,14 +42,20 @@ const loginHttp = async (code: any) => {
|
||||
|
||||
// 登录前的判断
|
||||
const login = () => {
|
||||
const { code } = $route.query;
|
||||
const { code, redirect_path } = $route.query;
|
||||
// 没有code直接跳转到登录页
|
||||
if (!code && redirect_path) {
|
||||
location.href = usePathUrl(redirect_path);
|
||||
return;
|
||||
}
|
||||
if (!code) {
|
||||
location.href = usePathUrl();
|
||||
return;
|
||||
}
|
||||
// 有code就登录请求
|
||||
loginHttp(code);
|
||||
if (code) {
|
||||
loginHttp(code);
|
||||
}
|
||||
};
|
||||
login();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user