courseModule.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 :isBuy="isBuy" :isRebuild="isRebuild" :menuItem="itemM" :levelId="levelId+'-'+itemM.chapterId"></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 '@/components/course/courseChapter.vue';
  18. export default {
  19. name: 'courseModule',
  20. props: {
  21. menuItem: {
  22. type: Object,
  23. default: {}
  24. },
  25. isBuy: {
  26. type: Boolean,
  27. default: false
  28. },
  29. levelId: {
  30. type: String,
  31. default: ""
  32. },
  33. isRebuild: {
  34. type: Boolean,
  35. default: false
  36. }
  37. },
  38. components: {
  39. courseChapter
  40. },
  41. data() {
  42. return {
  43. down:true,
  44. list:[]
  45. };
  46. },
  47. onLoad() {},
  48. created() {
  49. },
  50. mounted() {
  51. },
  52. methods: {
  53. openModule(item){
  54. this.down = !this.down
  55. if(!this.down&&this.list.length==0){
  56. this.getChapterList(item.id)
  57. }
  58. },
  59. getChapterList(moduleId) {
  60. let self = this
  61. this.$api.chapterList(moduleId).then(res => {
  62. if(res.data.code==200){
  63. for(let i=0;i<res.data.data.length;i++){
  64. let item = res.data.data[i]
  65. item.id = item.chapterId
  66. }
  67. self.list = res.data.data
  68. }
  69. });
  70. },
  71. }
  72. };
  73. </script>
  74. <style scoped>
  75. .icon_up{
  76. width: 24rpx;
  77. height: 24rpx;
  78. }
  79. .title{
  80. font-size: 30rpx;
  81. font-family: PingFang SC;
  82. font-weight: bold;
  83. color: #333333;
  84. white-space:nowrap;
  85. overflow:hidden;
  86. text-overflow:ellipsis;
  87. }
  88. </style>