|
@@ -57,6 +57,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import {getCurrentUser, storageGet, storageSave} from '@/js/index'
|
|
|
+import {notify} from '@/constants/index'
|
|
|
|
|
|
export default {
|
|
|
name: 'header-container',
|
|
@@ -70,18 +72,24 @@ export default {
|
|
|
openNavBarFunc () {
|
|
|
this.openNavBar = !this.openNavBar
|
|
|
},
|
|
|
- getCurrentUser () {
|
|
|
- // Http.get(Apis.USER.GET_CURRENT_USER).then((res) => {
|
|
|
- // sessionStorage.setItem('user', JSON.stringify(res))
|
|
|
- // })
|
|
|
+ setUserInfo () {
|
|
|
+ if (storageGet('user') == null) {
|
|
|
+ getCurrentUser().then((res) => {
|
|
|
+ storageSave('user', res)
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ if (error.status == 401) {
|
|
|
+ notify('error', error.data)
|
|
|
+ } else {
|
|
|
+ notify('error', error.data)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
- getUserIdentity () {
|
|
|
-
|
|
|
- }
|
|
|
},
|
|
|
mounted () {
|
|
|
this.$nextTick(() => {
|
|
|
- this.getCurrentUser()
|
|
|
+ this.setUserInfo()
|
|
|
})
|
|
|
},
|
|
|
}
|