courseModule.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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" :gradeId="gradeId" :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. gradeId: { //重修需要班级ID
  38. type: Number,
  39. default: 0
  40. }
  41. },
  42. components: {
  43. courseChapter
  44. },
  45. data() {
  46. return {
  47. down:true,
  48. list:[]
  49. };
  50. },
  51. onLoad() {},
  52. created() {
  53. },
  54. mounted() {
  55. },
  56. methods: {
  57. openModule(item){
  58. this.down = !this.down
  59. if(!this.down&&this.list.length==0){
  60. this.getChapterList(item.id)
  61. }
  62. },
  63. getChapterList(moduleId) {
  64. let self = this
  65. this.$api.chapterList(moduleId).then(res => {
  66. if(res.data.code==200){
  67. for(let i=0;i<res.data.data.length;i++){
  68. let item = res.data.data[i]
  69. item.id = item.chapterId
  70. }
  71. self.list = res.data.data
  72. }
  73. });
  74. },
  75. }
  76. };
  77. </script>
  78. <style scoped>
  79. .icon_up{
  80. width: 24rpx;
  81. height: 24rpx;
  82. }
  83. .title{
  84. font-size: 30rpx;
  85. font-family: PingFang SC;
  86. font-weight: bold;
  87. color: #333333;
  88. white-space:nowrap;
  89. overflow:hidden;
  90. text-overflow:ellipsis;
  91. }
  92. </style>