courseChapter.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. learningOrder:{ //是否设置学习顺序 1 设置 0不设置
  38. type:String,
  39. default:'0'
  40. },
  41. menuItem: {
  42. type: Object,
  43. default: {}
  44. },
  45. isBuy: {
  46. type: Boolean,
  47. default: false
  48. },
  49. levelId: {
  50. type: String,
  51. default: ""
  52. },
  53. goodsId: {
  54. type: Number,
  55. default: 0
  56. },
  57. courseId: {
  58. type: Number,
  59. default: 0
  60. },
  61. isRebuild: {
  62. type: Boolean,
  63. default: false
  64. },
  65. gradeId: {
  66. type: Number,
  67. default: 0
  68. }
  69. },
  70. components: {
  71. courseSection
  72. },
  73. data() {
  74. return {
  75. down:true,
  76. list:[],
  77. examList:{},
  78. canLearn:false, //是否全部视频看完可以练习、测试
  79. };
  80. },
  81. onLoad() {},
  82. created() {
  83. },
  84. mounted() {
  85. },
  86. methods: {
  87. /**
  88. * 去做题
  89. */
  90. async toDo(id,goodsId =0,moduleId = 0, chapterId = 0) {
  91. if(this.learningOrder == 1) {
  92. if(this.canLearn) {
  93. uni.navigateTo({
  94. url:'/pages2/class/questionBank?courseId='+this.courseId+'&gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
  95. })
  96. } else {
  97. uni.showToast({
  98. icon:'none',
  99. title:'请学完视频课程再进行练习和测试'
  100. })
  101. }
  102. } else {
  103. uni.navigateTo({
  104. url:'/pages2/class/questionBank?courseId='+this.courseId+'&gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
  105. })
  106. }
  107. },
  108. openChapter(item){
  109. this.down = !this.down
  110. if(!this.down&&this.list.length==0){
  111. console.log(item.id,69)
  112. if(this.isBuy){
  113. let moduleId = item.moduleId?item.moduleId:0
  114. if(this.isRebuild){
  115. this.getReSectionList(item.id,item.courseId,moduleId)
  116. }else{
  117. this.getBuySectionList(item.id,item.courseId,moduleId)
  118. // this.getMenuExamList(item.id,item.courseId,moduleId)
  119. }
  120. }else{
  121. this.getSectionList(item.id)
  122. }
  123. }
  124. },
  125. getMenuExamList(chapterId,courseId,moduleId) {
  126. let self = this
  127. this.$api.menuExamList({chapterId:chapterId,courseId:courseId,moduleId:moduleId}).then(res => {
  128. if(res.data.code==200){
  129. self.examList = res.data.rows
  130. }
  131. });
  132. },
  133. getSectionList(chapterId) {
  134. let self = this
  135. this.$api.sectionList(chapterId).then(res => {
  136. if(res.data.code==200){
  137. for(let i=0;i<res.data.data.length;i++){
  138. let item = res.data.data[i]
  139. item.id = item.sectionId
  140. //判断是否试听
  141. item.tryListen = false
  142. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  143. item.tryListen = true
  144. }
  145. }
  146. let newArr = res.data.data.filter(item => {
  147. console.log(item)
  148. return item.type != 2;
  149. })
  150. this.canLearn = newArr.every(item => {
  151. console.log(item)
  152. if(item.learning == 1) {
  153. return true;
  154. } else {
  155. return false;
  156. }
  157. })
  158. self.list = res.data.data
  159. }
  160. });
  161. },
  162. getReSectionList(chapterId,courseId,moduleId) {
  163. let self = this
  164. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,rebuild:1,moduleId:moduleId}).then(res => {
  165. if(res.data.code==200){
  166. for(let i=0;i<res.data.data.length;i++){
  167. let item = res.data.data[i]
  168. item.id = item.sectionId
  169. //判断是否试听
  170. item.tryListen = false
  171. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  172. item.tryListen = true
  173. }
  174. }
  175. let newArr = res.data.data.filter(item => {
  176. console.log(item)
  177. return item.type != 2;
  178. })
  179. this.canLearn = newArr.every(item => {
  180. console.log(item)
  181. if(item.learning == 1) {
  182. return true;
  183. } else {
  184. return false;
  185. }
  186. })
  187. self.list = res.data.data
  188. }
  189. });
  190. },
  191. getBuySectionList(chapterId,courseId,moduleId) {
  192. let self = this
  193. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,moduleId:moduleId}).then(res => {
  194. if(res.data.code==200){
  195. for(let i=0;i<res.data.data.length;i++){
  196. let item = res.data.data[i]
  197. item.id = item.sectionId
  198. //判断是否试听
  199. item.tryListen = false
  200. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  201. item.tryListen = true
  202. }
  203. }
  204. let newArr = res.data.data.filter(item => {
  205. console.log(item)
  206. return item.type != 2;
  207. })
  208. this.canLearn = newArr.every(item => {
  209. console.log(item)
  210. if(item.learning == 1) {
  211. return true;
  212. } else {
  213. return false;
  214. }
  215. })
  216. self.list = res.data.data
  217. }
  218. });
  219. },
  220. },computed: { ...mapGetters(['goodsAuditionConfigIdList']) },
  221. };
  222. </script>
  223. <style scoped>
  224. .tagRe{
  225. width: 80rpx;
  226. height: 28rpx;
  227. background: #FF3B30;
  228. border-radius: 8rpx;
  229. font-size: 20rpx;
  230. color: #FFFFFF;
  231. text-align: center;
  232. }
  233. .tagGreen{
  234. width: 80rpx;
  235. height: 28rpx;
  236. background: #34C759;
  237. border-radius: 8rpx;
  238. font-size: 20rpx;
  239. color: #FFFFFF;
  240. text-align: center;
  241. }
  242. .eTag{
  243. width: 56rpx;
  244. height: 28rpx;
  245. background: #007AFF;
  246. border-radius: 8rpx;
  247. color: #FFFFFF;
  248. font-size: 20rpx;
  249. text-align: center;
  250. line-height: 28rpx;
  251. }
  252. .examBox{
  253. display: flex;
  254. align-items: center;
  255. justify-content: space-between;
  256. }
  257. .exam{
  258. display: flex;
  259. align-items: center;
  260. margin: 20rpx 0;
  261. }
  262. .icon_up{
  263. width: 24rpx;
  264. height: 24rpx;
  265. }
  266. .title{
  267. font-size: 24rpx;
  268. font-family: PingFang SC;
  269. font-weight: bold;
  270. color: #666666;
  271. white-space:nowrap;
  272. overflow:hidden;
  273. text-overflow:ellipsis;
  274. }
  275. </style>