courseChapter.vue 4.6 KB

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