courseChapter.vue 4.7 KB

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