navBar.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <div>
  3. <v-toolbar class="banner font-size-14 pl-0" density="compact" style="height: 50px;">
  4. <div class="innerBox d-flex justify-space-between">
  5. <div class="nav-logo" @click="handleLogoClick">
  6. <v-img src="../../assets/logo.png" aspect-ratio="16/9" contain width="90" height="35"></v-img>
  7. </div>
  8. <div class="d-flex user-nav align-center">
  9. <!-- 企业logo、企业名称 -->
  10. <div class="d-flex align-center cursor-pointer px-4" :class="{'active-route': route.path.includes('/recruit/enterprise/entInfoSetting')}">
  11. <v-img @click="enterpriseClick(2)" rounded contain class="enterprise-logo" width="40" height="40" :src="baseInfo?.logoUrl || 'https://minio.citupro.com/dev/menduner/company-avatar.png'" ></v-img>
  12. <span @click="enterpriseClick(1)" class="ml-3">{{ formatName(baseInfo?.enterpriseAnotherName || baseInfo?.enterpriseName) }}</span>
  13. <div v-if="baseInfo?.vipFlag && Date.now() < baseInfo?.vipExpireDate" >
  14. <svg-icon name="vip" size="25" class="ml-2"></svg-icon>
  15. </div>
  16. </div>
  17. <v-chip class="ml-4 mr-8" label color="primary" size="small" variant="flat" @click="handleLogout(false)">我要求职</v-chip>
  18. <v-chip
  19. color="primary"
  20. class="cursor-pointer"
  21. label
  22. size="small"
  23. @click="router.push('/recruit/enterprise/tradingOrder?key=tab_recharge')"
  24. >
  25. 剩余M豆
  26. <strong class="ml-3">{{ enterpriseUserAccount?.balance ? enterpriseUserAccount?.balance / 100 : 0 }}个</strong>
  27. </v-chip>
  28. <!-- 头像用户名 -->
  29. <div class="d-flex align-center mx-4" v-if="showBall">
  30. <v-menu open-on-hover>
  31. <template v-slot:activator="{ props }">
  32. <div
  33. class="d-flex align-center cursor-pointer px-4"
  34. v-bind="props"
  35. :class="{'active-route': route.path.includes('/recruit/enterprise/staffInfoSetting')}"
  36. @click="router.push('/recruit/enterprise/staffInfoSetting')"
  37. >
  38. <v-avatar>
  39. <v-img alt="" :src="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)"></v-img>
  40. </v-avatar>
  41. <div class="ml-2">{{ formatName(baseInfo?.name ?? baseInfo?.phone) }}</div>
  42. </div>
  43. </template>
  44. <v-list>
  45. <v-list-item v-for="(item, index) in items" :key="index" @click="item.change">
  46. <template v-slot:prepend>
  47. <v-icon :icon="item.icon"></v-icon>
  48. </template>
  49. <v-list-item-title>{{ item.title }}</v-list-item-title>
  50. </v-list-item>
  51. </v-list>
  52. </v-menu>
  53. </div>
  54. <!-- 语言切换 -->
  55. <!-- <v-menu>
  56. <template v-slot:activator="{ props }">
  57. <v-btn
  58. class="ml-3"
  59. color="primary"
  60. size="small"
  61. icon="mdi-translate"
  62. v-bind="props"
  63. >
  64. </v-btn>
  65. </template>
  66. <v-list density="compact">
  67. <v-list-item
  68. v-for="item in localeStore.localeMap"
  69. :key="item.name"
  70. :value="item.lang"
  71. :active="localeStore.currentLocale.lang === item.lang"
  72. @click="handleChangeLocale(item)"
  73. >
  74. <v-list-item-title>{{ item.name }}</v-list-item-title>
  75. </v-list-item>
  76. </v-list>
  77. </v-menu> -->
  78. <!-- 消息通知 -->
  79. <MessageNotification path="/recruit/enterprise/chatTools"></MessageNotification>
  80. </div>
  81. </div>
  82. </v-toolbar>
  83. </div>
  84. </template>
  85. <script setup>
  86. defineOptions({ name: 'personal-navbar' })
  87. import { ref, onMounted, computed } from 'vue'
  88. import { getToken } from '@/utils/auth'
  89. import { useUserStore } from '@/store/user'; const userStore = useUserStore()
  90. // import { useLocaleStore } from '@/store/locale'; const localeStore = useLocaleStore()
  91. import { useRouter, useRoute } from 'vue-router'; const router = useRouter(); const route = useRoute()
  92. import { useI18n } from '@/hooks/web/useI18n'; const { t } = useI18n()
  93. import MessageNotification from '../message.vue'
  94. import { getUserAvatar } from '@/utils/avatar'
  95. import { formatName } from '@/utils/getText'
  96. // import { logoutToken } from '@/api/common'
  97. defineProps({
  98. sticky: {
  99. type: Boolean,
  100. default: true
  101. }
  102. })
  103. const showBall = ref(false)
  104. const handleLogoClick = () => { window.open('/recruitHome') } // 点击logo
  105. const enterpriseClick = (tabKey = 1) => {
  106. const path = '/recruit/enterprise/entInfoSetting'
  107. router.push({ path, query: { tabKey } })
  108. }
  109. // 退出登录、切换求职者
  110. const handleLogout = async (exit = true) => {
  111. if (exit) await userStore.userLogout(2)
  112. router.push({ path: '/recruitHome' })
  113. }
  114. // 我要求职
  115. // const handleRecruit = async () => {
  116. // // 没有登录个人的则直接清除企业缓存后跳转登录页
  117. // if (!getToken()) {
  118. // await userStore.userLogout(2)
  119. // router.push({ path: '/login' })
  120. // return
  121. // }
  122. // // 有登录个人账号时则清除企业登录缓存后跳转到求职者首页
  123. // await logoutToken(getToken(1))
  124. // const isChangeRole = localStorage.getItem('enterpriseId')
  125. // if (isChangeRole) {
  126. // const perAccountData = JSON.parse(localStorage.getItem('perAccountInfo'))
  127. // localStorage.setItem('accountInfo', JSON.stringify(perAccountData))
  128. // } else localStorage.removeItem('accountInfo')
  129. // // 清除企业相关缓存信息
  130. // const enterpriseLocalStorage = ['ENT_REFRESH_TOKEN', 'ENT_ACCESS_TOKEN', 'entBaseInfo', 'isAdmin', 'enterpriseUserAccount', 'entUpdatePassword', 'emailLoginInfo', 'enterpriseStore', 'enterpriseId']
  131. // enterpriseLocalStorage.forEach(e => localStorage.removeItem(e))
  132. // router.push('/')
  133. // }
  134. const menuList = ref([
  135. { title: t('setting.editPassword'), icon: 'mdi-shield-lock-open-outline', key: 'editPassword', change: () => router.push({ path: '/recruit/enterprise/staffChangePassword' }) },
  136. { title: t('setting.logOut'), icon: 'mdi-logout', change: handleLogout }
  137. ])
  138. const items = computed(() => {
  139. return menuList.value.filter(item => !item.hidden)
  140. })
  141. onMounted(() => {
  142. if (getToken(1)) {
  143. showBall.value = true
  144. }
  145. })
  146. // 企业logo、用户基本信息
  147. let baseInfo = ref(JSON.parse(localStorage.getItem('entBaseInfo')) || {})
  148. let enterpriseUserAccount = ref(JSON.parse(localStorage.getItem('enterpriseUserAccount')) || {}) // 账户信息
  149. userStore.$subscribe((mutation, state) => {
  150. if (Object.keys(state.entBaseInfo).length) baseInfo.value = state.entBaseInfo
  151. if (Object.keys(state.enterpriseUserAccount).length) enterpriseUserAccount.value = state.enterpriseUserAccount
  152. })
  153. // 语言切换
  154. // const handleChangeLocale = (item) => {
  155. // localeStore.setCurrentLocale(item)
  156. // location.reload()
  157. // }
  158. </script>
  159. <style lang="scss" scoped>
  160. .banner {
  161. width: 100%;
  162. height: 50px;
  163. z-index: var(--zIndex-nav) !important;
  164. color: #0E100F;
  165. background-color: #fff;
  166. padding-left: 0px;
  167. height: 50px;
  168. font-size: 15px;
  169. border-bottom: 1px solid #e8e6e6;
  170. }
  171. .innerBox {
  172. position: relative;
  173. width: 100%;
  174. align-items: center;
  175. padding: 0 30px;
  176. }
  177. .nav-logo {
  178. float: left;
  179. cursor: pointer;
  180. margin-bottom: 1px;
  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(--color-333);
  191. font-size: 15px;
  192. }
  193. .enterprise-logo {
  194. border: 1px solid #E1E4E9;
  195. border-radius: 4px;
  196. }
  197. .active-route {
  198. color: #00B760;
  199. font-weight: 700;
  200. border-bottom: 4px solid #00B760;
  201. background-color: #e5f8ef;
  202. height: 50px;
  203. }
  204. :deep(.v-toolbar__content) {
  205. height: 50px !important;
  206. }
  207. :deep(.v-chip.v-chip--size-small) {
  208. height: 30px !important;
  209. }
  210. </style>