Index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <script setup>
  2. import {useUserInfo} from '@/hooks/useUserInfo'
  3. import { computed } from 'vue';
  4. import AudioBox from '@/components/Audio.vue'
  5. import { useRoute, useRouter } from 'vue-router';
  6. import Aslide from './components/Aslide.vue'
  7. import { usePermissionMenu } from '@/hooks/usePermissionMenu'
  8. const {getUserInfo,userInfo}=useUserInfo()
  9. const router=useRouter()
  10. const route= useRoute()
  11. const { getPermissionMenu } = usePermissionMenu()
  12. const menu = ref([])
  13. async function init() {
  14. const res = await getPermissionMenu()
  15. menu.value = res||[];
  16. if(menu.value.length) {
  17. router.replace(menu.value[0].path)
  18. }
  19. }
  20. init()
  21. getUserInfo()
  22. const isShowAslide = computed(() => {
  23. return !['/etaChart/favorite','/etaReport/favorite'].includes(route.path)
  24. })
  25. const dynamicStyle = computed(() => {
  26. const isStylePage = route.path.includes('/etaReport')
  27. return isStylePage ? 'background:#fff' : ''
  28. })
  29. async function handleLoginOut(){
  30. await $confirmDialog({
  31. header:'提示',
  32. body: '是否确认退出当前账号',
  33. confirmBtn:'确认退出'
  34. });
  35. localStorage.removeItem('token')
  36. router.replace('/login')
  37. }
  38. </script>
  39. <template>
  40. <div class="layout-wrap">
  41. <div class="flex header">
  42. <div class="flex">
  43. <img class="logo" src="@/assets/imgs/logo.png" alt="" />
  44. <Aslide v-if="isShowAslide" :menu="menu"/>
  45. </div>
  46. <div class="fav-btn" @click="$router.push('/etaChart/favorite')">{{menu.length ? '我的收藏':''}}</div>
  47. <t-popup placement="bottom-left" overlayInnerClassName="header-userInfo-pop-wrap">
  48. <template #content>
  49. <div class="content">
  50. <div class="top-box">
  51. <div class="label-text">账号信息</div>
  52. <div class="flex">
  53. <span>{{userInfo?.RealName}}</span>
  54. <span>|</span>
  55. <span>{{userInfo?.Mobile}}</span>
  56. </div>
  57. <div class="business-name">
  58. <span>{{userInfo?.BusinessName}}</span>
  59. <span v-if="userInfo?.Position">|</span>
  60. <span>{{userInfo?.Position}}</span>
  61. </div>
  62. </div>
  63. <!-- <div class="flex my-fav-box" @click="$router.push('/etaChart/favorite')">
  64. <t-icon name="star" style="font-size:20px"></t-icon>
  65. <span>我的收藏</span>
  66. <t-icon class="arrow-right" name="chevron-right-s" style="font-size:20px"></t-icon>
  67. </div> -->
  68. <div class="flex my-fav-box" style="color:#D54941" @click="handleLoginOut">
  69. <t-icon name="logout" style="font-size:20px"></t-icon>
  70. <span>退出登录</span>
  71. </div>
  72. </div>
  73. </template>
  74. <div class="userInfo-box">
  75. <svg-icon name="user_avatar" style="font-size:20px;margin-right:3px"></svg-icon>
  76. <span>{{userInfo?.RealName}}</span>
  77. <t-icon name="chevron-down" style="font-size:28px;margin-left:11px"></t-icon>
  78. </div>
  79. </t-popup>
  80. </div>
  81. <div class="layout-content" :style="dynamicStyle">
  82. <router-view />
  83. </div>
  84. </div>
  85. <!-- 音频模块 -->
  86. <AudioBox></AudioBox>
  87. </template>
  88. <style lang="scss">
  89. .header-userInfo-pop-wrap{
  90. padding: 0;
  91. width: 300px;
  92. border-radius: 8px;
  93. border: 1px solid var(--border-color);
  94. box-shadow: 0px 4px 12px 0px #0000001A;
  95. overflow: hidden;
  96. .content{
  97. .top-box{
  98. padding: 14px;
  99. background: linear-gradient(180deg, #7C55FF 0%, #4C64F7 100%);
  100. color: #fff;
  101. .label-text{
  102. font-size: 16px;
  103. line-height: 22.4px;
  104. }
  105. .flex{
  106. gap: 0 5px;
  107. margin-top: 5px;
  108. }
  109. .business-name > * {
  110. padding-right: 10px;
  111. }
  112. }
  113. .my-fav-box{
  114. border-bottom: 1px solid var(--border-color);
  115. height: 48px;
  116. align-items: center;
  117. padding: 0 14px;
  118. color: #666666;
  119. cursor: pointer;
  120. .arrow-right{
  121. margin-left: auto;
  122. }
  123. span{
  124. display: inline-block;
  125. margin-left: 12px;
  126. }
  127. }
  128. }
  129. }
  130. </style>
  131. <style lang="scss" scoped>
  132. .layout-wrap {
  133. height: 100%;
  134. padding-top: 70px;
  135. .header {
  136. position: fixed;
  137. left: 0;
  138. right: 0;
  139. top: 0;
  140. z-index: 10;
  141. height: 70px;
  142. background: linear-gradient(90deg, #7c54ff 0%, #4b64f7 100%);
  143. align-items: center;
  144. padding: 0 20px;
  145. .logo {
  146. width: 168px;
  147. margin-right: 20px;
  148. }
  149. .fav-btn{
  150. cursor: pointer;
  151. color: #fff;
  152. margin-left: auto;
  153. }
  154. .userInfo-box{
  155. margin-left: 30px;
  156. color: #fff;
  157. display: flex;
  158. align-items: center;
  159. cursor: pointer;
  160. }
  161. }
  162. .layout-content {
  163. padding: 20px;
  164. min-height: calc(100% - 70px);
  165. }
  166. }
  167. </style>