navBar.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div>
  3. <v-toolbar
  4. class="banner"
  5. density="compact"
  6. style="padding-left: 0px;height: 50px;font-size: 14px;"
  7. >
  8. <div class="innerBox d-flex justify-space-between">
  9. <div>
  10. <div class="nav-logo" style="cursor: pointer;" @click="handleLogoClick">
  11. <v-img src="../../assets/logo.png" aspect-ratio="16/9" cover :width="90" style="height: 40px"></v-img>
  12. </div>
  13. <div class="nav-city">
  14. <p class="nav-city-box">
  15. <v-icon color="primary">mdi-map-marker</v-icon>
  16. <span class="nav-city-selected">广州</span>
  17. <span class="switchover-city nav-city-selected">[{{ $t('sys.switchCities') }}]</span>
  18. </p>
  19. </div>
  20. <div class="nav">
  21. <ul>
  22. <li v-for="k in list" :key="k.text">
  23. <a :href="k.path" style="font-size: 14px;">{{ k.text }}</a>
  24. </li>
  25. </ul>
  26. </div>
  27. </div>
  28. <div class="d-flex user-nav">
  29. <div class="btns d-flex align-center" v-if="!getToken()">
  30. <span class="nav-resume-tools">
  31. <a href="">{{ $t('sys.lookingJob') }}</a>
  32. <a href="">{{ $t('sys.recruit') }}</a>
  33. </span>
  34. <v-btn class="half-button" border color="primary" size="small" @click="handleLogin">{{ $t('login.register') }}</v-btn>
  35. </div>
  36. <!-- 头像用户名 -->
  37. <div class="d-flex align-center" v-if="getToken()">
  38. <span style="cursor: pointer;">{{ $t('sys.news') }}</span>
  39. <v-menu open-on-hover>
  40. <template v-slot:activator="{ props }">
  41. <div class="d-flex ml-5 pl-2 align-center cursor-pointer" v-bind="props" @click="handleToPersonalCenter">
  42. <v-avatar>
  43. <v-img alt="John" :src="baseInfo.avatar ?? 'https://cdn.vuetifyjs.com/images/john.jpg'"></v-img>
  44. </v-avatar>
  45. <div class="ml-2">{{ baseInfo.name ?? $t('sys.tourist') }}</div>
  46. </div>
  47. </template>
  48. <v-list>
  49. <v-list-item v-for="(item, index) in items" :key="index" @click="item.change">
  50. <template v-slot:prepend>
  51. <v-icon :icon="item.icon"></v-icon>
  52. </template>
  53. <v-list-item-title>{{ item.title }}</v-list-item-title>
  54. </v-list-item>
  55. </v-list>
  56. </v-menu>
  57. </div>
  58. <!-- 语言切换 -->
  59. <v-menu>
  60. <template v-slot:activator="{ props }">
  61. <v-btn
  62. class="ml-3"
  63. color="primary"
  64. icon="mdi-translate"
  65. size="small"
  66. v-bind="props"
  67. >
  68. </v-btn>
  69. </template>
  70. <v-list density="compact">
  71. <v-list-item
  72. v-for="item in localeStore.localeMap"
  73. :key="item.name"
  74. :value="item.lang"
  75. :active="localeStore.currentLocale.lang === item.lang"
  76. @click="localeStore.setCurrentLocale(item)"
  77. >
  78. <v-list-item-title>{{ item.name }}</v-list-item-title>
  79. </v-list-item>
  80. </v-list>
  81. </v-menu>
  82. </div>
  83. </div>
  84. </v-toolbar>
  85. <Dialog :visible="show" :footer="true" title="企业注册" widthType="1" @close="show = false">
  86. <enterpriseRegister ref="enterpriseRegisterRef"></enterpriseRegister>
  87. </Dialog>
  88. </div>
  89. </template>
  90. <script setup>
  91. import { ref } from 'vue'
  92. import { getToken } from '@/utils/auth'
  93. import { useUserStore } from '@/store/user'
  94. import { useLocaleStore } from '@/store/locale'
  95. defineOptions({ name: 'personal-navbar' })
  96. import Dialog from '@/components/CtDialog'
  97. import enterpriseRegister from '@/views/enterprise/components/register.vue'
  98. defineProps({
  99. sticky: {
  100. type: Boolean,
  101. default: true
  102. }
  103. })
  104. const localeStore = useLocaleStore()
  105. const userStore = useUserStore()
  106. const baseInfo = userStore.baseInfo // 人才信息
  107. const list = ref([
  108. { text: '首页', path: '/home' },
  109. { text: '职位', path: '/recruit/position' },
  110. { text: '公司', path: '/recruit/company' }
  111. ])
  112. import { useRouter } from 'vue-router'
  113. const router = useRouter()
  114. const handleLogoClick = () => { router.push({ path: '/home'}) }
  115. const userType = ref(1) // 0企业用户、1个人用户
  116. const show = ref(false)
  117. const changeRole = () => {
  118. if (userType.value) {
  119. show.value = true
  120. } else {
  121. router.push({ path: '/' })
  122. }
  123. }
  124. const handleToPersonalCenter = () => {
  125. router.push({ path: '/personalCenter' })
  126. }
  127. // 退出登录
  128. const handleLogout = async () => {
  129. // try {
  130. await userStore.userLogout()
  131. router.push({ path: '/login' })
  132. // } catch (error) {
  133. // console.log(error, 'error')
  134. // }
  135. }
  136. const items = ref([
  137. { title: '在线简历', icon: 'mdi-list-box-outline', change: () => router.push({ path: '/resume' }) },
  138. { title: '账号设置', icon: 'mdi-cog-outline', change: () => router.push({ path: '/personalAccount/accountBinding' }) },
  139. { title: '切换为招聘者', icon: 'mdi-swap-horizontal', change: changeRole },
  140. { title: '退出登录', icon: 'mdi-logout', change: handleLogout }
  141. ])
  142. const handleLogin = () => {
  143. router.push({ path: '/login' })
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. @import '@/styles/personal/navBar.scss'
  148. </style>