kecheng-mulu.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="kecheng-mulu-box">
  3. <myCollapseCardVue v-for="zhang in chapterArr" :title="zhang.name" @click.stop="handleZhangClick(zhang)" @tap.stop="handleZhangClick(zhang)"
  4. :open="zhang.open">
  5. <myCollapseCardVue v-for="jie in zhang.jieList" :title="jie.name" @click.stop="handleJieClick(jie, zhang)" @tap.stop="handleJieClick(jie, zhang)"
  6. :open="jie.open">
  7. <view :class="{'kejian-active': activeKjId == item.kjId,'kejian-item':true }" v-for="item in jie.kejianList" @tap.stop="handleKejianClick(item)" @click.stop="handleKejianClick(item)">
  8. <icon class="kejian-item-icon"
  9. :style="{
  10. backgroundImage: `url(${activeKjId == item.kjId
  11. ? iconsArr.playIconA
  12. : iconsArr.playIcon})`
  13. }"
  14. ></icon>
  15. <text class="kejian-item-name">{{item.name}}</text>
  16. <!-- <text v-if="isHasProgress">
  17. <text v-if="item.maxProcess < 100">{{item.maxProcess >= item.curProcess ? item.maxProcess: item.curProcess}}%</text>
  18. <text v-else>{{item.maxProcess}}%</text>
  19. </text> -->
  20. </view>
  21. </myCollapseCardVue>
  22. </myCollapseCardVue>
  23. </view>
  24. </template>
  25. <script setup>
  26. import cacheManager from '@/utils/cacheManager.js';
  27. import myCollapseCardVue from '../myCollapseCard/myCollapseCard.vue';
  28. import {ref,reactive,onMounted} from 'vue';
  29. const props = defineProps({
  30. chapterArr: {
  31. type: Array
  32. },
  33. isHasProgress: {
  34. type: Boolean
  35. },
  36. activeKjId: {
  37. type: [Number,String]
  38. }
  39. })
  40. const iconsArr = reactive({
  41. playIcon: '',
  42. playIconA: '',
  43. })
  44. const emits = defineEmits(['play'])
  45. function handleZhangClick(item) {
  46. if (item.open) {
  47. // 展开 -》 关闭
  48. props.chapterArr.forEach(zhang => {
  49. zhang.open = false;
  50. zhang.jieList.forEach(jie => {
  51. jie.open = false;
  52. })
  53. })
  54. } else {
  55. // 关闭 -》 展开
  56. props.chapterArr.forEach(zhang => {
  57. zhang.open = false;
  58. zhang.jieList.forEach(jie => {
  59. jie.open = false;
  60. })
  61. })
  62. item.open = true;
  63. }
  64. }
  65. function handleJieClick(item, zhang) {
  66. if (item.open) {
  67. // 展开 -》 关闭
  68. zhang.jieList.forEach(jie => {
  69. jie.open = false;
  70. })
  71. } else {
  72. // 关闭 -》 展开
  73. zhang.jieList.forEach(jie => {
  74. jie.open = false;
  75. })
  76. item.open = true;
  77. }
  78. }
  79. function handleKejianClick(item) {
  80. emits('play', item)
  81. }
  82. onMounted(() => {
  83. iconsArr.playIcon = cacheManager.get('projectImg').play_icon;
  84. iconsArr.playIconA = cacheManager.get('projectImg').play_icon_a;
  85. });
  86. </script>