courseChapter.vue 9.1 KB

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