goodsItem.vue 1.8 KB

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