cwg-sidebar.vue 4.7 KB

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