navBar.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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" style="cursor: pointer;" @click="handleLogoClick">
  6. <v-img src="../../assets/logo.png" aspect-ratio="16/9" contain :width="97" style="height: 40px"></v-img>
  7. </div>
  8. <div class="d-flex user-nav align-center">
  9. <!-- 企业logo、企业名称 -->
  10. <div class="d-flex align-center cursor-pointer">
  11. <v-img @click="enterpriseClick(2)" rounded contain 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 commonHover">{{ formatName(baseInfo?.enterpriseAnotherName || baseInfo?.enterpriseName) }}</span>
  13. </div>
  14. <div class="enterprise-septal-line"></div>
  15. <div class="cursor-pointer mx-3 commonHover" @click="handleLogout(false)">我要求职</div>
  16. <div class="enterprise-septal-line"></div>
  17. <div class="d-flex align-center mx-3 cursor-pointer commonHover" @click="router.push('/recruit/enterprise/tradingOrder?key=tab_recharge')">
  18. <div>剩余M豆:{{ enterpriseUserAccount?.balance ? enterpriseUserAccount?.balance / 100 : 0 }}个</div>
  19. </div>
  20. <!-- 企业会员标识 -->
  21. <div v-if="baseInfo?.vipFlag && Date.now() < baseInfo?.vipExpireDate" >
  22. <div class="enterprise-septal-line"></div>
  23. <svg-icon name="vip" size="30" class="ml-3"></svg-icon>
  24. </div>
  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 commonHover">{{ formatName(baseInfo?.name ?? baseInfo?.phone) }}</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 class="commonHover2" 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. import { formatName } from '@/utils/getText';
  91. defineOptions({ name: 'personal-navbar' })
  92. defineProps({
  93. sticky: {
  94. type: Boolean,
  95. default: true
  96. }
  97. })
  98. const showBall = ref(false)
  99. onMounted(() => {
  100. if (getToken(1)) {
  101. showBall.value = true
  102. }
  103. })
  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. const enterpriseList = ref([])
  115. const menuList = ref([
  116. { title: t('setting.editPassword'), icon: 'mdi-shield-lock-open-outline', change: () => router.push({ path: '/recruit/enterprise/staffChangePassword' }) },
  117. { title: t('setting.logOut'), icon: 'mdi-logout', change: handleLogout }
  118. ])
  119. const items = computed(() => {
  120. return menuList.value.filter(item => !item.hidden)
  121. })
  122. // 企业logo、用户基本信息
  123. let baseInfo = ref(JSON.parse(localStorage.getItem('entBaseInfo')) || {})
  124. let enterpriseUserAccount = ref(JSON.parse(localStorage.getItem('enterpriseUserAccount')) || {}) // 账户信息
  125. userStore.$subscribe((mutation, state) => {
  126. if (Object.keys(state.entBaseInfo).length) baseInfo.value = state.entBaseInfo
  127. if (Object.keys(state.enterpriseUserAccount).length) enterpriseUserAccount.value = state.enterpriseUserAccount
  128. })
  129. // 语言切换
  130. // const handleChangeLocale = (item) => {
  131. // localeStore.setCurrentLocale(item)
  132. // location.reload()
  133. // }
  134. const test = ref(false)
  135. // 企业列表
  136. const getEnterpriseListData = async () => {
  137. if (!test.value) return
  138. const data = await getUserBindEnterpriseList() // 申请通过才有数据,否则空数组
  139. enterpriseList.value = data || []
  140. }
  141. getEnterpriseListData()
  142. </script>
  143. <style lang="scss" scoped>
  144. .banner {
  145. width: 100%;
  146. height: 50px;
  147. z-index: var(--zIndex-nav) !important;
  148. color: #fff;
  149. background-color: var(--color-d5e6e8);
  150. padding-left: 0px;
  151. height: 50px;
  152. font-size: 15px;
  153. }
  154. .hover:hover {
  155. cursor: pointer;
  156. background: rgba(0, 0, 0, 0.03);
  157. }
  158. .innerBox {
  159. position: relative;
  160. width: 100%;
  161. align-items: center;
  162. padding: 0 30px;
  163. }
  164. .nav-logo {
  165. float: left;
  166. }
  167. .nav {
  168. font-size: 0;
  169. float: left;
  170. margin-left: 50px;
  171. height: 49px;
  172. line-height: 49px;
  173. }
  174. .user-nav {
  175. color: var(--color-333);
  176. font-size: 15px;
  177. }
  178. .enterprise-septal-line {
  179. width: 1px;
  180. display: inline-block;
  181. height: 20px;
  182. vertical-align: middle;
  183. background-color: #fff;
  184. margin: 0 10px;
  185. }
  186. </style>