封装用户基本信息请求
This commit is contained in:
parent
8f3b56c322
commit
6b6cbd02a3
@ -1,3 +1,4 @@
|
||||
import store from '@/store'
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function login(data) {
|
||||
@ -13,12 +14,14 @@ export function login(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function getInfo(token) {
|
||||
// return request({
|
||||
// url: '/vue-admin-template/user/info',
|
||||
// method: 'get',
|
||||
// params: { token }
|
||||
// })
|
||||
export function getUserInfo() {
|
||||
return request({
|
||||
url: '/sys/profile',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Bearer ${store.getters.token}`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function logout() {
|
||||
|
@ -5,6 +5,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getUserInfo } from '@/api/user'
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
@ -13,6 +14,11 @@ export default {
|
||||
...mapGetters([
|
||||
'name'
|
||||
])
|
||||
},
|
||||
created() {
|
||||
getUserInfo().then(res => {
|
||||
console.log(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user