Commit bfe89019 authored by Step_by_step's avatar Step_by_step

feat 登录改造

parent 223aeb36
......@@ -21,6 +21,7 @@
<script>
import login from '@/utils/login'
import { post } from '@/utils/http'
export default {
name: "App",
......@@ -30,10 +31,14 @@ export default {
};
},
async mounted() {
localStorage.setItem('userId', 5)
const TempAccess = import.meta.env.DEV ? 'cb3939fa-8c0a-447d-8842-2d17d7b4555b' : ''
localStorage.setItem('userId', 5) // 可删
localStorage.setItem('phone', "18388105084")
const TempAccess = import.meta.env.DEV ? 'bcec5d6e-6d4e-4cff-abcc-b5a92ad6b58b' : ''
if (import.meta.env.DEV) window.localStorage.setItem('access_token', TempAccess) // 可删
let homePage = { path: "applications", replace: true }
this.getBusinessToken()
if (import.meta.env.PROD) {
// 得保证 每个子应用中首页有 title
let jumRouter;
......@@ -59,6 +64,17 @@ export default {
}
this.$router.push(homePage);
},
methods: {
async getBusinessToken() {
const baseURL = import.meta.env.DEV ? '/api' : import.meta.env.VITE_HTTP_BASE_URL
let res = await post(`${baseURL}/app/api/app/user/token/get`, {
mobilePhone: window.localStorage.getItem('phone'), loginType: 'HLS_LOGIN', hlsUserId: window.localStorage.getItem('userId'), receivets: + new Date() + ''
})
if (res.success && res.total > 0) {
window.localStorage.setItem('_token', res.rows[0]?.token)
}
}
}
};
</script>
......
......@@ -169,7 +169,7 @@ export function post(url, param = {}) {
method: 'post',
headers: headers,
url,
data: param,
data: {...param, _token: window.localStorage.getItem('_token')},
}).then((res) => {
resolve(res)
}).catch((err) => {
......
......@@ -14,6 +14,7 @@ export function bridgeLogin() {
pushExtra: object.pushExtra
}
window.localStorage.setItem('userId', object.userId)
window.localStorage.setItem('phone', object.loginAccount)
resolve(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