cwg-sidebar.vue 4.5 KB

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