Commit 563dfdf0 authored by 张牧越's avatar 张牧越

大屏跳转登录

parent b9f395ff
<template> <template>
<div id="app"> <div id="app">
<router-view></router-view> <router-view v-if="signIn"></router-view>
</div> </div>
</template> </template>
<script> <script>
import { getXAccessToken } from "@/api/index";
export default { export default {
name: "App", name: "App",
components: {}, components: {},
methods: {}, data() {
mounted() { return {
signIn: false,
};
},
methods: {
getXAccessToken() {
getXAccessToken(localStorage.getItem("token")).then((res) => {
if (res.status == 200) {
localStorage.setItem("Authorization", res.data.access_token);
this.$nextTick(() => {
this.signIn = true;
});
}
});
},
},
beforeCreate() {
console.log(this.$route);
if (this.$route.query.token_code) { if (this.$route.query.token_code) {
localStorage.setItem("token", this.$route.query.token_code); localStorage.setItem("token", this.$route.query.token_code);
} }
}, },
mounted() {
this.getXAccessToken();
},
}; };
</script> </script>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<span style="font-size: 14px; cursor: pointer" @click="jumpBack" <span style="font-size: 14px; cursor: pointer" @click="jumpBack"
>工程项目后台管理系统</span >工程项目后台管理系统</span
> >
<router-link :to="{ path: '/', query: { token: token } }" exact <router-link :to="{ path: '/', query: { token_code: token } }" exact
>数字工地</router-link >数字工地</router-link
> >
<router-link to="/realname">实名制</router-link> <router-link to="/realname">实名制</router-link>
...@@ -29,13 +29,12 @@ ...@@ -29,13 +29,12 @@
</div> </div>
</div> </div>
</div> </div>
<div v-if="signIn"> <div>
<router-view></router-view> <router-view></router-view>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { getXAccessToken } from "@/api/index";
export default { export default {
name: "Index", name: "Index",
data() { data() {
...@@ -44,7 +43,6 @@ export default { ...@@ -44,7 +43,6 @@ export default {
weekDay: "", weekDay: "",
date: "", date: "",
zoom: 1, zoom: 1,
signIn: false,
}; };
}, },
methods: { methods: {
...@@ -103,16 +101,6 @@ export default { ...@@ -103,16 +101,6 @@ export default {
jumpBack() { jumpBack() {
window.location.href = window.location.origin + "/pweb/m/"; window.location.href = window.location.origin + "/pweb/m/";
}, },
getXAccessToken() {
getXAccessToken(localStorage.getItem("token")).then((res) => {
if (res.status == 200) {
localStorage.setItem("Authorization", res.data.access_token);
this.$nextTick(() => {
this.signIn = true;
});
}
});
},
}, },
computed: { computed: {
token() { token() {
...@@ -122,7 +110,6 @@ export default { ...@@ -122,7 +110,6 @@ export default {
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
this.bodyScale(); this.bodyScale();
this.getXAccessToken();
}); });
this.getTime(); this.getTime();
......
...@@ -64,7 +64,7 @@ request.interceptors.response.use( ...@@ -64,7 +64,7 @@ request.interceptors.response.use(
}) })
} }
if (response.data.status == 401) { if (response.data.status == 401) {
window.location.href = process.env.VUE_APP_RESOURCE_URL + 'pweb/m/login' window.location.href = process.env.VUE_APP_RESOURCE_URL + 'pweb/m/login?is_screen=1'
} }
return response.data return response.data
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment