courseModule.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view style="margin: 20rpx 0;">
  3. <view class="title" @click="openModule(menuItem)">
  4. <image src="/static/icon/up1.png" class="icon_up" v-if="down"></image>
  5. <image src="/static/icon/down1.png" class="icon_up" v-if="!down"></image>
  6. <text style="margin-left: 10rpx;">{{menuItem.name}}</text>
  7. </view>
  8. <view v-if="!down">
  9. <view v-for="(itemM,indexM) in list" >
  10. <courseChapter :menuItem="itemM"></courseChapter>
  11. <u-line v-if="indexM<list.length-1"></u-line>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import courseChapter from '@/pages2/components/course/courseChapter.vue';
  18. export default {
  19. name: 'courseModule',
  20. props: {
  21. menuItem: {
  22. type: Object,
  23. default: {}
  24. }
  25. },
  26. components: {
  27. courseChapter
  28. },
  29. data() {
  30. return {
  31. down:true,
  32. list:[]
  33. };
  34. },
  35. onLoad() {},
  36. created() {
  37. },
  38. mounted() {
  39. },
  40. methods: {
  41. openModule(item){
  42. this.down = !this.down
  43. if(!this.down&&this.list.length==0){
  44. this.getChapterList(item.id)
  45. }
  46. },
  47. getChapterList(moduleId) {
  48. let self = this
  49. this.$api.chapterList({moduleId:moduleId}).then(res => {
  50. if(res.data.code==200){
  51. for(let i=0;i<res.data.data.length;i++){
  52. let item = res.data.data[i]
  53. item.id = item.chapterId
  54. }
  55. self.list = res.data.data
  56. }
  57. });
  58. },
  59. }
  60. };
  61. </script>
  62. <style scoped>
  63. .icon_up{
  64. width: 24rpx;
  65. height: 24rpx;
  66. }
  67. .title{
  68. font-size: 30rpx;
  69. font-family: PingFang SC;
  70. font-weight: bold;
  71. color: #333333;
  72. white-space:nowrap;
  73. overflow:hidden;
  74. text-overflow:ellipsis;
  75. }
  76. </style>