cwg-sidebar.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="cwg-sidebar">
  3. <view class="menu-list">
  4. <view class="menu" v-for="(item, index) in menus" :key="item.path">
  5. <view class="menu-item" @click="handleClick(index)">
  6. <cwg-icon :name="item.icon" :size="20" color="#6c8595" />
  7. <view class="menu-label" v-t="item.label" />
  8. <view class="chevron-icon" :class="{ 'expanded': item.isOpenMenu }">
  9. <cwg-icon v-if="item.children && item.children.length" name="crm-chevron-down" :size="20"
  10. color="#6c8595" />
  11. </view>
  12. </view>
  13. <view :ref="(el) => setSubmenuRef(index, el)" class="submenu-box" :a="index" :key1="item.path + index"
  14. :b="item" :style="{
  15. height: !(item.children && item.children.length) ? '0px' : item.isOpenMenu ? item.submenuHeight + 'px' : '0px',
  16. transition: 'height 281ms cubic-bezier(0.4, 0, 0.2, 1)'
  17. }" :class="{ 'active': item.isOpenMenu }">
  18. <cwg-submenu v-if="item.children && item.children.length" :submenu-items="item.children"
  19. @submenu-click="handleSubmenuClick" />
  20. </view>
  21. </view>
  22. </view>
  23. <view class="menu fixed">
  24. <view class="menu-item ib-box" @click="setMode('ib')" v-if="mode !== 'ib' && ibStatus">
  25. <cwg-icon name="crm-ib" :size="20" color="#6c8595" />
  26. <view class="menu-label" v-t="'Home.msg.Ib'" />
  27. </view>
  28. <view class="menu-item ib-box" @click="setMode('customer')" v-if="mode !== 'customer'">
  29. <cwg-icon name="crm-trade" :size="20" color="#6c8595" />
  30. <view class="menu-label" v-t="'Home.msg.Custom'" />
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script lang="ts" setup>
  36. import useUserStore from '@/stores/use-user-store'
  37. import { useMenuSplit } from '@/composables/useMenuSplit'
  38. import { computed } from 'vue'
  39. import { storeToRefs } from 'pinia'
  40. const { menus, setSubmenuRef, setMode, handleClick, handleSubmenuClick, mode } = useMenuSplit()
  41. const userStore = useUserStore()
  42. const { userInfo } = storeToRefs(userStore)
  43. // ib按钮展示
  44. const ibStatus = computed(() => {
  45. return userInfo.value?.customInfo?.ibInvalid == 0 && !!userInfo.value?.ibInfo
  46. })
  47. </script>
  48. <style scoped lang="scss">
  49. @import "@/uni.scss";
  50. .cwg-sidebar {
  51. width: px2rpx(280);
  52. color: #6c8595;
  53. height: calc(100vh - 56px);
  54. overflow: auto;
  55. display: flex;
  56. flex-direction: column;
  57. align-items: center;
  58. padding: px2rpx(8);
  59. padding-top: px2rpx(20);
  60. box-sizing: border-box;
  61. gap: px2rpx(8);
  62. border-right: 1px solid rgba(108, 133, 149, 0.12);
  63. .logo {
  64. width: px2rpx(54);
  65. }
  66. .menu-list {
  67. flex: 1;
  68. width: 100%;
  69. overflow-y: auto;
  70. display: flex;
  71. flex-direction: column;
  72. gap: px2rpx(8);
  73. }
  74. .submenu-box {
  75. width: 100%;
  76. height: 0;
  77. overflow: hidden;
  78. }
  79. .menu {
  80. width: 100%;
  81. position: relative;
  82. display: flex;
  83. flex-direction: column;
  84. align-items: center;
  85. box-sizing: border-box;
  86. }
  87. .menu-item {
  88. width: 100%;
  89. height: px2rpx(40);
  90. cursor: pointer;
  91. display: flex;
  92. align-items: center;
  93. justify-content: space-between;
  94. gap: px2rpx(8);
  95. padding: px2rpx(10);
  96. box-sizing: border-box;
  97. font-size: 14px;
  98. .menu-label {
  99. flex: 1;
  100. }
  101. &:hover {
  102. background: rgba(108, 133, 149, 0.12) !important;
  103. border: 1px solid rgb(145, 163, 176) !important;
  104. border-radius: px2rpx(4);
  105. }
  106. .expanded .icon {
  107. transform: rotate(180deg);
  108. }
  109. }
  110. .ib-box {
  111. background: rgba(140, 69, 246, 0.08) !important;
  112. border: 1px solid rgba(140, 69, 246, 0.2) !important;
  113. font-size: px2rpx(18);
  114. font-weight: 600;
  115. color: #141d22;
  116. &:hover {
  117. background: rgba(140, 69, 246, 0.08) !important;
  118. border: 1px solid rgba(140, 69, 246, 0.2) !important;
  119. }
  120. }
  121. .zy-box {
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. }
  126. .fixed {
  127. position: relative;
  128. width: 100%;
  129. display: flex;
  130. align-items: center;
  131. justify-content: center;
  132. gap: px2rpx(8);
  133. }
  134. }
  135. </style>