Navbar.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  1. <template>
  2. <div class="navbar">
  3. <div class="pageTitle">{{ this.$route.meta.title }}</div>
  4. <!--收缩左侧菜单按钮-->
  5. <!-- <hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
  6. <hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" /> -->
  7. <!-- <breadcrumb id="breadcrumb-container" class="breadcrumb-container" /> -->
  8. <div class="right-menu">
  9. <!--搜索,全屏,大小写转换和翻译-->
  10. <!-- <template v-if="device!=='mobile'">
  11. <search id="header-search" class="right-menu-item" />
  12. <error-log class="errLog-container right-menu-item hover-effect" />
  13. <screenfull id="screenfull" class="right-menu-item hover-effect" />
  14. <el-tooltip :content="$t('navbar.size')" effect="dark" placement="bottom">
  15. <size-select id="size-select" class="right-menu-item hover-effect" />
  16. </el-tooltip>
  17. <lang-select class="right-menu-item hover-effect" />
  18. </template> -->
  19. <div class="noticeIconBox">
  20. <img src="@/assets/public/nav/notice1.png" class="noticeIconImg" @click="showTabs = !showTabs" />
  21. <span class="unreadCount">{{ msg.count }}</span>
  22. <!-- <img src="@/assets/public/nav/arrowDown.png" class="arrowDown" /> -->
  23. <div class="noticeTabsBox" v-if="showTabs" ref="noticeTabsBox">
  24. <div class="noticeTabsTitleBox">
  25. <div :class="{ 'noticeTabs': true, 'active': tabsIndex == 1 }" @click="changeTabs(1)">
  26. <div class="noticeTabsItem">
  27. 资讯
  28. <span class="noticeMessageNew" v-if="msg.apply_articale.length > 0"></span>
  29. </div>
  30. </div>
  31. <div :class="{ 'noticeTabs': true, 'active': tabsIndex == 2 }" @click="changeTabs(2)">
  32. <div class="noticeTabsItem">
  33. 商品
  34. <span class="noticeMessageNew" v-if="msg.good.length > 0"></span>
  35. </div>
  36. </div>
  37. <div :class="{ 'noticeTabs': true, 'active': tabsIndex == 4 }" @click="changeTabs(4)">
  38. <div class="noticeTabsItem">
  39. 书刊
  40. <span class="noticeMessageNew" v-if="msg.book.length > 0"></span>
  41. </div>
  42. </div>
  43. <div :class="{ 'noticeTabs': true, 'active': tabsIndex == 3 }" @click="changeTabs(3)">
  44. <div class="noticeTabsItem">
  45. 求职招聘
  46. <span class="noticeMessageNew"
  47. v-if="msg.job_hunting.length > 0 || msg.job_recruiting.length > 0 || msg.job_apply.length > 0 || msg.job_resume.length > 0">
  48. </span>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="noticeTabsLine" v-if="tabsIndex == 3" style="height: 20px; margin: 0px; margin-top: -20px;">
  53. <ul class="noticeTabsLink">
  54. <li v-if="userType == 1">
  55. 求职
  56. </li>
  57. <li v-if="userType == 3">
  58. 招聘
  59. </li>
  60. </ul>
  61. <ul class="noticeTabsLink" v-if="userType == 10000">
  62. <li v-if="qiu" @click="changeJob(1)">
  63. 求职
  64. <img src="@/assets/public/nav/arrowDown.png" class="arrowDown" />
  65. </li>
  66. <li v-if="zhao" @click="changeJob(2)">
  67. 招聘
  68. <img src="@/assets/public/nav/arrowDown.png" class="arrowDown" />
  69. </li>
  70. </ul>
  71. </div>
  72. <div class="noticeTabsLinkLine">
  73. <div v-if="userType == 10000 || userType == 1 || userType == 3">
  74. <div v-if="tabsIndex == 1" @click="goToPath(1, 0)">待审核列表</div>
  75. <div v-if="tabsIndex == 2" @click="goToPath(2, 0)">待审核列表</div>
  76. <div class="qiuFlex" v-if="tabsIndex == 3 && qiu == true && (userType == 10000 || userType == 1)"
  77. @click="goToPath(3, 0)">
  78. <span :class="{ 'qiuPillow': true, 'qiuPillowHover': qiu1 == true }" @mouseover="handleQiu(1)"
  79. @click="goToPath(3.1, 0)">待审核列表</span>
  80. <span :class="{ 'qiuPillow': true, 'qiuPillowHover': qiu2 == true }" @mouseover="handleQiu(2)"
  81. @click="goToPath(3.2, 0)">职场机会</span>
  82. </div>
  83. <div class="qiuFlex" v-if="tabsIndex == 3 && zhao == true && (userType == 10000 || userType == 3)"
  84. @click="goToPath(3, 0)">
  85. <span :class="{ 'qiuPillow': true, 'qiuPillowHover': zhao1 == true }" @mouseover="handleQiu(3)"
  86. @click="goToPath(3.3, 0)">待审核列表</span>
  87. <span :class="{ 'qiuPillow': true, 'qiuPillowHover': zhao2 == true }" @mouseover="handleQiu(4)"
  88. @click="goToPath(3.4, 0)">人才库</span>
  89. </div>
  90. <div v-if="tabsIndex == 4" @click="goToPath(4, 0)">待审核列表</div>
  91. </div>
  92. <div v-else>
  93. <div v-if="tabsIndex == 1" @click="goToPath(1, -1)">资讯列表</div>
  94. <div v-if="tabsIndex == 2" @click="goToPath(2, -1)">商品列表</div>
  95. <div v-if="tabsIndex == 3" @click="goToPath(3, -1)">求职招聘列表</div>
  96. <div v-if="tabsIndex == 4" @click="goToPath(4, -1)">书刊列表</div>
  97. </div>
  98. </div>
  99. <div class="noticeTabsDataBox" v-if="tabsIndex == 1">
  100. <div v-if="msg.apply_articale && msg.apply_articale.length > 0">
  101. <div class="noticeTabsDataItem" v-for="item in msg.apply_articale" :key="item.id"
  102. @click="goToPath(1, item.id)">
  103. <div class="noticeTabsDataItemImg newsIcon">
  104. <img src="@/assets/public/nav/message-news.png">
  105. </div>
  106. <div class="noticeTabsDataItemContent">
  107. <div class="noticeNewsTitle">{{ item.title }}</div>
  108. <div class="noticeNewsTime">{{ item.updated_at }}</div>
  109. </div>
  110. </div>
  111. </div>
  112. <div v-else class="noticeTabsDataItemEmpty">
  113. <div class="noticeEmpty">
  114. <img src="@/assets/public/nav/message-empty.png">
  115. </div>
  116. <div class="noticeEmptyText">
  117. 暂无消息
  118. </div>
  119. </div>
  120. </div>
  121. <div class="noticeTabsDataBox" v-if="tabsIndex == 2">
  122. <div v-if="msg.good && msg.good.length > 0">
  123. <div class="noticeTabsDataItem" v-for="item in msg.good" :key="item.id" @click="goToPath(2, item.id)">
  124. <div class="noticeTabsDataItemImg newsIcon">
  125. <img src="@/assets/public/nav/message-news.png">
  126. </div>
  127. <div class="noticeTabsDataItemContent">
  128. <div class="noticeNewsTitle">{{ item.name }}</div>
  129. <div class="noticeNewsTime">{{ item.updated_at }}</div>
  130. </div>
  131. </div>
  132. </div>
  133. <div v-else class="noticeTabsDataItemEmpty">
  134. <div class="noticeEmpty">
  135. <img src="@/assets/public/nav/message-empty.png">
  136. </div>
  137. <div class="noticeEmptyText">
  138. 暂无消息
  139. </div>
  140. </div>
  141. </div>
  142. <!-- 求职信息 待审核 -->
  143. <div class="noticeTabsDataBox" v-if="tabsIndex == 3 && qiu == true && qiu1 == true && userType == 10000">
  144. <div v-if="msg.job_hunting && msg.job_hunting.length > 0">
  145. <div class="noticeTabsDataItem" v-for="item in msg.job_hunting" :key="item.id"
  146. @click="goToPath(3.1, item.id)">
  147. <!-- 待审核求职 -->
  148. <div class="noticeTabsDataItemImg newsIcon">
  149. <img src="@/assets/public/nav/message-news.png">
  150. </div>
  151. <div class="noticeTabsDataItemContent">
  152. <div class="noticeNewsTitle">{{ item.user_name + ':' + item.website_name + '-' + '发布求职信息了' }}</div>
  153. <div class="noticeNewsTime">{{ item.updated_at }}</div>
  154. </div>
  155. </div>
  156. </div>
  157. <div v-else class="noticeTabsDataItemEmpty">
  158. <div class="noticeEmpty">
  159. <img src="@/assets/public/nav/message-empty.png">
  160. </div>
  161. <div class="noticeEmptyText">
  162. 暂无消息
  163. </div>
  164. </div>
  165. </div>
  166. <!-- 求职信息 职场机会 -->
  167. <div class="noticeTabsDataBox" v-if="tabsIndex == 3 && qiu == true && qiu2 == true && userType == 10000">
  168. <div v-if="msg.job_apply && msg.job_apply.length > 0">
  169. <div class="noticeTabsDataItem" v-for="item in msg.job_apply" :key="item.id"
  170. @click="goToPath(3.2, item.recruit_id)">
  171. <div class="noticeTabsDataItemImg newsIcon">
  172. <img src="@/assets/public/nav/message-news.png">
  173. </div>
  174. <div class="noticeTabsDataItemContent">
  175. <div class="noticeNewsTitle">{{ item.business_name + ':' + item.website_name + ' ' + '关注了' +
  176. item.user_name
  177. + '的简历' }}</div>
  178. <div class="noticeNewsTime">{{ item.updated_at }}</div>
  179. </div>
  180. </div>
  181. </div>
  182. <div v-else class="noticeTabsDataItemEmpty">
  183. <div class="noticeEmpty">
  184. <img src="@/assets/public/nav/message-empty.png">
  185. </div>
  186. <div class="noticeEmptyText">
  187. 暂无消息
  188. </div>
  189. </div>
  190. </div>
  191. <!-- 招聘信息 招聘信息 job_recruiting -->
  192. <div class="noticeTabsDataBox" v-if="tabsIndex == 3 && zhao == true && zhao1 == true && userType == 10000">
  193. <div v-if="msg.job_recruiting && msg.job_recruiting.length > 0">
  194. <div class="noticeTabsDataItem" v-for="item in msg.job_recruiting" :key="item.id"
  195. @click="goToPath(3.3, item.id)">
  196. <!-- 招聘信息 job_recruiting -->
  197. <div class="noticeTabsDataItemImg newsIcon">
  198. <img src="@/assets/public/nav/message-news.png">
  199. </div>
  200. <div class="noticeTabsDataItemContent">
  201. <div class="noticeNewsTitle">{{ item.user_name + ':' + item.website_name + ' ' + '-' + item.title
  202. + '岗位' }}
  203. </div>
  204. <div class="noticeNewsTime">{{ item.updated_at }}</div>
  205. </div>
  206. </div>
  207. </div>
  208. <div v-else class="noticeTabsDataItemEmpty">
  209. <div class="noticeEmpty">
  210. <img src="@/assets/public/nav/message-empty.png">
  211. </div>
  212. <div class="noticeEmptyText">
  213. 暂无消息
  214. </div>
  215. </div>
  216. </div>
  217. <!-- 招聘信息 人才库 job_apply -->
  218. <div class="noticeTabsDataBox" v-if="tabsIndex == 3 && zhao == true && zhao2 == true && userType == 10000">
  219. <div v-if="msg.job_apply && msg.job_apply.length > 0">
  220. <div class="noticeTabsDataItem" v-for="item in msg.job_apply" :key="item.id"
  221. @click="goToPath(3.4, item.hunt_id)">
  222. <!-- 人才库 job_apply -->
  223. <div class="noticeTabsDataItemImg newsIcon">
  224. <img src="@/assets/public/nav/message-news.png">
  225. </div>
  226. <div class="noticeTabsDataItemContent">
  227. <div class="noticeNewsTitle">{{ item.user_name + ': 求职了' + '-' + item.business_name +
  228. '-' +
  229. item.job_name }}</div>
  230. <div class="noticeNewsTime">{{ item.updated_at }}</div>
  231. </div>
  232. </div>
  233. </div>
  234. <div v-else class="noticeTabsDataItemEmpty">
  235. <div class="noticeEmpty">
  236. <img src="@/assets/public/nav/message-empty.png">
  237. </div>
  238. <div class="noticeEmptyText">
  239. 暂无消息
  240. </div>
  241. </div>
  242. </div>
  243. <!-- 求职信息 待审核 -->
  244. <div class="noticeTabsDataBox" v-if="tabsIndex == 3 && qiu == true && qiu1 == true && userType == 1">
  245. <div v-if="msg.job_hunting && msg.job_hunting.length > 0">
  246. <div class="noticeTabsDataItem" v-for="item in msg.job_hunting" :key="item.id"
  247. @click="goToPath(3.1, item.id)">
  248. <!-- 待审核求职 -->
  249. <div class="noticeTabsDataItemImg newsIcon">
  250. <img src="@/assets/public/nav/message-news.png">
  251. </div>
  252. <div class="noticeTabsDataItemContent">
  253. <div class="noticeNewsTitle">{{ item.user_name + ':' + item.website_name + '-' + '发布求职信息了' }}</div>
  254. <div class="noticeNewsTime">{{ item.updated_at }}</div>
  255. </div>
  256. </div>
  257. </div>
  258. <div v-else class="noticeTabsDataItemEmpty">
  259. <div class="noticeEmpty">
  260. <img src="@/assets/public/nav/message-empty.png">
  261. </div>
  262. <div class="noticeEmptyText">
  263. 暂无消息
  264. </div>
  265. </div>
  266. </div>
  267. <!-- 求职信息 职场机会 -->
  268. <div class="noticeTabsDataBox" v-if="tabsIndex == 3 && qiu == true && qiu2 == true && userType == 1">
  269. <div v-if="msg.job_apply && msg.job_apply.length > 0">
  270. <div class="noticeTabsDataItem" v-for="item in msg.job_apply" :key="item.id"
  271. @click="goToPath(3.2, item.recruit_id)">
  272. <div class="noticeTabsDataItemImg newsIcon">
  273. <img src="@/assets/public/nav/message-news.png">
  274. </div>
  275. <div class="noticeTabsDataItemContent">
  276. <div class="noticeNewsTitle">{{ item.business_name + ':' + item.website_name + ' ' + '关注了' +
  277. item.user_name
  278. + '的简历' }}</div>
  279. <div class="noticeNewsTime">{{ item.updated_at }}</div>
  280. </div>
  281. </div>
  282. </div>
  283. <div v-else class="noticeTabsDataItemEmpty">
  284. <div class="noticeEmpty">
  285. <img src="@/assets/public/nav/message-empty.png">
  286. </div>
  287. <div class="noticeEmptyText">
  288. 暂无消息
  289. </div>
  290. </div>
  291. </div>
  292. <!-- 招聘信息 招聘信息 job_recruiting -->
  293. <div class="noticeTabsDataBox" v-if="tabsIndex == 3 && zhao == true && zhao1 == true && userType == 3">
  294. <div v-if="msg.job_recruiting && msg.job_recruiting.length > 0">
  295. <div class="noticeTabsDataItem" v-for="item in msg.job_recruiting" :key="item.id"
  296. @click="goToPath(3.3, item.id)">
  297. <!-- 招聘信息 job_recruiting -->
  298. <div class="noticeTabsDataItemImg newsIcon">
  299. <img src="@/assets/public/nav/message-news.png">
  300. </div>
  301. <div class="noticeTabsDataItemContent">
  302. <div class="noticeNewsTitle">{{ item.user_name + ':' + item.website_name + ' ' + '-' + item.title
  303. + '岗位' }}
  304. </div>
  305. <div class="noticeNewsTime">{{ item.updated_at }}</div>
  306. </div>
  307. </div>
  308. </div>
  309. <div v-else class="noticeTabsDataItemEmpty">
  310. <div class="noticeEmpty">
  311. <img src="@/assets/public/nav/message-empty.png">
  312. </div>
  313. <div class="noticeEmptyText">
  314. 暂无消息
  315. </div>
  316. </div>
  317. </div>
  318. <!-- 招聘信息 人才库 job_apply -->
  319. <div class="noticeTabsDataBox" v-if="tabsIndex == 3 && zhao == true && zhao2 == true && userType == 3">
  320. <div v-if="msg.job_apply && msg.job_apply.length > 0">
  321. <div class="noticeTabsDataItem" v-for="item in msg.job_apply" :key="item.id"
  322. @click="goToPath(3.4, item.hunt_id)">
  323. <!-- 人才库 job_apply -->
  324. <div class="noticeTabsDataItemImg newsIcon">
  325. <img src="@/assets/public/nav/message-news.png">
  326. </div>
  327. <div class="noticeTabsDataItemContent">
  328. <div class="noticeNewsTitle">{{ item.user_name + ': 求职了' + '-' + item.business_name +
  329. '-' +
  330. item.job_name }}</div>
  331. <div class="noticeNewsTime">{{ item.updated_at }}</div>
  332. </div>
  333. </div>
  334. </div>
  335. <div v-else class="noticeTabsDataItemEmpty">
  336. <div class="noticeEmpty">
  337. <img src="@/assets/public/nav/message-empty.png">
  338. </div>
  339. <div class="noticeEmptyText">
  340. 暂无消息
  341. </div>
  342. </div>
  343. </div>
  344. <div class="noticeTabsDataBox" v-if="tabsIndex == 4">
  345. <div v-if="msg.book && msg.book.length > 0">
  346. <div class="noticeTabsDataItem" v-for="item in msg.book" :key="item.id" @click="goToPath(4, item.id)">
  347. <div class="noticeTabsDataItemImg newsIcon">
  348. <img src="@/assets/public/nav/message-news.png">
  349. </div>
  350. <div class="noticeTabsDataItemContent">
  351. <div class="noticeNewsTitle">{{ item.title }}</div>
  352. <div class="noticeNewsTime">{{ item.updated_at }}</div>
  353. </div>
  354. </div>
  355. </div>
  356. <div v-else class="noticeTabsDataItemEmpty">
  357. <div class="noticeEmpty">
  358. <img src="@/assets/public/nav/message-empty.png">
  359. </div>
  360. <div class="noticeEmptyText">
  361. 暂无消息
  362. </div>
  363. </div>
  364. </div>
  365. </div>
  366. </div>
  367. <!-- 用户头像和菜单 -->
  368. <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
  369. <div class="avatar-wrapper">
  370. <!-- <img src="@/assets/public/nav/notice.png" class="user-notice"> -->
  371. <img :src="avatar + '?imageView2/1/w/80/h/80'" class="user-avatar" v-if="avatar != ''">
  372. <img src="@/assets/login/userDefault.png" class="user-avatar" v-else>
  373. <span class="userName">{{ this.$store.state.user.name }}</span>
  374. <img src="@/assets/public/nav/arrowDown.png" class="arrowDown">
  375. <!--向下按钮-->
  376. <!-- <i class="el-icon-caret-bottom" /> -->
  377. </div>
  378. <el-dropdown-menu slot="dropdown">
  379. <router-link to="/profile/index">
  380. <div class="userMenuDownItem">
  381. <el-dropdown-item>
  382. <span style="display:block;">{{ $t('navbar.profile') }}</span>
  383. </el-dropdown-item>
  384. </div>
  385. </router-link>
  386. <!-- <router-link to="/">
  387. <el-dropdown-item>
  388. {{ $t('navbar.dashboard') }}
  389. </el-dropdown-item>
  390. </router-link>
  391. <a target="_blank" href="https://github.com/PanJiaChen/vue-element-admin/">
  392. <el-dropdown-item>
  393. {{ $t('navbar.github') }}
  394. </el-dropdown-item>
  395. </a>
  396. <a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/">
  397. <el-dropdown-item>Docs</el-dropdown-item>
  398. </a> -->
  399. <el-dropdown-item divided @click.native="logout">
  400. <div class="userMenuDownItem">
  401. <span style="display:block;">{{ $t('navbar.logOut') }}</span>
  402. <img src="@/assets/public/nav/Logout.png">
  403. </div>
  404. </el-dropdown-item>
  405. </el-dropdown-menu>
  406. </el-dropdown>
  407. </div>
  408. </div>
  409. </template>
  410. <script>
  411. import { mapGetters } from 'vuex'
  412. import Breadcrumb from '@/components/Breadcrumb'
  413. import Hamburger from '@/components/Hamburger'
  414. import ErrorLog from '@/components/ErrorLog'
  415. import Screenfull from '@/components/Screenfull'
  416. import SizeSelect from '@/components/SizeSelect'
  417. import LangSelect from '@/components/LangSelect'
  418. import Search from '@/components/HeaderSearch'
  419. import axios from 'axios';
  420. import router, { resetRouter } from '@/router'
  421. import BASEURL from '@/utils/baseUrl'
  422. import { getUseType, removeLoginStatus } from '@/utils/auth'
  423. export default {
  424. components: {
  425. Breadcrumb,
  426. Hamburger,
  427. ErrorLog,
  428. Screenfull,
  429. SizeSelect,
  430. LangSelect,
  431. Search
  432. },
  433. data() {
  434. return {
  435. msg: {},
  436. userType: '', //用户类型
  437. tabsIndex: 1, //显示哪个选项卡
  438. showTabs: false, //是否显示悬浮菜单
  439. //求职招聘
  440. qiu: false,
  441. zhao: true,
  442. qiu1: true,
  443. qiu2: false,
  444. zhao1: true,
  445. zhao2: false,
  446. }
  447. },
  448. computed: {
  449. ...mapGetters([
  450. 'sidebar',
  451. 'avatar',
  452. 'device'
  453. ]),
  454. },
  455. mounted() {
  456. this.getMsg();
  457. //获得用户类型
  458. this.userType = getUseType();
  459. if (this.userType == 1) {
  460. this.qiu = true;
  461. }
  462. // 添加点击事件监听器
  463. document.addEventListener('click', this.handleClickOutside);
  464. },
  465. beforeDestroy() {
  466. // 组件销毁前移除事件监听器
  467. document.removeEventListener('click', this.handleClickOutside);
  468. },
  469. methods: {
  470. //0.收缩菜单 start---------------------------------------->
  471. toggleSideBar() {
  472. this.$store.dispatch('app/toggleSideBar')
  473. },
  474. //0.收缩菜单 end---------------------------------------->
  475. //1.退出登录 start---------------------------------------->
  476. logout() {
  477. //获取 token
  478. const token = this.getTokenFromCookie();
  479. // 新做的,待替换
  480. // this.$store.dispatch('user/logoutapi', {token: token}).then(response => {
  481. // //重置访问过的路由
  482. // resetRouter()
  483. // dispatch('tagsView/delAllViews', null, { root: true })
  484. // console.log(response);
  485. // this.$store.commit("user/LOGOUT");
  486. // this.$router.push(`/login`);
  487. // }).catch(error => {
  488. // this.$store.commit("user/LOGOUT");
  489. // this.$router.push(`/login`);
  490. // });
  491. axios.get(BASEURL.WebCLogoutUrl, { params: { token: token } }).then(response => {
  492. console.log(response);
  493. this.$store.commit("user/LOGOUT");
  494. //this.$router.push(`/login`);
  495. //刷新页面
  496. window.location.reload();
  497. }).catch(error => {
  498. console.log(error);
  499. this.$store.commit("user/LOGOUT");
  500. //this.$router.push(`/login`);
  501. //this.$message.error(response.message);
  502. window.location.reload();
  503. });
  504. removeLoginStatus();
  505. },
  506. // async logout() {
  507. // await this.$store.dispatch('user/logout')
  508. // this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  509. // },
  510. getTokenFromCookie() {
  511. const name = "Admin-Token=";
  512. const decodedCookie = decodeURIComponent(document.cookie);
  513. const cookieArray = decodedCookie.split(';');
  514. for (let i = 0; i < cookieArray.length; i++) {
  515. let cookie = cookieArray[i].trim();
  516. if (cookie.indexOf(name) === 0) {
  517. return cookie.substring(name.length, cookie.length); // 返回 token
  518. }
  519. }
  520. return ""; // 如果没有找到 token,返回空字符串
  521. },
  522. //1.退出登录 end---------------------------------------->
  523. //2.通知消息 start---------------------------------------->
  524. //2.1 获取通知消息列表
  525. getMsg() {
  526. this.$store.dispatch('news/getMSG').then(response => {
  527. //console.log('response1111111111', response);
  528. this.msg = response.data;
  529. // console.log(this.msg);
  530. }).catch(error => {
  531. console.log(error);
  532. });
  533. },
  534. //2.2 切换
  535. changeTabs(index) {
  536. this.tabsIndex = index;
  537. },
  538. //2.3跳转方法
  539. goToPath(type, id) {
  540. //如果id是0 跳转到列表
  541. if (id == 0) {
  542. if (type == 1) {
  543. this.$router.push(`/examine`);
  544. } else if (type == 2) {
  545. this.$router.push(`/goodListApply`);
  546. } else if (type == 3.1) { //求职 待审核
  547. this.$router.push(`/jobHuntingListApply`);
  548. }
  549. else if (type == 3.2) { // 职场机会
  550. this.$router.push(`/jobOpportunities`);
  551. }
  552. else if (type == 3.3) { // 招聘 待审核
  553. this.$router.push(`/checkjobRecruitingList`);
  554. }
  555. else if (type == 3.4) { // 人才库
  556. this.$router.push(`/jobHuntingApplyList`);
  557. }
  558. else if (type == 4) {
  559. this.$router.push(`/bookListApply`);
  560. }
  561. } else if (id == -1) {
  562. if (type == 1) {
  563. this.$router.push(`/articleList`);
  564. } else if (type == 2) {
  565. this.$router.push(`/goodList`);
  566. } else if (type == 3) {
  567. this.$router.push(`/jobHuntingList`);
  568. }
  569. else if (type == 3.1) { //求职 待审核
  570. this.$router.push(`/jobHuntingList`);
  571. }
  572. else if (type == 3.2) { // 职场机会
  573. this.$router.push(`/jobOpportunities`);
  574. }
  575. else if (type == 3.3) { // 招聘 待审核
  576. this.$router.push(`/jobRecruitingList`);
  577. }
  578. else if (type == 3.4) { // 人才库
  579. this.$router.push(`/jobHuntingApplyList`);
  580. }
  581. else if (type == 4) {
  582. this.$router.push(`/bookList`);
  583. }
  584. } else {
  585. if (type == 1) {
  586. this.$router.push(`/creatNews?id=${id}`);
  587. } else if (type == 2) {
  588. this.$router.push(`/addGood?id=${id}`);
  589. } else if (type == 3) {
  590. this.$router.push(`/addJobHunting?id=${id}`);
  591. }
  592. else if (type == 3.1) { //求职 待审核
  593. this.$router.push(`/addJobHunting?id=${id}`);
  594. }
  595. else if (type == 3.2) { // 职场机会
  596. this.$router.push(`/jobOpportunitiesDetails?id=${id}`);
  597. }
  598. else if (type == 3.3) { // 招聘 待审核
  599. this.$router.push(`/creatJob?id=${id}`);
  600. }
  601. else if (type == 3.4) { // 人才库
  602. this.$router.push(`/jobHuntingApplyDetil?id=${id}`);
  603. }
  604. else if (type == 4) {
  605. this.$router.push(`/addBook?id=${id}`);
  606. }
  607. }
  608. this.showTabs = false;
  609. },
  610. // 添加处理点击外部的方法
  611. handleClickOutside(event) {
  612. const noticeTabsBox = this.$refs.noticeTabsBox;
  613. const noticeIconImg = event.target.closest('.noticeIconImg');
  614. // 如果点击的不是通知图标,并且点击的区域不在通知框内,则关闭通知框
  615. if (!noticeIconImg && noticeTabsBox && !noticeTabsBox.contains(event.target)) {
  616. this.showTabs = false;
  617. }
  618. },
  619. //2.通知消息 end---------------------------------------->
  620. changeJob(index) {
  621. if (index == 1) {
  622. this.qiu = false;
  623. this.zhao = true;
  624. } else if (index == 2) {
  625. this.qiu = true;
  626. this.zhao = false;
  627. }
  628. },
  629. handleQiu(index) {
  630. if (index == 1) {
  631. this.qiu1 = true;
  632. this.qiu2 = false;
  633. } else if (index == 2) {
  634. this.qiu1 = false;
  635. this.qiu2 = true;
  636. } else if (index == 3) {
  637. this.zhao1 = true;
  638. this.zhao2 = false;
  639. } else if (index == 4) {
  640. this.zhao1 = false;
  641. this.zhao2 = true;
  642. }
  643. }
  644. }
  645. }
  646. </script>
  647. <style lang="scss" scoped>
  648. .navbar {
  649. height: 60px;
  650. position: relative;
  651. display: flex;
  652. align-items: center;
  653. justify-content: space-between;
  654. background: #fff;
  655. // box-shadow: 0 1px 4px rgba(0,21,41,.08);
  656. border-bottom: 1px solid #E9EDF7;
  657. .pageTitle {
  658. font-size: 20px;
  659. font-weight: bold;
  660. padding-left: 30px;
  661. color: #45464E;
  662. }
  663. .userName {
  664. font-size: 14px;
  665. color: #1C1D22;
  666. margin-left: 10px;
  667. font-weight: bold;
  668. }
  669. .hamburger-container {
  670. line-height: 46px;
  671. height: 100%;
  672. float: left;
  673. cursor: pointer;
  674. transition: background .3s;
  675. -webkit-tap-highlight-color: transparent;
  676. &:hover {
  677. background: rgba(0, 0, 0, .025)
  678. }
  679. }
  680. .breadcrumb-container {
  681. float: left;
  682. }
  683. .errLog-container {
  684. display: inline-block;
  685. vertical-align: top;
  686. }
  687. .right-menu {
  688. float: right;
  689. height: 100%;
  690. line-height: 50px;
  691. display: flex;
  692. align-items: center;
  693. position: relative;
  694. &:focus {
  695. outline: none;
  696. }
  697. .right-menu-item {
  698. display: inline-block;
  699. padding: 0 8px;
  700. height: 100%;
  701. font-size: 18px;
  702. color: #5a5e66;
  703. vertical-align: text-bottom;
  704. &.hover-effect {
  705. cursor: pointer;
  706. transition: background .3s;
  707. &:hover {
  708. background: rgba(0, 0, 0, .025)
  709. }
  710. }
  711. }
  712. .avatar-container {
  713. margin-right: 30px;
  714. .avatar-wrapper {
  715. margin-top: 5px;
  716. display: flex;
  717. align-items: center;
  718. .user-avatar {
  719. cursor: pointer;
  720. width: 32px;
  721. height: 32px;
  722. }
  723. .arrowDown {
  724. width: 12px;
  725. height: 8px;
  726. margin-left: 10px;
  727. }
  728. .user-notice {
  729. width: 20px;
  730. height: 20px;
  731. margin-right: 20px;
  732. }
  733. .el-icon-caret-bottom {
  734. cursor: pointer;
  735. position: absolute;
  736. right: -20px;
  737. top: 25px;
  738. font-size: 12px;
  739. }
  740. }
  741. }
  742. //通知消息 图标
  743. .noticeIconBox {
  744. width: 45px;
  745. height: 50px;
  746. box-sizing: border-box;
  747. padding-top: 8px;
  748. position: relative;
  749. .noticeIconImg {
  750. width: 34px;
  751. height: 34px;
  752. cursor: pointer;
  753. }
  754. .unreadCount {
  755. position: absolute;
  756. top: 5px;
  757. right: 10px;
  758. width: 16px;
  759. height: 16px;
  760. background: #FF4E4E;
  761. font-size: 12px;
  762. line-height: 16px;
  763. text-align: center;
  764. color: #fff;
  765. border-radius: 50%;
  766. }
  767. //通知消息 悬浮菜单
  768. .noticeTabsBox {
  769. position: absolute;
  770. width: 380px;
  771. height: 640px;
  772. border-radius: 8px;
  773. background: #fff;
  774. z-index: 999;
  775. right: 20px;
  776. top: 50px;
  777. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.15);
  778. padding: 25px 20px;
  779. box-sizing: border-box;
  780. .noticeTabsTitleBox {
  781. display: flex;
  782. align-items: center;
  783. border-bottom: 1px solid #E9EDF7;
  784. .noticeTabs {
  785. height: 41px;
  786. border-bottom: 2px solid #fff;
  787. margin-right: 40px;
  788. display: flex;
  789. cursor: pointer;
  790. .noticeTabsItem {
  791. height: 20px;
  792. line-height: 20px;
  793. font-size: 16px;
  794. position: relative;
  795. .noticeMessageNew {
  796. width: 5px;
  797. height: 5px;
  798. border-radius: 50%;
  799. background: #FF4E4E;
  800. position: absolute;
  801. right: -5px;
  802. top: 0;
  803. }
  804. }
  805. }
  806. .active {
  807. border-bottom: 2px solid #5570F1;
  808. }
  809. }
  810. .noticeTabsLinkLine {
  811. height: 38px;
  812. box-sizing: border-box;
  813. font-size: 14px;
  814. cursor: pointer;
  815. background: #F5F7FB;
  816. border: 1px solid #E3E8FA;
  817. text-align: center;
  818. line-height: 38px;
  819. border-radius: 8px;
  820. margin: 20px 0;
  821. }
  822. .noticeTabsDataBox {
  823. .noticeTabsDataItem {
  824. display: flex;
  825. align-items: flex-start;
  826. cursor: pointer;
  827. border-radius: 8px;
  828. box-sizing: border-box;
  829. padding: 5px 10px;
  830. &:hover {
  831. background: #F5F7FB;
  832. }
  833. height: 95px;
  834. .noticeTabsDataItemImg {
  835. border-radius: 50%;
  836. width: 26px;
  837. height: 26px;
  838. display: flex;
  839. align-items: center;
  840. justify-content: center;
  841. margin-right: 15px;
  842. margin-top: 6px;
  843. }
  844. .newsIcon {
  845. background: #BAC5F8;
  846. }
  847. .noticeTabsDataItemContent {
  848. flex: 1;
  849. .noticeNewsTitle {
  850. font-size: 14px;
  851. line-height: 28px;
  852. height: 56px;
  853. color: #333;
  854. overflow: hidden;
  855. text-overflow: ellipsis;
  856. display: -webkit-box;
  857. -webkit-line-clamp: 2;
  858. -webkit-box-orient: vertical;
  859. }
  860. .noticeNewsTime {
  861. height: 30px;
  862. line-height: 30px;
  863. font-size: 14px;
  864. color: #999;
  865. }
  866. }
  867. }
  868. .noticeTabsDataItemEmpty {
  869. .noticeEmpty {
  870. text-align: center;
  871. padding-top: 150px;
  872. box-sizing: border-box;
  873. }
  874. .noticeEmptyText {
  875. text-align: center;
  876. color: #999;
  877. font-size: 14px;
  878. }
  879. }
  880. }
  881. }
  882. }
  883. }
  884. }
  885. .userMenuDownItem {
  886. width: 100px;
  887. display: flex;
  888. align-items: center;
  889. justify-content: space-between;
  890. }
  891. .el-dropdown-menu__item:not(.is-disabled):hover {
  892. background: none;
  893. color: #606266;
  894. }
  895. .unread-count {
  896. position: relative;
  897. display: inline-block;
  898. width: 20px;
  899. height: 20px;
  900. border-radius: 50%;
  901. background-color: red;
  902. color: white;
  903. font-size: 12px;
  904. text-align: center;
  905. line-height: 20px;
  906. margin-left: -40px;
  907. margin-top: -20px;
  908. /* 调整位置,使其贴合通知图标 */
  909. }
  910. /* 如果未读数量为 0,则隐藏角标 */
  911. .unread-count:empty {
  912. display: none;
  913. }
  914. .noticeTabsLink {
  915. padding-left: 10px;
  916. // 去掉圆点
  917. list-style: none;
  918. }
  919. .qiuPillow {
  920. border-radius: 4px;
  921. padding: -1px;
  922. width: 48%;
  923. height: 36px;
  924. display: block;
  925. }
  926. .qiuPillowHover {
  927. border-radius: 4px;
  928. padding: -1px;
  929. width: 48%;
  930. height: 36px;
  931. background: #dfe9ee;
  932. border: #dfe1e7 1px solid;
  933. }
  934. .qiuFlex {
  935. display: flex;
  936. justify-content: space-between;
  937. text-align: center;
  938. }
  939. </style>