cwg-right-drawer.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <uni-popup ref="popupRef" type="right" background-color="#f5f5f5">
  3. <view class="right-drawer">
  4. <view class="drawer-header">
  5. <image class="avatar" src="/static/logo.png" mode="aspectFill" />
  6. <view class="user-info">
  7. <text class="name">{{ displayName }}</text>
  8. <text class="cid">CID: {{ displayCid }}</text>
  9. </view>
  10. </view>
  11. <view class="menu-list">
  12. <view v-for="item in menuList" :key="item.key" class="menu-item"
  13. :class="{ active: activePath === item.path }" @click="handleNavigate(item.path)">
  14. <cwg-icon :name="item.icon" :size="16" :color="activePath === item.path ? '#fff' : '#0f172b'" />
  15. <text>{{ item.name }}</text>
  16. </view>
  17. </view>
  18. <view class="logout-wrap">
  19. <view class="logout-btn" @click="handleLogout">
  20. <cwg-icon name="logout" :size="16" color="#ff9800" />
  21. <text>Logout</text>
  22. </view>
  23. </view>
  24. </view>
  25. </uni-popup>
  26. </template>
  27. <script setup lang="ts">
  28. import { computed, ref } from 'vue'
  29. import useRoute from '@/hooks/useRoute'
  30. import useUserStore from '@/stores/use-user-store'
  31. import { useI18n } from "vue-i18n";
  32. const { t } = useI18n();
  33. const emit = defineEmits<{
  34. (e: 'navigate', path: string): void
  35. (e: 'logout'): void
  36. }>()
  37. const popupRef = ref<any>(null)
  38. const userStore = useUserStore()
  39. const userInfo = computed<any>(() => userStore.userInfo || {})
  40. const route = useRoute()
  41. const menuList = computed(() => [
  42. {
  43. id: 1, path: '/pages/mine/info?type=1', name: t('PersonalManagement.Title.PersonalInformation'), icon: 'crm-circle-user'
  44. },
  45. {
  46. id: 2, path: '/pages/mine/info?type=2', name: t('PersonalManagement.Title.BankInformation'), icon: 'crm-building-columns'
  47. },
  48. {
  49. id: 3, path: '/pages/mine/info?type=3', name: t('PersonalManagement.Title.FileManagement'), icon: 'crm-file'
  50. },
  51. {
  52. id: 4, path: '/pages/mine/info?type=4', name: t('PersonalManagement.Title.SecurityCenter'), icon: 'crm-lock'
  53. }
  54. ]);
  55. const displayName = computed(() => {
  56. const fullName = `${userInfo.value?.firstName || ''} ${userInfo.value?.lastName || ''}`.trim()
  57. return fullName || userInfo.value?.name || userInfo.value?.email || '--'
  58. })
  59. const displayCid = computed(() => userInfo.value?.cId || userInfo.value?.id || '--')
  60. const activePath = computed(() => route.path + (route.query?.type ? `?type=${route.query.type}` : '') || '')
  61. function open() {
  62. popupRef.value?.open()
  63. }
  64. function close() {
  65. popupRef.value?.close()
  66. }
  67. function handleNavigate(path: string) {
  68. emit('navigate', path)
  69. close()
  70. }
  71. function handleLogout() {
  72. emit('logout')
  73. close()
  74. }
  75. defineExpose({
  76. open,
  77. close
  78. })
  79. </script>
  80. <style scoped lang="scss">
  81. @import "@/uni.scss";
  82. .right-drawer {
  83. width: 300px;
  84. height: 100vh;
  85. background: #f5f5f5;
  86. display: flex;
  87. flex-direction: column;
  88. padding: 20px 16px;
  89. }
  90. .drawer-header {
  91. display: flex;
  92. align-items: center;
  93. gap: 12px;
  94. padding: 20px 16px;
  95. border-bottom: 1px solid #d9dde5;
  96. }
  97. .avatar {
  98. width: 76px;
  99. height: 76px;
  100. border-radius: 12px;
  101. background: #fff;
  102. }
  103. .user-info {
  104. display: flex;
  105. flex-direction: column;
  106. gap: 6px;
  107. }
  108. .name {
  109. font-size: 20px;
  110. font-weight: 600;
  111. color: #334155;
  112. }
  113. .cid {
  114. font-size: 14px;
  115. color: #ef4444;
  116. }
  117. .menu-list {
  118. padding: 12px 0;
  119. }
  120. .menu-item {
  121. height: 48px;
  122. display: flex;
  123. align-items: center;
  124. gap: 10px;
  125. padding: 0 16px;
  126. color: #0f172b;
  127. font-size: 16px;
  128. font-weight: 600;
  129. }
  130. .menu-item.active {
  131. background: #ea2027;
  132. color: #fff;
  133. }
  134. .logout-wrap {
  135. margin-top: auto;
  136. padding: 20px 16px;
  137. margin-bottom: 20px;
  138. }
  139. .logout-btn {
  140. height: 44px;
  141. background: #f4eadf;
  142. display: flex;
  143. align-items: center;
  144. justify-content: center;
  145. gap: 8px;
  146. color: #ff9800;
  147. font-weight: 600;
  148. }
  149. </style>