navBar.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 class="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://minio.citupro.com/dev/menduner/7.png'"></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" color="primary">
  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="handleChangeLocale(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" title="提示" :footer="false" widthType="2" @close="show = false">
  86. <div class="mb-3 text-center" style="color: #999;">
  87. <div class="mb-5">您还未加入或注册企业, 请选择您要操作的类型!</div>
  88. <v-btn class="half-button" size="small" color="primary" variant="tonal" @click="handleChange(0)">加入企业</v-btn>
  89. <v-btn class="half-button ml-5" size="small" color="primary" variant="tonal" @click="handleChange(1)">{{ $t('enterprise.registeringNewEnterprise') }}</v-btn>
  90. </div>
  91. </Dialog> -->
  92. </div>
  93. </template>
  94. <script setup>
  95. import { ref } from 'vue'
  96. import { getToken } from '@/utils/auth'
  97. import { useUserStore } from '@/store/user'
  98. import { useLocaleStore } from '@/store/locale'
  99. import { useI18n } from '@/hooks/web/useI18n'
  100. import { getUserBindEnterpriseList, getUserRegisterEnterpriseApply } from '@/api/personal/user'
  101. defineOptions({ name: 'personal-navbar' })
  102. defineProps({
  103. sticky: {
  104. type: Boolean,
  105. default: true
  106. }
  107. })
  108. const { t } = useI18n()
  109. const localeStore = useLocaleStore()
  110. const userStore = useUserStore()
  111. const list = ref([
  112. { text: t('common.home'), path: '/home' },
  113. { text: t('common.position'), path: '/recruit/position' },
  114. { text: t('common.company'), path: '/recruit/company' }
  115. ])
  116. import { useRouter } from 'vue-router'
  117. const router = useRouter()
  118. const handleLogoClick = () => { router.push({ path: '/home'}) }
  119. // 查看用户是否有企业
  120. const changeLoginType = async () => {
  121. // router.push({ path: '/login' })
  122. // router.push({ name: 'login', query: { loginType: 330 } })
  123. const data = await getUserBindEnterpriseList() // 申请通过才会数据,否则空数组
  124. if (data?.length) {
  125. localStorage.setItem('companyInfo', JSON.stringify(data))
  126. changeRole()
  127. }
  128. else getApplyInfo()
  129. }
  130. // 查看用户是否有在申请中的数据
  131. const getApplyInfo = async () => {
  132. const data = await getUserRegisterEnterpriseApply()
  133. const bool = data && Object.keys(data).length // 已经有数据说明已经申请过了
  134. const path = bool ? '/enterprise/inReview' : '/enterprise/register'
  135. router.push({ path })
  136. }
  137. const handleToPersonalCenter = () => {
  138. router.push({ path: '/personalCenter' })
  139. }
  140. // 退出登录
  141. const handleLogout = async () => {
  142. await userStore.userLogout()
  143. router.push({ path: '/login' })
  144. }
  145. // 切换为招聘者
  146. const changeRole = async () => {
  147. await userStore.userLogout()
  148. router.push({ name: 'login', query: { loginType: 330 } })
  149. }
  150. const items = ref([
  151. { title: t('resume.onlineResume'), icon: 'mdi-list-box-outline', change: () => router.push({ path: '/resume' }) },
  152. { title: t('setting.accountSettings'), icon: 'mdi-cog-outline', change: () => router.push({ path: '/personalAccount/accountBinding' }) },
  153. { title: t('setting.switchToRecruit'), icon: 'mdi-swap-horizontal', change: changeLoginType },
  154. { title: t('setting.logOut'), icon: 'mdi-logout', change: handleLogout }
  155. ])
  156. let baseInfo = ref(JSON.parse(localStorage.getItem('baseInfo')) || {}) // 人才信息
  157. userStore.$subscribe((mutation, state) => {
  158. baseInfo.value = state.baseInfo
  159. })
  160. const handleLogin = () => {
  161. router.push({ path: '/login' })
  162. }
  163. // 语言切换
  164. const handleChangeLocale = (item) => {
  165. localeStore.setCurrentLocale(item)
  166. location.reload()
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. @import '@/styles/personal/navBar.scss'
  171. </style>