navBar.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div>
  3. <div
  4. class="banner"
  5. density="compact"
  6. style="padding-left: 0px;height: 50px;font-size: 14px;"
  7. >
  8. <div class="innerBox">
  9. <div class="nav-logo">
  10. <v-img src="../../assets/logo.png" aspect-ratio="16/9" cover :width="90" style="height: 40px"></v-img>
  11. </div>
  12. <div class="nav-city">
  13. <p class="nav-city-box">
  14. <v-icon color="primary">mdi-map-marker</v-icon>
  15. <span class="nav-city-selected">广州</span>
  16. <span class="switchover-city nav-city-selected">[切换城市]</span>
  17. </p>
  18. </div>
  19. <div class="nav">
  20. <ul>
  21. <li v-for="k in list" :key="k.text" class="mt-1">
  22. <a :href="k.path" style="font-size: 14px;">{{ k.text }}</a>
  23. </li>
  24. </ul>
  25. </div>
  26. <div class="user-nav" v-if="!getToken()">
  27. <div class="btns">
  28. <span class="nav-resume-tools">
  29. <a href="">我要找工作</a>
  30. <a href="">我要招聘</a>
  31. </span>
  32. <v-btn class="half-button" color="primary" size="small" @click="handleLogin">登录/注册</v-btn>
  33. </div>
  34. </div>
  35. <div v-else class="d-flex user-nav">
  36. <span style="cursor: pointer;">消息</span>
  37. <v-menu open-on-hover>
  38. <template v-slot:activator="{ props }">
  39. <div class="d-flex ml-5 align-center" v-bind="props">
  40. <v-avatar>
  41. <v-img alt="John" src="https://cdn.vuetifyjs.com/images/john.jpg"></v-img>
  42. </v-avatar>
  43. <div class="ml-2">游客</div>
  44. </div>
  45. </template>
  46. <v-list>
  47. <v-list-item v-for="(item, index) in items" :key="index" @click="item.change">
  48. <v-list-item-title>{{ item.title }}</v-list-item-title>
  49. </v-list-item>
  50. </v-list>
  51. </v-menu>
  52. </div>
  53. </div>
  54. </div>
  55. <Dialog :visible="show" :footer="true" title="企业注册" widthType="1" @close="show = false">
  56. <enterpriseRegister ref="enterpriseRegisterRef"></enterpriseRegister>
  57. </Dialog>
  58. </div>
  59. </template>
  60. <script setup>
  61. import { ref } from 'vue'
  62. import { getToken } from '@/utils/auth'
  63. import { userLocaleStore } from '@/store/user'
  64. defineOptions({ name: 'personal-navbar' })
  65. import Dialog from '@/components/CtDialog'
  66. import enterpriseRegister from '@/views/enterprise/components/register.vue'
  67. defineProps({
  68. sticky: {
  69. type: Boolean,
  70. default: true
  71. }
  72. })
  73. const list = ref([
  74. { text: '首页', path: '/home' },
  75. { text: '职位', path: '' },
  76. { text: '公司', path: '' }
  77. ])
  78. import { useRouter } from 'vue-router'
  79. const router = useRouter()
  80. const userType = ref(1) // 0企业用户、1个人用户
  81. const show = ref(false)
  82. const changeRole = () => {
  83. if (userType.value) {
  84. show.value = true
  85. } else {
  86. router.push({ path: '/' })
  87. }
  88. }
  89. // 退出登录
  90. const userStore = userLocaleStore()
  91. const handleLogout = async () => {
  92. // try {
  93. await userStore.userLogout()
  94. router.push({ path: '/login' })
  95. // } catch (error) {
  96. // console.log(error, 'error')
  97. // }
  98. }
  99. const items = ref([
  100. { title: '账号设置', change: () => router.push({ path: '/personalAccount/accountBinding' }) },
  101. { title: '切换为招聘者', change: changeRole },
  102. { title: '退出登录', change: handleLogout }
  103. ])
  104. const handleLogin = () => {
  105. router.push({ path: '/login' })
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. @import '@/styles/personal/navBar.scss'
  110. </style>