courseChapter.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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,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. /**
  93. * 去做题
  94. */
  95. async toDo(id,goodsId =0,moduleId = 0, chapterId = 0,item,index) {
  96. if(this.learningOrder == 1) {
  97. if(this.canLearn) {
  98. let num = await this.bankRecordDoNum(item.typeId)
  99. //有次数限制
  100. if(item.answerNum - num > 0 && item.answerNum > 0) {
  101. // this.$set(this.list[index],'doNum',(item.doNum+1))
  102. console.log(this.list[index])
  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. } else if(item.answerNum == 0) {
  108. uni.navigateTo({
  109. url:'/pages2/class/questionBank?courseId='+this.courseId+'&gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
  110. })
  111. } else {
  112. uni.showToast({
  113. icon:'none',
  114. title:'该试卷只能答题'+item.answerNum+'次'
  115. })
  116. return;
  117. }
  118. } else {
  119. uni.showToast({
  120. icon:'none',
  121. title:'请学完视频课程再进行练习和测试'
  122. })
  123. }
  124. } else {
  125. let num = await this.bankRecordDoNum(item.typeId)
  126. //有次数限制
  127. if(item.answerNum - item.doNum > 0 && item.answerNum > 0) {
  128. // this.$set(this.list[index],'doNum',(item.doNum+1))
  129. console.log(this.list[index])
  130. uni.navigateTo({
  131. url:'/pages2/class/questionBank?courseId='+this.courseId+'&gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
  132. })
  133. //没有答题次数限制
  134. } else if(item.answerNum == 0) {
  135. uni.navigateTo({
  136. url:'/pages2/class/questionBank?courseId='+this.courseId+'&gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
  137. })
  138. } else {
  139. uni.showToast({
  140. icon:'none',
  141. title:'该试卷只能答题'+item.answerNum+'次'
  142. })
  143. return;
  144. }
  145. }
  146. },
  147. bankRecordDoNum(examId) {
  148. return new Promise(resolve => {
  149. this.$api.bankRecordDoNum({
  150. goodsId:this.goodsId,
  151. gradeId:this.gradeId,
  152. chapterId:this.menuItem.id,
  153. courseId:this.courseId,
  154. moduleId:0,
  155. examId:examId,
  156. }).then(res => {
  157. resolve(res.data.data)
  158. })
  159. })
  160. },
  161. openChapter(item){
  162. this.down = !this.down
  163. if(!this.down&&this.list.length==0){
  164. console.log(item.id,69)
  165. if(this.isBuy){
  166. let moduleId = item.moduleId?item.moduleId:0
  167. if(this.isRebuild){
  168. this.getReSectionList(item.id,item.courseId,moduleId)
  169. }else{
  170. this.getBuySectionList(item.id,item.courseId,moduleId)
  171. // this.getMenuExamList(item.id,item.courseId,moduleId)
  172. }
  173. }else{
  174. this.getSectionList(item.id)
  175. }
  176. }
  177. },
  178. getMenuExamList(chapterId,courseId,moduleId) {
  179. let self = this
  180. this.$api.menuExamList({chapterId:chapterId,courseId:courseId,moduleId:moduleId}).then(res => {
  181. if(res.data.code==200){
  182. self.examList = res.data.rows
  183. }
  184. });
  185. },
  186. getSectionList(chapterId) {
  187. let self = this
  188. this.$api.sectionList(chapterId).then(res => {
  189. if(res.data.code==200){
  190. for(let i=0;i<res.data.data.length;i++){
  191. let item = res.data.data[i]
  192. item.id = item.sectionId
  193. //判断是否试听
  194. item.tryListen = false
  195. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  196. item.tryListen = true
  197. }
  198. }
  199. let newArr = res.data.data.filter(item => {
  200. console.log(item)
  201. return item.type != 2;
  202. })
  203. this.canLearn = newArr.every(item => {
  204. console.log(item)
  205. if(item.learning == 1) {
  206. return true;
  207. } else {
  208. return false;
  209. }
  210. })
  211. self.list = res.data.data
  212. }
  213. });
  214. },
  215. getReSectionList(chapterId,courseId,moduleId) {
  216. let self = this
  217. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,rebuild:1,moduleId:moduleId}).then(res => {
  218. if(res.data.code==200){
  219. for(let i=0;i<res.data.data.length;i++){
  220. let item = res.data.data[i]
  221. item.id = item.sectionId
  222. //判断是否试听
  223. item.tryListen = false
  224. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  225. item.tryListen = true
  226. }
  227. }
  228. let newArr = res.data.data.filter(item => {
  229. console.log(item)
  230. return item.type != 2;
  231. })
  232. this.canLearn = newArr.every(item => {
  233. console.log(item)
  234. if(item.learning == 1) {
  235. return true;
  236. } else {
  237. return false;
  238. }
  239. })
  240. self.list = res.data.data
  241. }
  242. });
  243. },
  244. getBuySectionList(chapterId,courseId,moduleId) {
  245. let self = this
  246. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,moduleId:moduleId}).then(res => {
  247. if(res.data.code==200){
  248. for(let i=0;i<res.data.data.length;i++){
  249. let item = res.data.data[i]
  250. item.id = item.sectionId
  251. //判断是否试听
  252. item.tryListen = false
  253. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  254. item.tryListen = true
  255. }
  256. }
  257. let newArr = res.data.data.filter(item => {
  258. console.log(item)
  259. return item.type != 2;
  260. })
  261. this.canLearn = newArr.every(item => {
  262. console.log(item)
  263. if(item.learning == 1) {
  264. return true;
  265. } else {
  266. return false;
  267. }
  268. })
  269. self.list = res.data.data
  270. }
  271. });
  272. },
  273. },computed: { ...mapGetters(['goodsAuditionConfigIdList']) },
  274. };
  275. </script>
  276. <style scoped>
  277. .tagRe{
  278. width: 80rpx;
  279. height: 28rpx;
  280. background: #FF3B30;
  281. border-radius: 8rpx;
  282. font-size: 20rpx;
  283. color: #FFFFFF;
  284. text-align: center;
  285. }
  286. .tagGreen{
  287. width: 80rpx;
  288. height: 28rpx;
  289. background: #34C759;
  290. border-radius: 8rpx;
  291. font-size: 20rpx;
  292. color: #FFFFFF;
  293. text-align: center;
  294. }
  295. .eTag{
  296. width: 56rpx;
  297. height: 28rpx;
  298. background: #007AFF;
  299. border-radius: 8rpx;
  300. color: #FFFFFF;
  301. font-size: 20rpx;
  302. text-align: center;
  303. line-height: 28rpx;
  304. }
  305. .examBox{
  306. display: flex;
  307. align-items: center;
  308. justify-content: space-between;
  309. }
  310. .exam{
  311. display: flex;
  312. align-items: center;
  313. margin: 20rpx 0;
  314. }
  315. .icon_up{
  316. width: 24rpx;
  317. height: 24rpx;
  318. }
  319. .title{
  320. font-size: 24rpx;
  321. font-family: PingFang SC;
  322. font-weight: bold;
  323. color: #666666;
  324. white-space:nowrap;
  325. overflow:hidden;
  326. text-overflow:ellipsis;
  327. }
  328. </style>