CpmdHeader.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <script setup lang="ts">
  2. import { ref } from 'vue'
  3. import { useRouter } from 'vue-router'
  4. const router = useRouter()
  5. import { menuStatusStore, userInfoStore } from '@/stores';
  6. import CpdmLeave from '../components/CpdmLeave.vue'
  7. const leave = ref()
  8. // import url from '../assets/home/trademark.png';
  9. //选中的索引
  10. const userInfo = userInfoStore()
  11. const menuStatus = menuStatusStore()
  12. const activeIndex = ref<string>()
  13. activeIndex.value = menuStatus.activeIndex
  14. // app.config.globalProperties.$globalMsg = '2'
  15. const visible = ref<boolean>(false)
  16. //选中菜单事件
  17. const handleSelect = (key: string, keyPath: []) => {
  18. menuStatus.saveActiveIndex(key)
  19. activeIndex.value = key;
  20. if (key == '1') {
  21. router.push({ name: 'homeView' })
  22. } else if (key == '2') {
  23. router.push({ name: 'popularizationScience' })
  24. } else if (key == '3') {
  25. router.push({ name: 'community', })
  26. } else if (key == '4') {
  27. router.push({ name: 'plan', })
  28. } else if (key == '5') {
  29. router.push({ name: 'testRecord' })
  30. }
  31. // menuStatus.saveActiveIndex(key)
  32. }
  33. //点击登录按钮
  34. const login = () => {
  35. menuStatus.saveActiveIndex('6')
  36. router.push({ name: 'login', params: {} })
  37. }
  38. const falgMenu = ref<boolean>(false)
  39. //鼠标移入事件
  40. const comeMenu = () => {
  41. falgMenu.value = true
  42. }
  43. //鼠标移出事件
  44. const leaveMenu = () => {
  45. falgMenu.value = false
  46. }
  47. const updatePassFun = () => {
  48. menuStatus.saveActiveIndex('6')
  49. router.push({ name: 'updatePas' })
  50. }
  51. const exitFun = () => {
  52. //退出登录清除缓存
  53. visible.value = true
  54. // userInfo.clearUserInfo()
  55. //跳转到首页
  56. }
  57. const comT = () => {
  58. visible.value = false
  59. userInfo.clearUserInfo()
  60. //跳转到首页
  61. router.push({ name: 'homeView' })
  62. }
  63. //设置显示字段长度
  64. const formatterName = (val: string) => {
  65. if (val == undefined) {
  66. return ''
  67. }
  68. if (val.length > 3) {
  69. return val.substring(0, 3) + '...'
  70. } else {
  71. return val
  72. }
  73. }
  74. //打开弹出框--显示弹出框
  75. const leaveFun = () => {
  76. leave.value.open()
  77. }
  78. </script>
  79. <template>
  80. <!-- :style="{ backgroundColor: activeIndex == '1' ? '#ffffff' : '' }" -->
  81. <div class="header_qp" :style="{ backgroundColor: activeIndex == '1' ? 'transparent' : '#3B3B3B' }">
  82. <div class="header_p">
  83. <div class="header_image">
  84. <!-- <img style="width: 239px; height: 55px" src="../assets/home/trademarkNew.png"></img> -->
  85. <!-- <img style="width: 239px; height: 55px" src="../assets/home/trademarkNew.png"></img> -->
  86. <!-- <div>学生心理健康测评系统</div> -->
  87. <div style="display: flex;align-items: center;">
  88. <span class="home_line_1"></span>
  89. <img width="30px" style="margin-left: 10px;" src="../assets/logo_white.png" alt="">
  90. <!-- <img style="width: 20vw;" src="../assets/home/group_title.png" alt=""> -->
  91. <div style="display: flex;flex-direction: column;margin-left:6px">
  92. <span style="color: #ffffff;font-size: 26px;font-weight: 100;">学生心理健康测评系统</span>
  93. <span style="color: #ffffff;font-weight: 100;font-size: 14px;">Student psychological health
  94. assessment system</span>
  95. </div>
  96. </div>
  97. </div>
  98. <el-menu :default-active="activeIndex" class="el-menu-demo" style="display: flex;" mode="horizontal"
  99. :ellipsis="false" @select="handleSelect">
  100. <el-menu-item index="1"><span
  101. :class="{ 'underlined-text': activeIndex == '1' }">首&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;页</span></el-menu-item>
  102. <!-- <el-badge :value="200" :max="99" class="item">
  103. <el-menu-item index="4">测试计划</el-menu-item>
  104. </el-badge> -->
  105. <el-menu-item index="4">
  106. <div class="badge_custom" v-show="userInfo.planCurrentNum != 0">
  107. {{ userInfo.planCurrentNum }}
  108. </div>
  109. <span :class="{ 'underlined-text': activeIndex == '4' }">测试计划</span>
  110. </el-menu-item>
  111. <el-menu-item index="5">
  112. <div class="badge_custom" v-show="userInfo.unreadNum != 0">
  113. {{ userInfo.unreadNum }}
  114. </div>
  115. <span :class="{ 'underlined-text': activeIndex == '5' }">测试记录</span>
  116. </el-menu-item>
  117. <el-menu-item index="2"><span
  118. :class="{ 'underlined-text': activeIndex == '2' }">更多测试</span></el-menu-item>
  119. <el-menu-item index="3"><span
  120. :class="{ 'underlined-text': activeIndex == '3' }">留言社区</span></el-menu-item>
  121. </el-menu>
  122. <span class="home_line"></span>
  123. <div class="login_button_bg" @mouseenter="comeMenu" @mouseleave="leaveMenu"
  124. v-show="userInfo.userInfo.userName">
  125. <span :title="userInfo.userInfo.userName">{{ formatterName(userInfo.userInfo.userName) }}</span>
  126. <transition>
  127. <div class="login_user" v-show="falgMenu">
  128. <div class="update_pass" @click="updatePassFun">
  129. 修改密码
  130. </div>
  131. <!-- <div class="exit_login" @click="leaveFun">
  132. 我的请假
  133. </div> -->
  134. <div class="exit_login" @click="exitFun">
  135. 退出登录
  136. </div>
  137. </div>
  138. </transition>
  139. </div>
  140. <div class="login_button_bg" v-show="!userInfo.userInfo.userName" @click="login">
  141. <span v-if="!userInfo.userInfo?.userName">登录</span>
  142. </div>
  143. <el-dialog v-model="visible" :show-close="true" width="500" style="border-radius: 40px;" class="dig_kg">
  144. <template #header="{ close, titleId, titleClass }">
  145. <div class="my-header" style="text-align: center;">
  146. <div class="exit_login_title">退出登录</div>
  147. <div class="exit_login_info">是否退出当前账号?</div>
  148. <div class="start_button_out">
  149. <div class="start_button_self" @click="comT">
  150. 确定
  151. </div>
  152. </div>
  153. </div>
  154. </template>
  155. </el-dialog>
  156. </div>
  157. </div>
  158. <CpdmLeave ref="leave" />
  159. </template>
  160. <style scoped>
  161. .home_line_1 {
  162. display: flex;
  163. width: 1px;
  164. height: 50px;
  165. background-color: #ffffff;
  166. }
  167. .home_line {
  168. width: 1px;
  169. height: 50%;
  170. border-left: 1px solid #ffffff;
  171. /* background-color: #ffffff; */
  172. }
  173. .underlined-text {
  174. position: relative;
  175. display: inline-block;
  176. }
  177. .underlined-text::after {
  178. content: "";
  179. position: absolute;
  180. left: 0;
  181. right: 0;
  182. bottom: 10px;
  183. border-bottom: 1px solid;
  184. }
  185. :deep(.dig_kg> .el-dialog__header) {
  186. padding-right: 0px !important;
  187. }
  188. </style>
  189. <style lang="scss" scoped>
  190. .el-menu {
  191. background-color: transparent !important
  192. }
  193. .exit_login_title {
  194. text-align: center;
  195. color: #222222;
  196. font-weight: 700;
  197. font-size: 20px;
  198. letter-spacing: 3px;
  199. }
  200. .exit_login_info {
  201. text-align: center;
  202. letter-spacing: 3px;
  203. font-size: 18px;
  204. margin-top: 20px;
  205. }
  206. .start_button_out {
  207. margin-top: 40px;
  208. // margin-bottom: 40px;
  209. display: flex;
  210. flex-direction: row;
  211. justify-content: center;
  212. .start_button_self {
  213. cursor: pointer;
  214. // width: 100px;
  215. border-radius: 5px;
  216. // border: 1px solid #48D68E;
  217. color: #ffffff;
  218. background-color: #3B3B3B;
  219. // margin-right: 20px;
  220. padding: 5px 50px;
  221. cursor: pointer;
  222. display: flex;
  223. align-items: center;
  224. background: url(../assets/zs/bottom_new.png) no-repeat;
  225. background-size: 100% 100%;
  226. }
  227. }
  228. .badge_custom {
  229. position: absolute;
  230. background-color: #FF52CE;
  231. right: -18px;
  232. top: 0px;
  233. text-align: center;
  234. line-height: 18px;
  235. width: 18px;
  236. color: 10px;
  237. font-weight: 300;
  238. font-size: 10px;
  239. color: #3B3B3B;
  240. font-weight: 700;
  241. border-radius: 18px;
  242. }
  243. //整个菜单底部样式
  244. .el-menu--horizontal.el-menu {
  245. border-bottom: 0px solid var(--el-menu-border-color);
  246. display: flex;
  247. align-items: center;
  248. }
  249. .el-menu--horizontal>.el-menu-item {
  250. width: 120px;
  251. height: 40px;
  252. align-items: center;
  253. border-bottom: 0px solid transparent;
  254. // color: var(--el-menu-text-color);
  255. color: #ffffff;
  256. display: inline-flex;
  257. // height: 100%;
  258. justify-content: flex-end;
  259. padding: 0px;
  260. align-items: center;
  261. border-radius: 12px;
  262. margin: 0;
  263. }
  264. .el-menu--horizontal .el-menu-item:not(.is-disabled):focus,
  265. .el-menu--horizontal .el-menu-item:not(.is-disabled):hover {
  266. background-color: transparent;
  267. color: #ffffff !important;
  268. border-radius: 12px;
  269. }
  270. //激活某个菜单时 底部样式
  271. .el-menu--horizontal>.el-menu-item.is-active {
  272. border-bottom: 0px solid var(--el-menu-active-color);
  273. // color: var(--el-menu-active-color) !important;
  274. color: #ffffff !important;
  275. background: transparent;
  276. border-radius: 12px;
  277. height: 40px;
  278. font-weight: 700;
  279. }
  280. .header_qp {
  281. display: flex;
  282. justify-content: center;
  283. width: 100%;
  284. .header_p {
  285. // background-color: #ffffff;
  286. padding-top: 10px;
  287. padding-bottom: 10px;
  288. display: flex;
  289. flex-direction: row;
  290. align-items: center;
  291. justify-content: space-between;
  292. width: 1200px;
  293. .header_image {
  294. // flex: 1
  295. // margin-right: 100px;
  296. div {
  297. color: #48D68E;
  298. font-weight: 700;
  299. // font-size: 26px;
  300. // -webkit-transform: skew(-10deg);
  301. // letter-spacing: 2px;
  302. // /* for Chrome||Safari */
  303. // -ms-transform: skew(-10deg);
  304. // /* for IE */
  305. // -moz-transform: skew(-10deg);
  306. // /* for Firefox */
  307. // -o-transform: skew(-10deg);
  308. // /* for Opera */
  309. }
  310. }
  311. .login_button_bg {
  312. position: relative;
  313. // border-radius: 4px;
  314. border: 1px solid #ffffff;
  315. color: #216EE2;
  316. font-weight: 700;
  317. padding: 8px 20px;
  318. cursor: pointer;
  319. display: flex;
  320. align-items: center;
  321. width: 60px;
  322. justify-content: center;
  323. background-color: #ffffff;
  324. .login_user {
  325. background-color: #236EE3;
  326. width: 100px;
  327. position: absolute;
  328. // background-color: #ffffff;
  329. // bottom: -105px;
  330. bottom: -105px;
  331. // margin-left: calc(10% - 20px);
  332. z-index: 200;
  333. color: #000000;
  334. border: 1px solid #ffffff;
  335. .update_pass {
  336. text-align: center;
  337. margin-top: 20px;
  338. // padding: 5px;
  339. color: #ffffff
  340. }
  341. .update_pass:hover {
  342. text-align: center;
  343. margin-top: 20px;
  344. color: #48D68E // padding: 5px;
  345. }
  346. .exit_login {
  347. text-align: center;
  348. // padding: 5px;
  349. margin-top: 20px;
  350. margin-bottom: 20px;
  351. color: #ffffff
  352. }
  353. .exit_login:hover {
  354. text-align: center;
  355. // padding: 5px;
  356. margin-top: 20px;
  357. margin-bottom: 20px;
  358. color: #48D68E // padding: 5px;
  359. }
  360. }
  361. }
  362. .flex-grow {
  363. flex: 1;
  364. }
  365. .menu_gen {
  366. width: 80px;
  367. height: 20px;
  368. font-family: Alibaba PuHuiTi 2.0;
  369. font-weight: normal;
  370. font-size: 20px;
  371. color: #333333;
  372. line-height: 26px
  373. }
  374. }
  375. }
  376. </style>