courseChapter.vue 1.8 KB

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