courseChapter.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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" :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. },
  39. components: {
  40. courseSection
  41. },
  42. data() {
  43. return {
  44. down:true,
  45. list:[]
  46. };
  47. },
  48. onLoad() {},
  49. created() {
  50. },
  51. mounted() {
  52. },
  53. methods: {
  54. openChapter(item){
  55. this.down = !this.down
  56. if(!this.down&&this.list.length==0){
  57. this.getSectionList(item.id)
  58. }
  59. },
  60. getSectionList(chapterId) {
  61. let self = this
  62. this.$api.sectionList(chapterId).then(res => {
  63. if(res.data.code==200){
  64. for(let i=0;i<res.data.data.length;i++){
  65. let item = res.data.data[i]
  66. item.id = item.sectionId
  67. //判断是否试听
  68. item.tryListen = false
  69. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  70. item.tryListen = true
  71. }
  72. }
  73. self.list = res.data.data
  74. }
  75. });
  76. },
  77. },computed: { ...mapGetters(['goodsAuditionConfigIdList']) },
  78. };
  79. </script>
  80. <style scoped>
  81. .icon_up{
  82. width: 24rpx;
  83. height: 24rpx;
  84. }
  85. .title{
  86. font-size: 24rpx;
  87. font-family: PingFang SC;
  88. font-weight: bold;
  89. color: #666666;
  90. white-space:nowrap;
  91. overflow:hidden;
  92. text-overflow:ellipsis;
  93. }
  94. </style>