index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="pt-3 d-flex parent">
  3. <v-card class="left">
  4. <v-list color="primary">
  5. <v-list-subheader class="title mb-3">个人中心</v-list-subheader>
  6. <v-divider></v-divider>
  7. <template v-for="(item, index) in list">
  8. <template v-if="!item.children.length">
  9. <v-list-item
  10. :key="`${item.name}_${index}`"
  11. active-class="active"
  12. color="primary"
  13. :href="item.path"
  14. :to="item.path"
  15. :prepend-icon="item.icon"
  16. :title="getCurrentLocaleLang() === 'zh_CN' ? item.title : item.enName"
  17. >
  18. </v-list-item>
  19. </template>
  20. <v-list-group
  21. v-else
  22. color="primary"
  23. :key="`${item.path}_${item.title}`"
  24. :prepend-icon="item.icon"
  25. >
  26. <template v-slot:activator="{ props }">
  27. <v-list-item v-bind="props" :title="getCurrentLocaleLang() === 'zh_CN' ? item.title : item.enName"></v-list-item>
  28. </template>
  29. <v-list-item
  30. v-for="(val, i) in item.children"
  31. :key="i"
  32. color="primary"
  33. :href="val.path"
  34. style="padding-left: 40px;"
  35. :to="val.path"
  36. :title="getCurrentLocaleLang() === 'zh_CN' ? val.title : val.enName"
  37. ></v-list-item>
  38. </v-list-group>
  39. </template>
  40. </v-list>
  41. </v-card>
  42. <v-card class="ml-3 pa-3 page">
  43. <router-view></router-view>
  44. </v-card>
  45. </div>
  46. <PreviewImage v-if="showPreview" :initialIndex="initialIndex" :fileName="fileName" :urlList="urlsList" @close="handleClosePreview" />
  47. </template>
  48. <script setup>
  49. defineOptions({ name: 'person-center'})
  50. import { computed, ref } from 'vue'
  51. import { getCurrentLocaleLang } from '@/utils/lang.js'
  52. import personCenterRoute from '@/router/modules/components/recruit/personCenter'
  53. import { useUserStore } from '@/store/user'
  54. import { usePersonCenterStore } from '@/store/personCenter'
  55. import { useRoute } from 'vue-router'
  56. const route = useRoute()
  57. const userStore = useUserStore()
  58. const info = localStorage.getItem('baseInfo') ? JSON.parse(localStorage.getItem('baseInfo')) : {}
  59. const menuDelete = { // 是否隐藏
  60. studentInformation: !(info?.type && Number(info.type) === 1) // 学生信息管理。 type:0是求职者,1是学生
  61. }
  62. // 左侧菜单列表
  63. const list = computed(() => {
  64. return getList(personCenterRoute[0].children[0].children)
  65. })
  66. console.log(import.meta.env.VITE_NODE_ENV, '当前环境变量===========')
  67. const getList = (arr, obj = []) => {
  68. arr.forEach(element => {
  69. if (element.show) return
  70. if (menuDelete[element.permissionName]) return
  71. let data = {}
  72. data = {
  73. title: element?.meta?.title,
  74. enName: element?.meta?.enName,
  75. icon: element?.meta?.icon,
  76. name: element?.name,
  77. path: element?.path,
  78. children: []
  79. }
  80. if (element?.children) {
  81. getList(element.children, data.children)
  82. }
  83. obj.push(data)
  84. })
  85. // 生产环境暂时不展示收货地址
  86. if (import.meta.env.VITE_NODE_ENV === 'production') obj = obj.filter(e => e.path !== '/recruit/personal/personalCenter/shippingAddress')
  87. return obj
  88. }
  89. const personCenterStore = usePersonCenterStore()
  90. const showPreview = ref(false)
  91. const initialIndex = ref(0)
  92. const urlsList = ref([])
  93. const fileName = ref('')
  94. personCenterStore.$subscribe((mutation, state) => {
  95. if (state.urlsList.length > 0) {
  96. urlsList.value = state.urlsList
  97. initialIndex.value = state.initialIndex
  98. fileName.value = state.fileName
  99. showPreview.value = true
  100. }
  101. })
  102. const handleClosePreview = () => {
  103. personCenterStore.clearPreviewData()
  104. showPreview.value = false
  105. }
  106. // 更新账户信息
  107. const refreshPath = [
  108. '/recruit/personal/personalCenter/wallet',
  109. '/recruit/personal/personalCenter/tradeOrder',
  110. '/recruit/personal/personalCenter/inviteRecord',
  111. '/recruit/personal/personalCenter/memberBenefits/taskCenter'
  112. ]
  113. const updateAccountInfo = async () => {
  114. await userStore.getUserAccountInfo()
  115. }
  116. if (refreshPath.includes(route.path)) updateAccountInfo()
  117. </script>
  118. <style scoped lang="scss">
  119. .parent {
  120. width: 1300px;
  121. max-width: 1300px;
  122. min-width: 1300px;
  123. margin: 0 auto;
  124. height: calc(100vh - 100px);
  125. overflow-y: auto;
  126. }
  127. .page {
  128. flex: 1;
  129. width: 100%;
  130. overflow-y: auto;
  131. overflow-x: hidden;
  132. }
  133. .left {
  134. position: sticky;
  135. width: 220px;
  136. height: calc(100vh - 113px);
  137. overflow-y: auto;
  138. }
  139. .title {
  140. color: var(--color-333);
  141. font-weight: 600;
  142. font-size: 20px;
  143. }
  144. ::-webkit-scrollbar {
  145. width: 6px;
  146. height: 10px;
  147. }
  148. ::-webkit-scrollbar-thumb, .temporaryAdd ::-webkit-scrollbar-thumb, .details_edit ::-webkit-scrollbar-thumb {
  149. // 滚动条-颜色
  150. background: #c3c3c379;
  151. }
  152. ::-webkit-scrollbar-track, .temporaryAdd ::-webkit-scrollbar-track, .details_edit ::-webkit-scrollbar-track {
  153. // 滚动条-底色
  154. background: #e5e5e58f;
  155. }
  156. </style>