courseChapter.vue 9.5 KB

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