courseChapter.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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" :nextMenuItem="findNextSection(indexM)" :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,itemM,indexM)">
  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:itemM.reportStatus == 1,tagRe:itemM.reportStatus == 0 || itemM.rebuild>0}">
  24. <!-- 已做完 -->
  25. <text v-if="itemM.rebuild > 0">待重测</text>
  26. <text v-else-if="itemM.reportStatus == 1">合格</text>
  27. <text v-else-if="itemM.reportStatus == 0">不合格</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import { mapGetters } from 'vuex';
  38. import courseSection from '@/components/course/courseSection.vue';
  39. export default {
  40. name: 'courseChapter',
  41. props: {
  42. learningOrder:{ //是否设置学习顺序 1 设置 0不设置
  43. type:String,
  44. default:'0'
  45. },
  46. menuItem: {
  47. type: Object,
  48. default: {}
  49. },
  50. isBuy: {
  51. type: Boolean,
  52. default: false
  53. },
  54. levelId: {
  55. type: String,
  56. default: ""
  57. },
  58. goodsId: {
  59. type: Number,
  60. default: 0
  61. },
  62. courseId: {
  63. type: Number,
  64. default: 0
  65. },
  66. isRebuild: {
  67. type: Boolean,
  68. default: false
  69. },
  70. gradeId: {
  71. type: Number,
  72. default: 0
  73. }
  74. },
  75. components: {
  76. courseSection
  77. },
  78. data() {
  79. return {
  80. down:true,
  81. list:[],
  82. examList:{},
  83. canLearn:false, //是否全部视频看完可以练习、测试
  84. };
  85. },
  86. onLoad() {},
  87. created() {
  88. },
  89. mounted() {
  90. },
  91. methods: {
  92. findNextSection(index){
  93. for(let i=index+1;i<this.list.length;i++){
  94. return this.list[i];
  95. }
  96. return {}
  97. },
  98. /**
  99. * 去做题
  100. */
  101. async toDo(id,goodsId =0,moduleId = 0, chapterId = 0,item,index) {
  102. if(this.learningOrder == 1) {
  103. if(this.canLearn) {
  104. let num = await this.bankRecordDoNum(item.typeId)
  105. //有次数限制
  106. if(item.answerNum - num > 0 && item.answerNum > 0) {
  107. // this.$set(this.list[index],'doNum',(item.doNum+1))
  108. console.log(this.list[index])
  109. uni.navigateTo({
  110. url:'/pages2/class/questionBank?courseId='+this.courseId+'&gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
  111. })
  112. //没有答题次数限制
  113. } else if(item.answerNum == 0) {
  114. uni.navigateTo({
  115. url:'/pages2/class/questionBank?courseId='+this.courseId+'&gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
  116. })
  117. } else {
  118. uni.showToast({
  119. icon:'none',
  120. title:'该试卷只能答题'+item.answerNum+'次'
  121. })
  122. return;
  123. }
  124. } else {
  125. uni.showToast({
  126. icon:'none',
  127. title:'请学完视频课程再进行练习和测试'
  128. })
  129. }
  130. } else {
  131. let num = await this.bankRecordDoNum(item.typeId)
  132. //有次数限制
  133. if(item.answerNum - item.doNum > 0 && item.answerNum > 0) {
  134. // this.$set(this.list[index],'doNum',(item.doNum+1))
  135. console.log(this.list[index])
  136. uni.navigateTo({
  137. url:'/pages2/class/questionBank?courseId='+this.courseId+'&gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
  138. })
  139. //没有答题次数限制
  140. } else if(item.answerNum == 0) {
  141. uni.navigateTo({
  142. url:'/pages2/class/questionBank?courseId='+this.courseId+'&gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
  143. })
  144. } else {
  145. uni.showToast({
  146. icon:'none',
  147. title:'该试卷只能答题'+item.answerNum+'次'
  148. })
  149. return;
  150. }
  151. }
  152. },
  153. bankRecordDoNum(examId) {
  154. return new Promise(resolve => {
  155. this.$api.bankRecordDoNum({
  156. goodsId:this.goodsId,
  157. gradeId:this.gradeId,
  158. chapterId:this.menuItem.id,
  159. courseId:this.courseId,
  160. moduleId:0,
  161. examId:examId,
  162. }).then(res => {
  163. resolve(res.data.data)
  164. })
  165. })
  166. },
  167. openChapter(item){
  168. this.down = !this.down
  169. if(!this.down&&this.list.length==0){
  170. console.log(item.id,69)
  171. if(this.isBuy){
  172. let moduleId = item.moduleId?item.moduleId:0
  173. if(this.isRebuild){
  174. this.getReSectionList(item.id,item.courseId,moduleId)
  175. }else{
  176. this.getBuySectionList(item.id,item.courseId,moduleId)
  177. // this.getMenuExamList(item.id,item.courseId,moduleId)
  178. }
  179. }else{
  180. this.getSectionList(item.id)
  181. }
  182. }
  183. },
  184. getMenuExamList(chapterId,courseId,moduleId) {
  185. let self = this
  186. this.$api.menuExamList({chapterId:chapterId,courseId:courseId,moduleId:moduleId}).then(res => {
  187. if(res.data.code==200){
  188. self.examList = res.data.rows
  189. }
  190. });
  191. },
  192. getSectionList(chapterId) {
  193. let self = this
  194. this.$api.sectionList(chapterId).then(res => {
  195. if(res.data.code==200){
  196. for(let i=0;i<res.data.data.length;i++){
  197. let item = res.data.data[i]
  198. item.id = item.sectionId
  199. //判断是否试听
  200. item.tryListen = false
  201. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  202. item.tryListen = true
  203. }
  204. }
  205. let newArr = res.data.data.filter(item => {
  206. console.log(item)
  207. return item.type != 2;
  208. })
  209. this.canLearn = newArr.every(item => {
  210. console.log(item)
  211. if(item.learning == 1) {
  212. return true;
  213. } else {
  214. return false;
  215. }
  216. })
  217. self.list = res.data.data
  218. }
  219. });
  220. },
  221. getReSectionList(chapterId,courseId,moduleId) {
  222. let self = this
  223. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,rebuild:1,moduleId:moduleId}).then(res => {
  224. if(res.data.code==200){
  225. for(let i=0;i<res.data.data.length;i++){
  226. let item = res.data.data[i]
  227. item.id = item.sectionId
  228. //判断是否试听
  229. item.tryListen = false
  230. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  231. item.tryListen = true
  232. }
  233. }
  234. let newArr = res.data.data.filter(item => {
  235. console.log(item)
  236. return item.type != 2;
  237. })
  238. this.canLearn = newArr.every(item => {
  239. console.log(item)
  240. if(item.learning == 1) {
  241. return true;
  242. } else {
  243. return false;
  244. }
  245. })
  246. self.list = res.data.data
  247. }
  248. });
  249. },
  250. getBuySectionList(chapterId,courseId,moduleId) {
  251. let self = this
  252. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,moduleId:moduleId}).then(res => {
  253. if(res.data.code==200){
  254. for(let i=0;i<res.data.data.length;i++){
  255. let item = res.data.data[i]
  256. item.id = item.sectionId
  257. //判断是否试听
  258. item.tryListen = false
  259. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  260. item.tryListen = true
  261. }
  262. }
  263. let newArr = res.data.data.filter(item => {
  264. console.log(item)
  265. return item.type != 2;
  266. })
  267. this.canLearn = newArr.every(item => {
  268. console.log(item)
  269. if(item.learning == 1) {
  270. return true;
  271. } else {
  272. return false;
  273. }
  274. })
  275. self.list = res.data.data
  276. }
  277. });
  278. },
  279. },computed: { ...mapGetters(['goodsAuditionConfigIdList']) },
  280. };
  281. </script>
  282. <style scoped>
  283. .tagRe{
  284. width: 80rpx;
  285. height: 28rpx;
  286. background: #FF3B30;
  287. border-radius: 8rpx;
  288. font-size: 20rpx;
  289. color: #FFFFFF;
  290. text-align: center;
  291. }
  292. .tagGreen{
  293. width: 80rpx;
  294. height: 28rpx;
  295. background: #34C759;
  296. border-radius: 8rpx;
  297. font-size: 20rpx;
  298. color: #FFFFFF;
  299. text-align: center;
  300. }
  301. .eTag{
  302. width: 56rpx;
  303. height: 28rpx;
  304. background: #007AFF;
  305. border-radius: 8rpx;
  306. color: #FFFFFF;
  307. font-size: 20rpx;
  308. text-align: center;
  309. line-height: 28rpx;
  310. }
  311. .examBox{
  312. display: flex;
  313. align-items: center;
  314. justify-content: space-between;
  315. }
  316. .exam{
  317. display: flex;
  318. align-items: center;
  319. margin: 20rpx 0;
  320. }
  321. .icon_up{
  322. width: 24rpx;
  323. height: 24rpx;
  324. }
  325. .title{
  326. font-size: 24rpx;
  327. font-family: PingFang SC;
  328. font-weight: bold;
  329. color: #666666;
  330. white-space:nowrap;
  331. overflow:hidden;
  332. text-overflow:ellipsis;
  333. }
  334. </style>