Header.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <script setup lang="ts">
  2. import {router} from '../router'
  3. import {parseRole} from "../utils"
  4. import {User, Document, Discount, SwitchButton} from "@element-plus/icons-vue" //图标
  5. const role = sessionStorage.getItem('role') //登录的时候插入的
  6. //退出登录
  7. function logout() {
  8. ElMessageBox.confirm(
  9. '是否要退出登录?',
  10. '提示',
  11. {
  12. customClass: "customDialog",
  13. confirmButtonText: '是',
  14. cancelButtonText: '否',
  15. type: "warning",
  16. showClose: false,
  17. roundButton: true,
  18. center: true
  19. }
  20. ).then(() => {
  21. sessionStorage.setItem('token', '')
  22. router.push({path: "/login"})
  23. })
  24. }
  25. </script>
  26. <template>
  27. <el-header class="custom-header" height="20">
  28. <el-row :gutter="10">
  29. <el-col :span="3" class="header-icon">
  30. <router-link to="/allStore" v-slot="{navigate}" class="no-link">
  31. <h1 @click="navigate" class="header-text"> 蓝鲸在线购物</h1>
  32. </router-link>
  33. </el-col>
  34. <el-col :span="2">
  35. <el-tag class="role-tag" size="large">{{ parseRole(role) }}版</el-tag>
  36. </el-col>
  37. <el-col :span="15">
  38. </el-col>
  39. <el-col :span="1" class="header-icon">
  40. <router-link to="/dashboard" v-slot="{navigate}">
  41. <el-icon @click="navigate" :size="35" color="white" ><User /></el-icon>
  42. </router-link>
  43. </el-col>
  44. <el-col :span="1" class="header-icon">
  45. <router-link to="/allOrder" v-slot="{navigate}">
  46. <el-icon @click="navigate" :size="35" color="white" ><Document /></el-icon>
  47. </router-link>
  48. </el-col>
  49. <!--Lab4新增,点击至全部优惠券界面-->
  50. <el-col :span="1" class="header-icon">
  51. <router-link to="/allCoupon" v-slot="{navigate}">
  52. <el-icon @click="navigate" :size="35" color="white" ><Discount /></el-icon>
  53. </router-link>
  54. </el-col>
  55. <el-col :span="1" class="header-icon">
  56. <a @click="logout">
  57. <el-icon :size="35" color="white" ><SwitchButton /></el-icon>
  58. </a>
  59. </el-col>
  60. </el-row>
  61. </el-header>
  62. </template>
  63. <style scoped>
  64. .custom-header {
  65. background-color: #409eff;
  66. border-bottom-left-radius: 20px;
  67. border-bottom-right-radius: 20px;
  68. display: flex;
  69. flex-direction: column;
  70. }
  71. .no-link {
  72. text-decoration: none;
  73. }
  74. .role-tag {
  75. margin-top: 20px;
  76. font-size: 20px;
  77. }
  78. .header-text {
  79. color:white;
  80. font-size: x-large;
  81. min-width: max-content;
  82. margin-top: 15px;
  83. margin-bottom: 15px;
  84. }
  85. .header-icon {
  86. display: flex;
  87. flex-direction: column;
  88. align-items:center;
  89. justify-content: center;
  90. }
  91. </style>