Commit bfe89019 authored by Step_by_step's avatar Step_by_step

feat 登录改造

parent 223aeb36
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<script> <script>
import login from '@/utils/login' import login from '@/utils/login'
import { post } from '@/utils/http'
export default { export default {
name: "App", name: "App",
...@@ -30,10 +31,14 @@ export default { ...@@ -30,10 +31,14 @@ export default {
}; };
}, },
async mounted() { async mounted() {
localStorage.setItem('userId', 5) localStorage.setItem('userId', 5) // 可删
const TempAccess = import.meta.env.DEV ? 'cb3939fa-8c0a-447d-8842-2d17d7b4555b' : '' 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 } let homePage = { path: "applications", replace: true }
this.getBusinessToken()
if (import.meta.env.PROD) { if (import.meta.env.PROD) {
// 得保证 每个子应用中首页有 title // 得保证 每个子应用中首页有 title
let jumRouter; let jumRouter;
...@@ -59,6 +64,17 @@ export default { ...@@ -59,6 +64,17 @@ export default {
} }
this.$router.push(homePage); 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> </script>
......
...@@ -169,7 +169,7 @@ export function post(url, param = {}) { ...@@ -169,7 +169,7 @@ export function post(url, param = {}) {
method: 'post', method: 'post',
headers: headers, headers: headers,
url, url,
data: param, data: {...param, _token: window.localStorage.getItem('_token')},
}).then((res) => { }).then((res) => {
resolve(res) resolve(res)
}).catch((err) => { }).catch((err) => {
......
...@@ -14,6 +14,7 @@ export function bridgeLogin() { ...@@ -14,6 +14,7 @@ export function bridgeLogin() {
pushExtra: object.pushExtra pushExtra: object.pushExtra
} }
window.localStorage.setItem('userId', object.userId) window.localStorage.setItem('userId', object.userId)
window.localStorage.setItem('phone', object.loginAccount)
resolve(data) 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