left-window.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 + index">
  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" color="#6c8595" />
  10. </view>
  11. </view>
  12. <view :ref="(el) => setSubmenuRef(index, el)" class="submenu-box" :a="index" :key1="item.path + index" :b="item"
  13. :style="{
  14. height: !(item.children && item.children.length) ? '0px' : item.isOpenMenu ? item.submenuHeight + 'px' : '0px',
  15. transition: 'height 281ms cubic-bezier(0.4, 0, 0.2, 1)'
  16. }" :class="{ 'active': item.isOpenMenu }">
  17. <cwg-submenu v-if="item.children && item.children.length" :submenu-items="item.children"
  18. @submenu-click="handleSubmenuClick" />
  19. </view>
  20. </view>
  21. </view>
  22. <view class="menu fixed">
  23. <view class="menu-item ib-box" @click="toIb" v-if="mode !== 'ib'">
  24. <cwg-icon name="crm-ib" :size="20" color="#6c8595" />
  25. <view class="menu-label" v-t="'Home.msg.Ib'" />
  26. </view>
  27. <view class="menu-item ib-box" @click="setMode('customer')" v-if="mode !== 'customer'">
  28. <cwg-icon name="crm-trade" :size="20" color="#6c8595" />
  29. <view class="menu-label" v-t="'Home.msg.Custom'" />
  30. </view>
  31. <view class="menu-item zy-box" @click="handleFixedMenuClick">
  32. <cwg-icon name="crm-zy" :size="20" color="#6c8595" />
  33. </view>
  34. </view>
  35. <!-- ib弹窗-->
  36. <IbInfo ref="ibRef"/>
  37. </view>
  38. </template>
  39. <script lang="ts" setup>
  40. import { ref } from 'vue'
  41. import { useMenuSplit } from '@/composables/useMenuSplit'
  42. import IbInfo from '@/components/IbInfo.vue'
  43. const { menus, setSubmenuRef, setMode, handleClick, handleSubmenuClick, mode } = useMenuSplit()
  44. const ibRef = ref(null)
  45. // 固定菜单项点击事件
  46. function handleFixedMenuClick() {
  47. // 这里可以添加固定菜单的点击处理逻辑
  48. console.log('Fixed menu clicked')
  49. }
  50. const toIb = ()=>{
  51. // 判断是否有注册过ib
  52. console.log(ibRef.value)
  53. if(ibRef.value){
  54. ibRef.value.getInfo()
  55. }
  56. setMode('ib')
  57. }
  58. </script>
  59. <style scoped lang="scss">
  60. @import "@/uni.scss";
  61. .cwg-sidebar {
  62. width: 100%;
  63. color: #6c8595;
  64. height: calc(100vh - 56px);
  65. overflow: hidden;
  66. display: flex;
  67. flex-direction: column;
  68. align-items: center;
  69. padding: px2rpx(8);
  70. padding-top: px2rpx(20);
  71. padding-bottom: px2rpx(8);
  72. box-sizing: border-box;
  73. gap: px2rpx(8);
  74. border-right: 1px solid rgba(108, 133, 149, 0.12);
  75. .logo {
  76. width: px2rpx(54);
  77. }
  78. .menu-list {
  79. flex: 1;
  80. width: 100%;
  81. overflow-y: auto;
  82. display: flex;
  83. flex-direction: column;
  84. gap: px2rpx(8);
  85. }
  86. .submenu-box {
  87. width: 100%;
  88. height: 0;
  89. overflow: hidden;
  90. }
  91. .menu {
  92. width: 100%;
  93. position: relative;
  94. display: flex;
  95. flex-direction: column;
  96. align-items: center;
  97. box-sizing: border-box;
  98. }
  99. .menu-item {
  100. width: 100%;
  101. height: px2rpx(40);
  102. cursor: pointer;
  103. display: flex;
  104. align-items: center;
  105. justify-content: space-between;
  106. gap: px2rpx(8);
  107. padding: px2rpx(10);
  108. box-sizing: border-box;
  109. font-size: 14px;
  110. .menu-label {
  111. flex: 1;
  112. }
  113. &:hover {
  114. background: rgba(108, 133, 149, 0.12) !important;
  115. border: 1px solid rgb(145, 163, 176) !important;
  116. border-radius: px2rpx(4);
  117. }
  118. .expanded .icon {
  119. transform: rotate(180deg);
  120. }
  121. }
  122. .ib-box {
  123. background: rgba(140, 69, 246, 0.08) !important;
  124. border: 1px solid rgba(140, 69, 246, 0.2) !important;
  125. font-size: px2rpx(18);
  126. font-weight: 600;
  127. color: #141d22;
  128. &:hover {
  129. background: rgba(140, 69, 246, 0.08) !important;
  130. border: 1px solid rgba(140, 69, 246, 0.2) !important;
  131. }
  132. }
  133. .zy-box {
  134. display: flex;
  135. align-items: center;
  136. justify-content: center;
  137. }
  138. .fixed {
  139. position: relative;
  140. width: 100%;
  141. display: flex;
  142. align-items: center;
  143. justify-content: center;
  144. gap: px2rpx(8);
  145. }
  146. }
  147. @media screen and (max-width: 1100px) {
  148. .cwg-sidebar:not(:hover) .menu-label,
  149. .cwg-sidebar:not(:hover) .submenu-box,
  150. .cwg-sidebar:not(:hover) .chevron-icon {
  151. display: none;
  152. }
  153. .cwg-sidebar:hover .menu-label,
  154. .cwg-sidebar:hover .submenu-box,
  155. .cwg-sidebar:hover .chevron-icon {
  156. display: block;
  157. }
  158. .cwg-sidebar .fixed {
  159. display: flex;
  160. }
  161. }
  162. </style>