navBar.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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>
  14. <div class="d-flex user-nav align-center">
  15. <div class="d-flex align-center cursor-pointer">
  16. <v-img @click="enterpriseClick(2)" rounded width="40" height="40" :src="baseInfo?.logoUrl || 'https://minio.citupro.com/dev/menduner/company-avatar.png'" ></v-img>
  17. <span @click="enterpriseClick(1)" class="ml-3">{{ baseInfo?.enterpriseAnotherName || baseInfo?.enterpriseName || '--' }}</span>
  18. </div>
  19. <div class="ml-3 cursor-pointer border-left border-right px-3 active" @click="handleLogout">我要求职</div>
  20. <div class="cursor-pointer border-right px-3 active" @click="router.push('/recruit/enterprise/hirePosition')">全员猎聘</div>
  21. <div class="d-flex align-center px-3 border-right">
  22. <div>{{ $t('enterprise.account.remainingPoints') }}:{{ enterpriseUserAccount?.balance || 0 }}点</div>
  23. </div>
  24. <svg-icon @click="handleToVip" name="vip" size="30" class="cursor-pointer ml-3"></svg-icon>
  25. <!-- 头像用户名 -->
  26. <div class="d-flex align-center" v-if="showBall">
  27. <v-menu open-on-hover>
  28. <template v-slot:activator="{ props }">
  29. <div class="d-flex ml-3 pl-2 align-center cursor-pointer" v-bind="props">
  30. <v-avatar>
  31. <v-img alt="" :src="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)"></v-img>
  32. </v-avatar>
  33. <div class="ml-2">{{ baseInfo?.name ?? $t('sys.tourist') }}</div>
  34. </div>
  35. </template>
  36. <v-list>
  37. <v-list-item v-for="(item, index) in items" :key="index" @click="item.change">
  38. <template v-slot:prepend>
  39. <v-icon :icon="item.icon"></v-icon>
  40. </template>
  41. <v-list-item-title>{{ item.title }}</v-list-item-title>
  42. </v-list-item>
  43. </v-list>
  44. </v-menu>
  45. </div>
  46. <!-- 语言切换 -->
  47. <!-- <v-menu>
  48. <template v-slot:activator="{ props }">
  49. <v-btn
  50. class="ml-3"
  51. color="primary"
  52. size="small"
  53. icon="mdi-translate"
  54. v-bind="props"
  55. >
  56. </v-btn>
  57. </template>
  58. <v-list density="compact">
  59. <v-list-item
  60. v-for="item in localeStore.localeMap"
  61. :key="item.name"
  62. :value="item.lang"
  63. :active="localeStore.currentLocale.lang === item.lang"
  64. @click="handleChangeLocale(item)"
  65. >
  66. <v-list-item-title>{{ item.name }}</v-list-item-title>
  67. </v-list-item>
  68. </v-list>
  69. </v-menu> -->
  70. <!-- 消息通知 -->
  71. <MessageNotification path="/recruit/enterprise/chatTools"></MessageNotification>
  72. </div>
  73. </div>
  74. </v-toolbar>
  75. </div>
  76. </template>
  77. <script setup>
  78. import {
  79. getUserBindEnterpriseList,
  80. // getUserRegisterEnterpriseApply
  81. } from '@/api/personal/user'
  82. import { computed, ref, onMounted } from 'vue'
  83. import { getToken } from '@/utils/auth'
  84. import { useUserStore } from '@/store/user'; const userStore = useUserStore()
  85. // import { useLocaleStore } from '@/store/locale'; const localeStore = useLocaleStore()
  86. import { useRouter } from 'vue-router'; const router = useRouter()
  87. import { useI18n } from '@/hooks/web/useI18n'; const { t } = useI18n()
  88. import MessageNotification from '../message.vue'
  89. import { getUserAvatar } from '@/utils/avatar'
  90. defineOptions({ name: 'personal-navbar' })
  91. defineProps({
  92. sticky: {
  93. type: Boolean,
  94. default: true
  95. }
  96. })
  97. const showBall = ref(false)
  98. onMounted(() => {
  99. if (getToken()) {
  100. showBall.value = true
  101. }
  102. })
  103. const handleToVip = () => {
  104. router.push({ path: '/recruit/enterprise/memberCenter/myMembers' })
  105. }
  106. // const handleLogoClick = () => { router.push({ path: '/recruit/enterprise'}) }
  107. const handleLogoClick = () => { window.open('/') } // 点击logo
  108. const enterpriseClick = (tabKey = 1) => {
  109. const path = '/recruit/enterprise/informationManagement/informationSettings'
  110. router.push({ path, query: { tabKey } })
  111. }
  112. // 退出登录
  113. const handleLogout = async () => {
  114. await userStore.userLogout(2)
  115. router.push({ path: '/login' })
  116. }
  117. const enterpriseList = ref([])
  118. const menuList = ref([
  119. { title: t('enterprise.account.myAccount'), icon: 'mdi-account', change: () => router.push({ path: '/recruit/enterprise/memberCenter/myAccount' }) },
  120. { title: t('vipPackage.purchasePackage'), icon: 'mdi-gift-outline', change: () => window.open('/recruit/enterprise/purchasePackage') },
  121. { title: t('enterprise.personalInformationSettings'), icon: 'mdi-account-cog', change: () => router.push({ path: '/recruit/enterprise/informationSettings' }) },
  122. // { title: t('setting.switchToOtherCompany'), icon: 'mdi-home-switch', hidden: enterpriseList.value?.length < 2, change: () => handleSwitchToAnotherEnterprise },
  123. // { title: t('enterprise.registeringNewEnterprise'), icon: 'mdi-home-plus-outline', change: () => handleRegisteringNewEnterprise },
  124. // { title: t('setting.switchToJobSeeker'), icon: 'mdi-swap-horizontal', change: handleLogout },
  125. { title: t('setting.logOut'), icon: 'mdi-logout', change: handleLogout }
  126. ])
  127. const items = computed(() => {
  128. return menuList.value.filter(item => !item.hidden)
  129. })
  130. // 企业logo、用户基本信息
  131. let baseInfo = ref(JSON.parse(localStorage.getItem('entBaseInfo')) || {})
  132. let enterpriseUserAccount = ref(JSON.parse(localStorage.getItem('enterpriseUserAccount')) || {}) // 账户信息
  133. userStore.$subscribe((mutation, state) => {
  134. baseInfo.value = state.baseInfo
  135. enterpriseUserAccount.value = state.enterpriseUserAccount
  136. })
  137. // 语言切换
  138. // const handleChangeLocale = (item) => {
  139. // localeStore.setCurrentLocale(item)
  140. // location.reload()
  141. // }
  142. const test = ref(false)
  143. // 企业列表
  144. const getEnterpriseListData = async () => {
  145. if (!test.value) return
  146. const data = await getUserBindEnterpriseList() // 申请通过才有数据,否则空数组
  147. enterpriseList.value = data || []
  148. }
  149. getEnterpriseListData()
  150. </script>
  151. <style lang="scss" scoped>
  152. .banner {
  153. width: 100%;
  154. height: 50px;
  155. z-index: var(--zIndex-nav) !important;
  156. color: #fff;
  157. background-color: var(--color-d5e6e8);
  158. padding-left: 0px;
  159. height: 50px;
  160. font-size: 15px;
  161. .left {
  162. height: 100%;
  163. display: flex;
  164. align-items: center;
  165. font-size: 20px;
  166. cursor: pointer;
  167. }
  168. }
  169. .hover:hover {
  170. cursor: pointer;
  171. background: rgba(0, 0, 0, 0.03);
  172. }
  173. .innerBox {
  174. position: relative;
  175. width: 100%;
  176. align-items: center;
  177. padding: 0 30px;
  178. }
  179. .nav-logo {
  180. float: left;
  181. }
  182. .nav {
  183. font-size: 0;
  184. float: left;
  185. margin-left: 50px;
  186. height: 49px;
  187. line-height: 49px;
  188. }
  189. .user-nav {
  190. color: var(--v-primary-base);
  191. }
  192. .border-left {
  193. border-left: 1px solid #fff;
  194. }
  195. .border-right {
  196. border-right: 1px solid #fff;
  197. }
  198. .active:hover {
  199. text-decoration: underline;
  200. }
  201. </style>