navBar.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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">
  15. <!-- <a target="_blank" href="/recruit/enterprise/purchasePackage" class="cursor-pointer mr-5" style="font-size: 15px;color: #FB8C00;line-height: 40px;">{{ $t('vipPackage.purchasePackage') }}</a> -->
  16. <div class="d-flex align-center cursor-pointer" @click="handleEnterpriseClick">
  17. <v-img @click="enterpriseClick(2)" rounded width="40" height="40" :src="baseInfo?.logoUrl || 'https://minio.citupro.com/dev/menduner/7.png'" ></v-img>
  18. <span @click="enterpriseClick(1)" class="ml-3">{{ baseInfo?.enterpriseAnotherName || $t('sys.tourist') }}</span>
  19. </div>
  20. <div class="line"></div>
  21. <div class="d-flex align-center ml-6">
  22. <div>{{ $t('enterprise.account.accountBalances') }}:{{ enterpriseUserAccount?.balance || 0 }}元</div>
  23. <div class="ml-5">{{ $t('enterprise.account.remainingPoints') }}:{{ enterpriseUserAccount?.point || 0 }}点</div>
  24. </div>
  25. <div class="line"></div>
  26. <!-- 头像用户名 -->
  27. <div class="d-flex align-center" v-if="getToken()">
  28. <v-menu open-on-hover>
  29. <template v-slot:activator="{ props }">
  30. <div class="d-flex ml-5 pl-2 align-center cursor-pointer" v-bind="props" @click="handleToPersonalCenter">
  31. <v-avatar>
  32. <v-img alt="" :src="baseInfo?.avatar || 'https://minio.citupro.com/dev/menduner/7.png'"></v-img>
  33. </v-avatar>
  34. <div class="ml-2">{{ baseInfo?.name ?? $t('sys.tourist') }}</div>
  35. </div>
  36. </template>
  37. <v-list>
  38. <v-list-item v-for="(item, index) in items" :key="index" @click="item.change">
  39. <template v-slot:prepend>
  40. <v-icon :icon="item.icon"></v-icon>
  41. </template>
  42. <v-list-item-title>{{ item.title }}</v-list-item-title>
  43. </v-list-item>
  44. </v-list>
  45. </v-menu>
  46. </div>
  47. <!-- 语言切换 -->
  48. <v-menu>
  49. <template v-slot:activator="{ props }">
  50. <v-btn
  51. class="ml-3"
  52. color="primary"
  53. size="small"
  54. icon="mdi-translate"
  55. v-bind="props"
  56. >
  57. </v-btn>
  58. </template>
  59. <v-list density="compact">
  60. <v-list-item
  61. v-for="item in localeStore.localeMap"
  62. :key="item.name"
  63. :value="item.lang"
  64. :active="localeStore.currentLocale.lang === item.lang"
  65. @click="handleChangeLocale(item)"
  66. >
  67. <v-list-item-title>{{ item.name }}</v-list-item-title>
  68. </v-list-item>
  69. </v-list>
  70. </v-menu>
  71. <v-btn size="small" icon="mdi-bell-outline"></v-btn>
  72. </div>
  73. </div>
  74. </v-toolbar>
  75. </div>
  76. </template>
  77. <script setup>
  78. import { ref } from 'vue'
  79. import { getToken } from '@/utils/auth'
  80. import { useUserStore } from '@/store/user'
  81. import { useLocaleStore } from '@/store/locale'
  82. import { useI18n } from '@/hooks/web/useI18n'
  83. defineOptions({ name: 'personal-navbar' })
  84. defineProps({
  85. sticky: {
  86. type: Boolean,
  87. default: true
  88. }
  89. })
  90. const { t } = useI18n()
  91. const localeStore = useLocaleStore()
  92. const userStore = useUserStore()
  93. import { useRouter } from 'vue-router'
  94. const router = useRouter()
  95. const handleLogoClick = () => { router.push({ path: '/recruit/enterprise'}) }
  96. const handleToPersonalCenter = () => {
  97. // router.push({ path: '/recruit/personal/personalCenter' })
  98. }
  99. const handleEnterpriseClick = () => {
  100. // router.push({ path: '/recruit/enterprise/enterpriseCenter?key=mIntroduction' })
  101. }
  102. const enterpriseClick = (tabKey = 1) => {
  103. const path = '/recruit/enterprise/informationManagement/informationSettings'
  104. router.push({ path, query: { tabKey } })
  105. }
  106. // 退出登录
  107. const handleLogout = async () => {
  108. await userStore.userLogout(2)
  109. router.push({ path: '/login' })
  110. }
  111. const items = ref([
  112. { title: t('vipPackage.purchasePackage'), icon: 'mdi-gift-outline', change: () => router.push({ path: '/recruit/enterprise/purchasePackage' }) },
  113. { title: t('enterprise.personalInformationSettings'), icon: 'mdi-account-cog', change: () => router.push({ path: '/recruit/enterprise/informationSettings' }) },
  114. { title: t('setting.switchToJobSeeker'), icon: 'mdi-swap-horizontal', change: handleLogout },
  115. // { title: t('enterprise.account.myAccount'), icon: 'mdi-account', change: () => router.push({ path: '/recruit/enterprise/myAccount' }) },
  116. { title: t('setting.logOut'), icon: 'mdi-logout', change: handleLogout }
  117. ])
  118. // 企业logo、用户基本信息
  119. let baseInfo = ref(JSON.parse(localStorage.getItem('baseInfo')) || {})
  120. let enterpriseUserAccount = ref(JSON.parse(localStorage.getItem('enterpriseUserAccount')) || {}) // 账户信息
  121. userStore.$subscribe((mutation, state) => {
  122. baseInfo.value = state.baseInfo
  123. enterpriseUserAccount.value = state.enterpriseUserAccount
  124. })
  125. // 语言切换
  126. const handleChangeLocale = (item) => {
  127. localeStore.setCurrentLocale(item)
  128. location.reload()
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. .banner {
  133. width: 100%;
  134. height: 50px;
  135. z-index: var(--zIndex-nav) !important;
  136. color: #fff;
  137. background-color: var(--color-d5e6e8);
  138. padding-left: 0px;
  139. height: 50px;
  140. font-size: 15px;
  141. .left {
  142. height: 100%;
  143. display: flex;
  144. align-items: center;
  145. font-size: 20px;
  146. cursor: pointer;
  147. }
  148. }
  149. .hover:hover {
  150. cursor: pointer;
  151. background: rgba(0, 0, 0, 0.03);
  152. }
  153. .innerBox {
  154. position: relative;
  155. width: 100%;
  156. align-items: center;
  157. padding: 0 30px;
  158. }
  159. .nav-logo {
  160. float: left;
  161. }
  162. .nav {
  163. font-size: 0;
  164. float: left;
  165. margin-left: 50px;
  166. height: 49px;
  167. line-height: 49px;
  168. }
  169. .user-nav {
  170. color: var(--v-primary-base);
  171. }
  172. .line {
  173. width: 1px;
  174. height: 25px;
  175. background-color: #fff;
  176. margin: 0 10px;
  177. margin: 8px 0 0 29px;
  178. }
  179. </style>