foldingPanel.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div class="w-full fold">
  3. <div class="foldingTheHead" @click="handleBox" :style="`background-color: ${bgColor}`">
  4. <div class="flex items-center">
  5. <van-icon name="play" class="text-size-in expandAndCollapseIcon" color="#FF8B32" :style="selStatus ? 'transform: rotate(90deg);' : 'transform: rotate(0deg);'" />
  6. <div class="text-[#FF8B32] pl-1">{{ title }}</div>
  7. </div>
  8. <slot name="foldingRight"></slot>
  9. </div>
  10. <div class="container">
  11. <div :class="selClassName">
  12. <slot name="foldContainer"></slot>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script setup>
  18. import { ref } from 'vue';
  19. import { useLifecycle } from "@hooks/useCommon.js";
  20. const props = defineProps({
  21. bgColor: {
  22. type: String,
  23. default: '#FFEFE2'
  24. },
  25. title: {
  26. type: String,
  27. default: '标题'
  28. }
  29. })
  30. useLifecycle({
  31. load: () => {
  32. // 添加加载逻辑
  33. }
  34. });
  35. const selClassName = ref(['sel-menu', 'expand'])
  36. const selStatus = ref(true)
  37. const handleBox = () => {
  38. if (selStatus.value) {
  39. selClassName.value.pop()
  40. selStatus.value = false
  41. } else {
  42. selClassName.value.push('expand')
  43. selStatus.value = true
  44. }
  45. }
  46. </script>
  47. <style scoped lang="scss">
  48. .fold {
  49. margin-bottom: 10px;
  50. .foldingTheHead {
  51. min-height: 44px;
  52. display: flex;
  53. justify-content: space-between;
  54. align-items: center;
  55. padding: 7px 16px 7px 12px;
  56. }
  57. .container {
  58. height: calc(100% - 50px);
  59. display: flex;
  60. justify-content: center;
  61. // 折叠样式
  62. .sel-menu {
  63. width: 100%;
  64. overflow: hidden;
  65. cursor: pointer;
  66. transition: max-height 0.5s linear;
  67. position: relative;
  68. }
  69. .sel-menu {
  70. max-height: 0;
  71. }
  72. .expand {
  73. max-height: 1000px;
  74. }
  75. }
  76. .expandAndCollapseIcon {
  77. transition: 0.5s ease-in-out;
  78. }
  79. }
  80. </style>