cwg-sidebar.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. const info: any = userInfo.value
  46. return !!info && !!info.customInfo && info.customInfo.ibInvalid == 0 && !!info.ibInfo
  47. })
  48. </script>
  49. <style scoped lang="scss">
  50. @import "@/uni.scss";
  51. .cwg-sidebar {
  52. width: px2rpx(280);
  53. color: #6c8595;
  54. height: calc(100vh - 56px);
  55. overflow: auto;
  56. display: flex;
  57. flex-direction: column;
  58. align-items: center;
  59. padding: px2rpx(8);
  60. padding-top: px2rpx(20);
  61. box-sizing: border-box;
  62. gap: px2rpx(8);
  63. border-right: 1px solid rgba(108, 133, 149, 0.12);
  64. .logo {
  65. width: px2rpx(54);
  66. }
  67. .menu-list {
  68. flex: 1;
  69. width: 100%;
  70. overflow-y: auto;
  71. display: flex;
  72. flex-direction: column;
  73. gap: px2rpx(8);
  74. }
  75. .submenu-box {
  76. width: 100%;
  77. height: 0;
  78. overflow: hidden;
  79. }
  80. .menu {
  81. width: 100%;
  82. position: relative;
  83. display: flex;
  84. flex-direction: column;
  85. align-items: center;
  86. box-sizing: border-box;
  87. }
  88. .menu-item {
  89. width: 100%;
  90. height: px2rpx(40);
  91. cursor: pointer;
  92. display: flex;
  93. align-items: center;
  94. justify-content: space-between;
  95. gap: px2rpx(8);
  96. padding: px2rpx(10);
  97. box-sizing: border-box;
  98. font-size: 14px;
  99. .menu-label {
  100. flex: 1;
  101. }
  102. &:hover {
  103. background: rgba(108, 133, 149, 0.12) !important;
  104. border: 1px solid rgb(145, 163, 176) !important;
  105. border-radius: px2rpx(4);
  106. }
  107. .expanded .icon {
  108. transform: rotate(180deg);
  109. }
  110. }
  111. .ib-box {
  112. background: rgba(140, 69, 246, 0.08) !important;
  113. border: 1px solid rgba(140, 69, 246, 0.2) !important;
  114. font-size: px2rpx(18);
  115. font-weight: 600;
  116. color: #141d22;
  117. &:hover {
  118. background: rgba(140, 69, 246, 0.08) !important;
  119. border: 1px solid rgba(140, 69, 246, 0.2) !important;
  120. }
  121. }
  122. .zy-box {
  123. display: flex;
  124. align-items: center;
  125. justify-content: center;
  126. }
  127. .fixed {
  128. position: relative;
  129. width: 100%;
  130. display: flex;
  131. align-items: center;
  132. justify-content: center;
  133. gap: px2rpx(8);
  134. }
  135. }
  136. </style>