courseChapter.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. <u-line v-if="examList.length>0"></u-line>
  14. <view class="exam" v-if="examList.length>0" @click="toDo(examList[0].examId)">
  15. <view class="eTag">{{examList[0].doType==1?'练习':'考试'}}</view>
  16. <view style="margin-left: 15rpx;">{{examList[0].examName}}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import { mapGetters } from 'vuex';
  23. import courseSection from '@/components/course/courseSection.vue';
  24. export default {
  25. name: 'courseChapter',
  26. props: {
  27. menuItem: {
  28. type: Object,
  29. default: {}
  30. },
  31. isBuy: {
  32. type: Boolean,
  33. default: false
  34. },
  35. levelId: {
  36. type: String,
  37. default: ""
  38. },
  39. isRebuild: {
  40. type: Boolean,
  41. default: false
  42. },
  43. gradeId: {
  44. type: Number,
  45. default: 0
  46. }
  47. },
  48. components: {
  49. courseSection
  50. },
  51. data() {
  52. return {
  53. down:true,
  54. list:[],
  55. examList:{}
  56. };
  57. },
  58. onLoad() {},
  59. created() {
  60. },
  61. mounted() {
  62. },
  63. methods: {
  64. /**
  65. * 去做题
  66. */
  67. async toDo(id,goodsId =0,moduleId = 0, chapterId = 0) {
  68. uni.navigateTo({
  69. url:'/pages2/class/questionBank?gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
  70. })
  71. },
  72. openChapter(item){
  73. this.down = !this.down
  74. if(!this.down&&this.list.length==0){
  75. console.log(item.id,69)
  76. if(this.isBuy){
  77. let moduleId = item.moduleId?item.moduleId:0
  78. if(this.isRebuild){
  79. this.getReSectionList(item.id,item.courseId,moduleId)
  80. }else{
  81. this.getBuySectionList(item.id,item.courseId,moduleId)
  82. this.getMenuExamList(item.id,item.courseId,moduleId)
  83. }
  84. }else{
  85. this.getSectionList(item.id)
  86. }
  87. }
  88. },
  89. getMenuExamList(chapterId,courseId,moduleId) {
  90. let self = this
  91. this.$api.menuExamList({chapterId:chapterId,courseId:courseId,moduleId:moduleId}).then(res => {
  92. if(res.data.code==200){
  93. self.examList = res.data.rows
  94. }
  95. });
  96. },
  97. getSectionList(chapterId) {
  98. let self = this
  99. this.$api.sectionList(chapterId).then(res => {
  100. if(res.data.code==200){
  101. for(let i=0;i<res.data.data.length;i++){
  102. let item = res.data.data[i]
  103. item.id = item.sectionId
  104. //判断是否试听
  105. item.tryListen = false
  106. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  107. item.tryListen = true
  108. }
  109. }
  110. self.list = res.data.data
  111. }
  112. });
  113. },
  114. getReSectionList(chapterId,courseId,moduleId) {
  115. let self = this
  116. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,rebuild:1,moduleId:moduleId}).then(res => {
  117. if(res.data.code==200){
  118. for(let i=0;i<res.data.data.length;i++){
  119. let item = res.data.data[i]
  120. item.id = item.sectionId
  121. //判断是否试听
  122. item.tryListen = false
  123. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  124. item.tryListen = true
  125. }
  126. }
  127. self.list = res.data.data
  128. }
  129. });
  130. },
  131. getBuySectionList(chapterId,courseId,moduleId) {
  132. let self = this
  133. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,moduleId:moduleId}).then(res => {
  134. if(res.data.code==200){
  135. for(let i=0;i<res.data.data.length;i++){
  136. let item = res.data.data[i]
  137. item.id = item.sectionId
  138. //判断是否试听
  139. item.tryListen = false
  140. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  141. item.tryListen = true
  142. }
  143. }
  144. self.list = res.data.data
  145. }
  146. });
  147. },
  148. },computed: { ...mapGetters(['goodsAuditionConfigIdList']) },
  149. };
  150. </script>
  151. <style scoped>
  152. .eTag{
  153. width: 56rpx;
  154. height: 28rpx;
  155. background: #007AFF;
  156. border-radius: 8rpx;
  157. color: #FFFFFF;
  158. font-size: 20rpx;
  159. text-align: center;
  160. line-height: 20rpx;
  161. }
  162. .exam{
  163. display: flex;
  164. align-items: center;
  165. margin: 20rpx 0;
  166. }
  167. .icon_up{
  168. width: 24rpx;
  169. height: 24rpx;
  170. }
  171. .title{
  172. font-size: 24rpx;
  173. font-family: PingFang SC;
  174. font-weight: bold;
  175. color: #666666;
  176. white-space:nowrap;
  177. overflow:hidden;
  178. text-overflow:ellipsis;
  179. }
  180. </style>