<template>
|
<div v-if="userInfo.id">
|
<router-view></router-view>
|
</div>
|
</template>
|
<script>
|
import { useSessionStore } from '@/stores/session.js'
|
import { storeToRefs } from 'pinia'
|
export default {
|
setup() {
|
const { setUserInfo } = useSessionStore()
|
const { userInfo } = storeToRefs(useSessionStore())
|
return { setUserInfo, userInfo }
|
},
|
data() {
|
return {}
|
},
|
computed: {
|
|
},
|
created() {
|
const path = this.$route.path
|
const regionCode = this.$route.query.regionCode //未使用
|
const fullPath = this.$route.fullPath
|
let personType = null
|
if (path == '/h5/addrVer') { //0==工作人员 2==考点核验员
|
personType = '2'
|
} else if (path == '/h5/staffSignIn') {
|
personType = '0'
|
}
|
localStorage.setItem('_personType', personType)
|
localStorage.setItem('_regionCode', regionCode)
|
localStorage.setItem('_enterUrl', fullPath)
|
this.getUserInfo()
|
},
|
methods: {
|
getUserInfo() {
|
this.$axios.get('/system/auth/staff/profile').then(res => {
|
if (res.data.code == 0) {
|
this.setUserInfo(res.data.data || {})
|
} else if (res.data.code != 401) {
|
const tip = res.data.msg || '获取账号信息异常'
|
this.$message.error(tip)
|
this.$router.replace({ path: '/h5/noTask', query: { tip } })
|
}
|
}).catch(() => {
|
const tip = '获取账号信息异常'
|
this.$router.replace({ path: '/h5/noTask', query: { tip }})
|
this.$message.error(tip)
|
})
|
},
|
}
|
}
|
</script>
|