navBar.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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">
  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">[切换城市]</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="">我要找工作</a>
  32. <a href="">我要招聘</a>
  33. </span>
  34. <v-btn class="half-button" border color="primary" size="small" @click="handleLogin">登录/注册</v-btn>
  35. </div>
  36. <div class="d-flex align-center" v-if="getToken()">
  37. <span style="cursor: pointer;">消息</span>
  38. <v-menu open-on-hover>
  39. <template v-slot:activator="{ props }">
  40. <div class="d-flex ml-5 align-center" v-bind="props">
  41. <v-avatar>
  42. <v-img alt="John" src="https://cdn.vuetifyjs.com/images/john.jpg"></v-img>
  43. </v-avatar>
  44. <div class="ml-2">游客</div>
  45. </div>
  46. </template>
  47. <v-list>
  48. <v-list-item v-for="(item, index) in items" :key="index" @click="item.change">
  49. <template v-slot:prepend>
  50. <v-icon :icon="item.icon"></v-icon>
  51. </template>
  52. <v-list-item-title>{{ item.title }}</v-list-item-title>
  53. </v-list-item>
  54. </v-list>
  55. </v-menu>
  56. </div>
  57. <v-menu>
  58. <template v-slot:activator="{ props }">
  59. <v-btn
  60. class="ml-3"
  61. color="primary"
  62. icon="mdi-translate"
  63. size="small"
  64. v-bind="props"
  65. >
  66. </v-btn>
  67. </template>
  68. <v-list density="compact">
  69. <v-list-item
  70. v-for="item in localeStore.localeMap"
  71. :key="item.name"
  72. :value="item.lang"
  73. :active="localeStore.currentLocale.lang === item.lang"
  74. @click="localeStore.setCurrentLocale(item)"
  75. >
  76. <v-list-item-title>{{ item.name }}</v-list-item-title>
  77. </v-list-item>
  78. </v-list>
  79. </v-menu>
  80. </div>
  81. </div>
  82. </v-toolbar>
  83. <Dialog :visible="show" :footer="true" title="企业注册" widthType="1" @close="show = false">
  84. <enterpriseRegister ref="enterpriseRegisterRef"></enterpriseRegister>
  85. </Dialog>
  86. </div>
  87. </template>
  88. <script setup>
  89. import { ref } from 'vue'
  90. import { getToken } from '@/utils/auth'
  91. import { useUserStore } from '@/store/user'
  92. import { useLocaleStore } from '@/store/locale'
  93. defineOptions({ name: 'personal-navbar' })
  94. import Dialog from '@/components/CtDialog'
  95. import enterpriseRegister from '@/views/enterprise/components/register.vue'
  96. defineProps({
  97. sticky: {
  98. type: Boolean,
  99. default: true
  100. }
  101. })
  102. const localeStore = useLocaleStore()
  103. const list = ref([
  104. { text: '首页', path: '/home' },
  105. { text: '职位', path: '/recruit/position' },
  106. { text: '公司', path: '' }
  107. ])
  108. import { useRouter } from 'vue-router'
  109. const router = useRouter()
  110. const userType = ref(1) // 0企业用户、1个人用户
  111. const show = ref(false)
  112. const changeRole = () => {
  113. if (userType.value) {
  114. show.value = true
  115. } else {
  116. router.push({ path: '/' })
  117. }
  118. }
  119. // 退出登录
  120. const userStore = useUserStore()
  121. const handleLogout = async () => {
  122. // try {
  123. await userStore.userLogout()
  124. router.push({ path: '/login' })
  125. // } catch (error) {
  126. // console.log(error, 'error')
  127. // }
  128. }
  129. const items = ref([
  130. { title: '在线简历', icon: 'mdi-list-box-outline', change: () => router.push({ path: '/resume' }) },
  131. { title: '账号设置', icon: 'mdi-cog-outline', change: () => router.push({ path: '/personalAccount/accountBinding' }) },
  132. { title: '切换为招聘者', icon: 'mdi-swap-horizontal', change: changeRole },
  133. { title: '退出登录', icon: 'mdi-logout', change: handleLogout }
  134. ])
  135. const handleLogin = () => {
  136. router.push({ path: '/login' })
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. @import '@/styles/personal/navBar.scss'
  141. </style>