navBar.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. <v-list-item-title>{{ item.title }}</v-list-item-title>
  50. </v-list-item>
  51. </v-list>
  52. </v-menu>
  53. </div>
  54. <v-menu>
  55. <template v-slot:activator="{ props }">
  56. <v-btn
  57. class="ml-3"
  58. color="primary"
  59. icon="mdi-translate"
  60. size="small"
  61. v-bind="props"
  62. >
  63. </v-btn>
  64. </template>
  65. <v-list density="compact">
  66. <v-list-item
  67. v-for="item in localeStore.localeMap"
  68. :key="item.name"
  69. :value="item.lang"
  70. :active="localeStore.currentLocale.lang === item.lang"
  71. @click="localeStore.setCurrentLocale(item)"
  72. >
  73. <v-list-item-title>{{ item.name }}</v-list-item-title>
  74. </v-list-item>
  75. </v-list>
  76. </v-menu>
  77. </div>
  78. </div>
  79. </v-toolbar>
  80. <Dialog :visible="show" :footer="true" title="企业注册" widthType="1" @close="show = false">
  81. <enterpriseRegister ref="enterpriseRegisterRef"></enterpriseRegister>
  82. </Dialog>
  83. </div>
  84. </template>
  85. <script setup>
  86. import { ref } from 'vue'
  87. import { getToken } from '@/utils/auth'
  88. import { useUserStore } from '@/store/user'
  89. import { useLocaleStore } from '@/store/locale'
  90. defineOptions({ name: 'personal-navbar' })
  91. import Dialog from '@/components/CtDialog'
  92. import enterpriseRegister from '@/views/enterprise/components/register.vue'
  93. defineProps({
  94. sticky: {
  95. type: Boolean,
  96. default: true
  97. }
  98. })
  99. const localeStore = useLocaleStore()
  100. const list = ref([
  101. { text: '首页', path: '/home' },
  102. { text: '职位', path: '' },
  103. { text: '公司', path: '' }
  104. ])
  105. import { useRouter } from 'vue-router'
  106. const router = useRouter()
  107. const userType = ref(1) // 0企业用户、1个人用户
  108. const show = ref(false)
  109. const changeRole = () => {
  110. if (userType.value) {
  111. show.value = true
  112. } else {
  113. router.push({ path: '/' })
  114. }
  115. }
  116. // 退出登录
  117. const userStore = useUserStore()
  118. const handleLogout = async () => {
  119. // try {
  120. await userStore.userLogout()
  121. router.push({ path: '/login' })
  122. // } catch (error) {
  123. // console.log(error, 'error')
  124. // }
  125. }
  126. const items = ref([
  127. { title: '账号设置', change: () => router.push({ path: '/personalAccount/accountBinding' }) },
  128. { title: '切换为招聘者', change: changeRole },
  129. { title: '退出登录', change: handleLogout }
  130. ])
  131. const handleLogin = () => {
  132. router.push({ path: '/login' })
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. @import '@/styles/personal/navBar.scss'
  137. </style>