courseChapter.vue 5.3 KB

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