| | |
| | | <el-dropdown v-if="userInfo.id" placement="bottom"> |
| | | <el-row align="middle"> |
| | | <Icon icon="fa:user-circle" width="22" height="22" class="mr-2" style="color: #fff" /> |
| | | <el-text class="text-white cursor-p text-lg font-bold">黄婷婷</el-text> |
| | | <el-text class="text-white cursor-p text-lg font-bold">{{ userInfo.nickname }}</el-text> |
| | | <Icon icon="flowbite:caret-down-solid" width="22" height="22" class="ml-2" style="color: #fff" /> |
| | | </el-row> |
| | | <template #dropdown> |
| | |
| | | </el-dropdown-menu> |
| | | </template> |
| | | </el-dropdown> |
| | | <el-button v-else color="#007AFF"> |
| | | <el-text class="text-white cursor-p text-lg font-bold" @click="login">登 录</el-text> |
| | | <el-button @click="login" v-else color="#007AFF"> |
| | | <el-text class="text-white cursor-p text-lg font-bold">登 录</el-text> |
| | | </el-button> |
| | | </el-row> |
| | | </div> |
| | |
| | | import { useSessionStore } from '@/stores/session.js' |
| | | import { useLoginStore } from '@/stores/login.js' |
| | | import { storeToRefs } from 'pinia'; |
| | | |
| | | import { tokenUtils } from '@/utils/axios.js' |
| | | export default { |
| | | setup() { |
| | | const { loginDialogVisible } = storeToRefs(useLoginStore()) |
| | |
| | | }, |
| | | data() { |
| | | return { |
| | | |
| | | } |
| | | }, |
| | | created() { |
| | | const token = localStorage.getItem('accessToken') |
| | | if (token) { |
| | | if (tokenUtils.getAccessToken()) { |
| | | this.getUserInfo() |
| | | } else { |
| | | this.$emit('getUserInfoFlag') |
| | | } |
| | | }, |
| | | methods: { |
| | |
| | | this.loginDialogVisible = true |
| | | }, |
| | | getUserInfo() { |
| | | setTimeout(() => { |
| | | this.setUserInfo({ |
| | | id: '12345', |
| | | username: '黄婷婷' |
| | | }) |
| | | }, 1000) |
| | | this.$axios.get('/system/kw/examinee/profile').then(res => { |
| | | if (res.data.code == 0) { |
| | | const resData = res.data.data || {} |
| | | this.setUserInfo(resData) |
| | | } else { |
| | | this.$message.error(res.data.msg) |
| | | } |
| | | }).finally(() => { |
| | | this.$emit('getUserInfoFlag') |
| | | }) |
| | | }, |
| | | gotoCenter() { |
| | | this.$router.push('/main/center') |
| | |
| | | this.$messageBox.confirm('确定要退出登录吗', '提示', |
| | | { confirmButtonText: '确定', cancelButtonText: '取消', type: 'error' }).then(res => { |
| | | if (res == 'confirm') { |
| | | localStorage.removeItem('accessToken') |
| | | tokenUtils.clearTokens() |
| | | this.setUserInfo({}) |
| | | this.$message.success('退出登录') |
| | | if (this.$route.meta.loginRequired) { |
| | | this.$router.replace('/main/home') |
| | | } |
| | | } |
| | | }) |
| | | } |