courseChapter.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view style="margin: 20rpx 0;">
  3. <view class="title" @click="openChapter(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: 30rpx;">{{menuItem.name}}</text>
  7. </view>
  8. <view v-if="!down">
  9. <view v-for="(itemM,indexM) in list" >
  10. <courseSection :isBuy="isBuy" :isRebuild="isRebuild" :gradeId="gradeId" :menuItem="itemM" :levelId="levelId+'-'+itemM.sectionId"></courseSection>
  11. <u-line v-if="indexM<list.length-1"></u-line>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import { mapGetters } from 'vuex';
  18. import courseSection from '@/components/course/courseSection.vue';
  19. export default {
  20. name: 'courseChapter',
  21. props: {
  22. menuItem: {
  23. type: Object,
  24. default: {}
  25. },
  26. isBuy: {
  27. type: Boolean,
  28. default: false
  29. },
  30. levelId: {
  31. type: String,
  32. default: ""
  33. },
  34. isRebuild: {
  35. type: Boolean,
  36. default: false
  37. },
  38. gradeId: {
  39. type: Number,
  40. default: 0
  41. }
  42. },
  43. components: {
  44. courseSection
  45. },
  46. data() {
  47. return {
  48. down:true,
  49. list:[]
  50. };
  51. },
  52. onLoad() {},
  53. created() {
  54. },
  55. mounted() {
  56. },
  57. methods: {
  58. openChapter(item){
  59. this.down = !this.down
  60. if(!this.down&&this.list.length==0){
  61. this.getSectionList(item.id)
  62. }
  63. },
  64. getSectionList(chapterId) {
  65. let self = this
  66. this.$api.sectionList(chapterId).then(res => {
  67. if(res.data.code==200){
  68. for(let i=0;i<res.data.data.length;i++){
  69. let item = res.data.data[i]
  70. item.id = item.sectionId
  71. //判断是否试听
  72. item.tryListen = false
  73. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  74. item.tryListen = true
  75. }
  76. }
  77. self.list = res.data.data
  78. }
  79. });
  80. },
  81. },computed: { ...mapGetters(['goodsAuditionConfigIdList']) },
  82. };
  83. </script>
  84. <style scoped>
  85. .icon_up{
  86. width: 24rpx;
  87. height: 24rpx;
  88. }
  89. .title{
  90. font-size: 24rpx;
  91. font-family: PingFang SC;
  92. font-weight: bold;
  93. color: #666666;
  94. white-space:nowrap;
  95. overflow:hidden;
  96. text-overflow:ellipsis;
  97. }
  98. </style>