123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
- <script setup lang="ts">
- import { ref } from 'vue'
- import { useRouter } from 'vue-router'
- const router = useRouter()
- import { menuStatusStore, userInfoStore } from '@/stores';
- import CpdmLeave from '../components/CpdmLeave.vue'
- const leave = ref()
- // import url from '../assets/home/trademark.png';
- //选中的索引
- const userInfo = userInfoStore()
- const menuStatus = menuStatusStore()
- const activeIndex = ref<string>()
- activeIndex.value = menuStatus.activeIndex
- // app.config.globalProperties.$globalMsg = '2'
- const visible = ref<boolean>(false)
- //选中菜单事件
- const handleSelect = (key: string, keyPath: []) => {
- menuStatus.saveActiveIndex(key)
- activeIndex.value = key;
- if (key == '1') {
- router.push({ name: 'homeView' })
- } else if (key == '2') {
- router.push({ name: 'popularizationScience' })
- } else if (key == '3') {
- router.push({ name: 'community', })
- } else if (key == '4') {
- router.push({ name: 'plan', })
- } else if (key == '5') {
- router.push({ name: 'testRecord' })
- }
- // menuStatus.saveActiveIndex(key)
- }
- //点击登录按钮
- const login = () => {
- menuStatus.saveActiveIndex('6')
- router.push({ name: 'login', params: {} })
- }
- const falgMenu = ref<boolean>(false)
- //鼠标移入事件
- const comeMenu = () => {
- falgMenu.value = true
- }
- //鼠标移出事件
- const leaveMenu = () => {
- falgMenu.value = false
- }
- const updatePassFun = () => {
- menuStatus.saveActiveIndex('6')
- router.push({ name: 'updatePas' })
- }
- const exitFun = () => {
- //退出登录清除缓存
- visible.value = true
- // userInfo.clearUserInfo()
- //跳转到首页
- }
- const comT = () => {
- visible.value = false
- userInfo.clearUserInfo()
- //跳转到首页
- router.push({ name: 'homeView' })
- }
- //设置显示字段长度
- const formatterName = (val: string) => {
- if (val == undefined) {
- return ''
- }
- if (val.length > 3) {
- return val.substring(0, 3) + '...'
- } else {
- return val
- }
- }
- //打开弹出框--显示弹出框
- const leaveFun = () => {
- leave.value.open()
- }
- </script>
- <template>
- <!-- :style="{ backgroundColor: activeIndex == '1' ? '#ffffff' : '' }" -->
- <div class="header_qp" :style="{ backgroundColor: activeIndex == '1' ? 'transparent' : '#3B3B3B' }">
- <div class="header_p">
- <div class="header_image">
- <!-- <img style="width: 239px; height: 55px" src="../assets/home/trademarkNew.png"></img> -->
- <!-- <img style="width: 239px; height: 55px" src="../assets/home/trademarkNew.png"></img> -->
- <!-- <div>学生心理健康测评系统</div> -->
- <div style="display: flex;align-items: center;">
- <span class="home_line_1"></span>
- <img width="30px" style="margin-left: 10px;" src="../assets/logo_white.png" alt="">
- <!-- <img style="width: 20vw;" src="../assets/home/group_title.png" alt=""> -->
- <div style="display: flex;flex-direction: column;margin-left:6px">
- <span style="color: #ffffff;font-size: 26px;font-weight: 100;">学生心理健康测评系统</span>
- <span style="color: #ffffff;font-weight: 100;font-size: 14px;">Student psychological health
- assessment system</span>
- </div>
- </div>
- </div>
- <el-menu :default-active="activeIndex" class="el-menu-demo" style="display: flex;" mode="horizontal"
- :ellipsis="false" @select="handleSelect">
- <el-menu-item index="1"><span
- :class="{ 'underlined-text': activeIndex == '1' }">首 页</span></el-menu-item>
- <!-- <el-badge :value="200" :max="99" class="item">
- <el-menu-item index="4">测试计划</el-menu-item>
- </el-badge> -->
- <el-menu-item index="4">
- <div class="badge_custom" v-show="userInfo.planCurrentNum != 0">
- {{ userInfo.planCurrentNum }}
- </div>
- <span :class="{ 'underlined-text': activeIndex == '4' }">测试计划</span>
- </el-menu-item>
- <el-menu-item index="5">
- <div class="badge_custom" v-show="userInfo.unreadNum != 0">
- {{ userInfo.unreadNum }}
- </div>
- <span :class="{ 'underlined-text': activeIndex == '5' }">测试记录</span>
- </el-menu-item>
- <el-menu-item index="2"><span
- :class="{ 'underlined-text': activeIndex == '2' }">更多测试</span></el-menu-item>
- <el-menu-item index="3"><span
- :class="{ 'underlined-text': activeIndex == '3' }">留言社区</span></el-menu-item>
- </el-menu>
- <span class="home_line"></span>
- <div class="login_button_bg" @mouseenter="comeMenu" @mouseleave="leaveMenu"
- v-show="userInfo.userInfo.userName">
- <span :title="userInfo.userInfo.userName">{{ formatterName(userInfo.userInfo.userName) }}</span>
- <transition>
- <div class="login_user" v-show="falgMenu">
- <div class="update_pass" @click="updatePassFun">
- 修改密码
- </div>
- <!-- <div class="exit_login" @click="leaveFun">
- 我的请假
- </div> -->
- <div class="exit_login" @click="exitFun">
- 退出登录
- </div>
- </div>
- </transition>
- </div>
- <div class="login_button_bg" v-show="!userInfo.userInfo.userName" @click="login">
- <span v-if="!userInfo.userInfo?.userName">登录</span>
- </div>
- <el-dialog v-model="visible" :show-close="true" width="500" style="border-radius: 40px;" class="dig_kg">
- <template #header="{ close, titleId, titleClass }">
- <div class="my-header" style="text-align: center;">
- <div class="exit_login_title">退出登录</div>
- <div class="exit_login_info">是否退出当前账号?</div>
- <div class="start_button_out">
- <div class="start_button_self" @click="comT">
- 确定
- </div>
- </div>
- </div>
- </template>
- </el-dialog>
- </div>
- </div>
- <CpdmLeave ref="leave" />
- </template>
- <style scoped>
- .home_line_1 {
- display: flex;
- width: 1px;
- height: 50px;
- background-color: #ffffff;
- }
- .home_line {
- width: 1px;
- height: 50%;
- border-left: 1px solid #ffffff;
- /* background-color: #ffffff; */
- }
- .underlined-text {
- position: relative;
- display: inline-block;
- }
- .underlined-text::after {
- content: "";
- position: absolute;
- left: 0;
- right: 0;
- bottom: 10px;
- border-bottom: 1px solid;
- }
- :deep(.dig_kg> .el-dialog__header) {
- padding-right: 0px !important;
- }
- </style>
- <style lang="scss" scoped>
- .el-menu {
- background-color: transparent !important
- }
- .exit_login_title {
- text-align: center;
- color: #222222;
- font-weight: 700;
- font-size: 20px;
- letter-spacing: 3px;
- }
- .exit_login_info {
- text-align: center;
- letter-spacing: 3px;
- font-size: 18px;
- margin-top: 20px;
- }
- .start_button_out {
- margin-top: 40px;
- // margin-bottom: 40px;
- display: flex;
- flex-direction: row;
- justify-content: center;
- .start_button_self {
- cursor: pointer;
- // width: 100px;
- border-radius: 5px;
- // border: 1px solid #48D68E;
- color: #ffffff;
- background-color: #3B3B3B;
- // margin-right: 20px;
- padding: 5px 50px;
- cursor: pointer;
- display: flex;
- align-items: center;
- background: url(../assets/zs/bottom_new.png) no-repeat;
- background-size: 100% 100%;
- }
- }
- .badge_custom {
- position: absolute;
- background-color: #FF52CE;
- right: -18px;
- top: 0px;
- text-align: center;
- line-height: 18px;
- width: 18px;
- color: 10px;
- font-weight: 300;
- font-size: 10px;
- color: #3B3B3B;
- font-weight: 700;
- border-radius: 18px;
- }
- //整个菜单底部样式
- .el-menu--horizontal.el-menu {
- border-bottom: 0px solid var(--el-menu-border-color);
- display: flex;
- align-items: center;
- }
- .el-menu--horizontal>.el-menu-item {
- width: 120px;
- height: 40px;
- align-items: center;
- border-bottom: 0px solid transparent;
- // color: var(--el-menu-text-color);
- color: #ffffff;
- display: inline-flex;
- // height: 100%;
- justify-content: flex-end;
- padding: 0px;
- align-items: center;
- border-radius: 12px;
- margin: 0;
- }
- .el-menu--horizontal .el-menu-item:not(.is-disabled):focus,
- .el-menu--horizontal .el-menu-item:not(.is-disabled):hover {
- background-color: transparent;
- color: #ffffff !important;
- border-radius: 12px;
- }
- //激活某个菜单时 底部样式
- .el-menu--horizontal>.el-menu-item.is-active {
- border-bottom: 0px solid var(--el-menu-active-color);
- // color: var(--el-menu-active-color) !important;
- color: #ffffff !important;
- background: transparent;
- border-radius: 12px;
- height: 40px;
- font-weight: 700;
- }
- .header_qp {
- display: flex;
- justify-content: center;
- width: 100%;
- .header_p {
- // background-color: #ffffff;
- padding-top: 10px;
- padding-bottom: 10px;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-between;
- width: 1200px;
- .header_image {
- // flex: 1
- // margin-right: 100px;
- div {
- color: #48D68E;
- font-weight: 700;
- // font-size: 26px;
- // -webkit-transform: skew(-10deg);
- // letter-spacing: 2px;
- // /* for Chrome||Safari */
- // -ms-transform: skew(-10deg);
- // /* for IE */
- // -moz-transform: skew(-10deg);
- // /* for Firefox */
- // -o-transform: skew(-10deg);
- // /* for Opera */
- }
- }
- .login_button_bg {
- position: relative;
- // border-radius: 4px;
- border: 1px solid #ffffff;
- color: #216EE2;
- font-weight: 700;
- padding: 8px 20px;
- cursor: pointer;
- display: flex;
- align-items: center;
- width: 60px;
- justify-content: center;
- background-color: #ffffff;
- .login_user {
- background-color: #236EE3;
- width: 100px;
- position: absolute;
- // background-color: #ffffff;
- // bottom: -105px;
- bottom: -105px;
- // margin-left: calc(10% - 20px);
- z-index: 200;
- color: #000000;
- border: 1px solid #ffffff;
- .update_pass {
- text-align: center;
- margin-top: 20px;
- // padding: 5px;
- color: #ffffff
- }
- .update_pass:hover {
- text-align: center;
- margin-top: 20px;
- color: #48D68E // padding: 5px;
- }
- .exit_login {
- text-align: center;
- // padding: 5px;
- margin-top: 20px;
- margin-bottom: 20px;
- color: #ffffff
- }
- .exit_login:hover {
- text-align: center;
- // padding: 5px;
- margin-top: 20px;
- margin-bottom: 20px;
- color: #48D68E // padding: 5px;
- }
- }
- }
- .flex-grow {
- flex: 1;
- }
- .menu_gen {
- width: 80px;
- height: 20px;
- font-family: Alibaba PuHuiTi 2.0;
- font-weight: normal;
- font-size: 20px;
- color: #333333;
- line-height: 26px
- }
- }
- }
- </style>
|