courseModule.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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" :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 '@/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. },
  30. components: {
  31. courseChapter
  32. },
  33. data() {
  34. return {
  35. down:true,
  36. list:[]
  37. };
  38. },
  39. onLoad() {},
  40. created() {
  41. },
  42. mounted() {
  43. },
  44. methods: {
  45. openModule(item){
  46. this.down = !this.down
  47. if(!this.down&&this.list.length==0){
  48. this.getChapterList(item.id)
  49. }
  50. },
  51. getChapterList(moduleId) {
  52. let self = this
  53. this.$api.chapterList(moduleId).then(res => {
  54. if(res.data.code==200){
  55. for(let i=0;i<res.data.data.length;i++){
  56. let item = res.data.data[i]
  57. item.id = item.chapterId
  58. }
  59. self.list = res.data.data
  60. }
  61. });
  62. },
  63. }
  64. };
  65. </script>
  66. <style scoped>
  67. .icon_up{
  68. width: 24rpx;
  69. height: 24rpx;
  70. }
  71. .title{
  72. font-size: 30rpx;
  73. font-family: PingFang SC;
  74. font-weight: bold;
  75. color: #333333;
  76. white-space:nowrap;
  77. overflow:hidden;
  78. text-overflow:ellipsis;
  79. }
  80. </style>