AppHeader.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div style="position: relative;height: 5rem;">
  3. <nav class="header-box" :class="{'visible':visible}">
  4. <img class="logo" src="./../assets/image/logo.png"/>
  5. <router-link to="/home">
  6. <div class="header-item">
  7. <i class="icon-mall-gongnengguanli"></i>首页
  8. </div>
  9. </router-link>
  10. <router-link to="/noticeCenter">
  11. <div class="header-item">
  12. <i v-if="userInfo.unreadNum==0" class="el-icon-message-solid"></i>
  13. <el-badge v-else :value="userInfo.unreadNum" :max="99" class="item">
  14. <i class="el-icon-message-solid"></i>
  15. </el-badge>
  16. 消息中心
  17. </div>
  18. </router-link>
  19. <router-link to="/myCenter">
  20. <div class="header-item">
  21. <i class="icon-mall-gerenzhongxin"></i>个人中心
  22. </div>
  23. </router-link>
  24. <!-- <router-link to="/pointsRank">
  25. <div class="header-item">
  26. <i class="el-icon-trophy"></i>积分排行
  27. </div>
  28. </router-link> -->
  29. <div class="userInfo flex-center">
  30. <!-- <el-tooltip content="联系我们" effect="dark" placement="bottom">
  31. <div style="font-size: 20px;margin-right: 10px;cursor: pointer;">
  32. <i class="el-icon-service" @click="childMethod()"></i>
  33. </div>
  34. </el-tooltip> -->
  35. <el-avatar fit="fill" :size="50" :src="avatar"></el-avatar>
  36. <div class="nameAndIntegral">
  37. <div>姓名: {{ userInfo.userName }}</div>
  38. <div style="display: flex;align-items: center;">
  39. 积分: <span class="blue">{{ userInfo.surplusIntegral }}</span>
  40. <router-link to="/ipay">
  41. <span class="ipay-btn">充值</span>
  42. </router-link>
  43. <img style="height: 24px;margin-left: 10px;" src="@/assets/image/gift.png" alt="返奖">
  44. </div>
  45. </div>
  46. </div>
  47. </nav>
  48. </div>
  49. </template>
  50. <script>
  51. import { mapGetters } from 'vuex'
  52. export default {
  53. props:['visible'],
  54. data() {
  55. return {};
  56. },
  57. computed: {
  58. // 将 getter 映射到当前组件的计算属性
  59. ...mapGetters(['userInfo','avatar'])
  60. },
  61. created() {},
  62. methods: {
  63. childMethod() {
  64. this.$parent.fatherMethod();
  65. },
  66. },
  67. }
  68. </script>
  69. <style>
  70. .logo{
  71. position: absolute;
  72. left: 80px;
  73. width: 160px;
  74. }
  75. .userInfo{
  76. position: absolute;
  77. right: 80px;
  78. }
  79. .flex-center{
  80. display: flex;
  81. justify-content: center;
  82. align-items: center;
  83. }
  84. .nameAndIntegral{
  85. margin-left: 10px;
  86. font-size: 14px;
  87. color: #252933;
  88. line-height: px;
  89. line-height: 23px;
  90. }
  91. .blue {
  92. color: #1e80ff;
  93. }
  94. .ipay-btn{
  95. font-weight: normal;
  96. margin-left: 10px;
  97. display: inline-block;
  98. color: #b87100;
  99. width: 56px;
  100. height: 24px;
  101. line-height: 24px;
  102. background: linear-gradient(270deg, #f8c883 0, #fae8d0 100%);
  103. border-radius: 16px;
  104. cursor: pointer;
  105. text-align: center;
  106. }
  107. .header-box {
  108. display: flex;
  109. justify-content: center;
  110. align-items: center;
  111. position: fixed;
  112. top: 0;
  113. left: 0;
  114. right: 0;
  115. background: #fff;
  116. border-bottom: 1px solid #f1f1f1;
  117. color: #909090;
  118. height: 5rem;
  119. z-index: 250;
  120. transition: all .2s;
  121. transform: translate3d(0,-100%,0);
  122. }
  123. .header-item {
  124. display: flex;
  125. justify-content: center;
  126. align-items: center;
  127. flex-direction: column;
  128. padding: 0 120px;
  129. }
  130. nav a {
  131. font-weight: bold;
  132. color: #515767;
  133. }
  134. nav a.route-active {
  135. color: #1e80ff;
  136. }
  137. .header-item i {
  138. font-size: 30px;
  139. margin-bottom: 5px;
  140. }
  141. .header-box.visible{
  142. transform: translateZ(0);
  143. }
  144. </style>