courseChapter.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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/bank/questionBank?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. if(this.isRebuild){
  78. this.getReSectionList(item.id,item.courseId,item.moduleId)
  79. }else{
  80. this.getBuySectionList(item.id,item.courseId,item.moduleId)
  81. this.getMenuExamList(item.id,item.courseId,item.moduleId)
  82. }
  83. }else{
  84. this.getSectionList(item.id)
  85. }
  86. }
  87. },
  88. getMenuExamList(chapterId,courseId,moduleId) {
  89. let self = this
  90. this.$api.menuExamList({chapterId:chapterId,courseId:courseId,moduleId:moduleId}).then(res => {
  91. if(res.data.code==200){
  92. self.examList = res.data.rows
  93. }
  94. });
  95. },
  96. getSectionList(chapterId) {
  97. let self = this
  98. this.$api.sectionList(chapterId).then(res => {
  99. if(res.data.code==200){
  100. for(let i=0;i<res.data.data.length;i++){
  101. let item = res.data.data[i]
  102. item.id = item.sectionId
  103. //判断是否试听
  104. item.tryListen = false
  105. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  106. item.tryListen = true
  107. }
  108. }
  109. self.list = res.data.data
  110. }
  111. });
  112. },
  113. getReSectionList(chapterId,courseId,moduleId) {
  114. let self = this
  115. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,rebuild:1,moduleId:moduleId}).then(res => {
  116. if(res.data.code==200){
  117. for(let i=0;i<res.data.data.length;i++){
  118. let item = res.data.data[i]
  119. item.id = item.sectionId
  120. //判断是否试听
  121. item.tryListen = false
  122. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  123. item.tryListen = true
  124. }
  125. }
  126. self.list = res.data.data
  127. }
  128. });
  129. },
  130. getBuySectionList(chapterId,courseId,moduleId) {
  131. let self = this
  132. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,moduleId:moduleId}).then(res => {
  133. if(res.data.code==200){
  134. for(let i=0;i<res.data.data.length;i++){
  135. let item = res.data.data[i]
  136. item.id = item.sectionId
  137. //判断是否试听
  138. item.tryListen = false
  139. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  140. item.tryListen = true
  141. }
  142. }
  143. self.list = res.data.data
  144. }
  145. });
  146. },
  147. },computed: { ...mapGetters(['goodsAuditionConfigIdList']) },
  148. };
  149. </script>
  150. <style scoped>
  151. .eTag{
  152. width: 56rpx;
  153. height: 28rpx;
  154. background: #007AFF;
  155. border-radius: 8rpx;
  156. color: #FFFFFF;
  157. font-size: 20rpx;
  158. text-align: center;
  159. line-height: 20rpx;
  160. }
  161. .exam{
  162. display: flex;
  163. align-items: center;
  164. margin: 20rpx 0;
  165. }
  166. .icon_up{
  167. width: 24rpx;
  168. height: 24rpx;
  169. }
  170. .title{
  171. font-size: 24rpx;
  172. font-family: PingFang SC;
  173. font-weight: bold;
  174. color: #666666;
  175. white-space:nowrap;
  176. overflow:hidden;
  177. text-overflow:ellipsis;
  178. }
  179. </style>