courseChapter.vue 5.1 KB

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