courseChapter.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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: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) {
  96. if(this.learningOrder == 1) {
  97. if(this.canLearn) {
  98. uni.navigateTo({
  99. url:'/pages2/class/questionBank?courseId='+this.courseId+'&gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
  100. })
  101. } else {
  102. uni.showToast({
  103. icon:'none',
  104. title:'请学完视频课程再进行练习和测试'
  105. })
  106. }
  107. } else {
  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. }
  112. },
  113. openChapter(item){
  114. this.down = !this.down
  115. if(!this.down&&this.list.length==0){
  116. console.log(item.id,69)
  117. if(this.isBuy){
  118. let moduleId = item.moduleId?item.moduleId:0
  119. if(this.isRebuild){
  120. this.getReSectionList(item.id,item.courseId,moduleId)
  121. }else{
  122. this.getBuySectionList(item.id,item.courseId,moduleId)
  123. // this.getMenuExamList(item.id,item.courseId,moduleId)
  124. }
  125. }else{
  126. this.getSectionList(item.id)
  127. }
  128. }
  129. },
  130. getMenuExamList(chapterId,courseId,moduleId) {
  131. let self = this
  132. this.$api.menuExamList({chapterId:chapterId,courseId:courseId,moduleId:moduleId}).then(res => {
  133. if(res.data.code==200){
  134. self.examList = res.data.rows
  135. }
  136. });
  137. },
  138. getSectionList(chapterId) {
  139. let self = this
  140. this.$api.sectionList(chapterId).then(res => {
  141. if(res.data.code==200){
  142. for(let i=0;i<res.data.data.length;i++){
  143. let item = res.data.data[i]
  144. item.id = item.sectionId
  145. //判断是否试听
  146. item.tryListen = false
  147. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  148. item.tryListen = true
  149. }
  150. }
  151. let newArr = res.data.data.filter(item => {
  152. console.log(item)
  153. return item.type != 2;
  154. })
  155. this.canLearn = newArr.every(item => {
  156. console.log(item)
  157. if(item.learning == 1) {
  158. return true;
  159. } else {
  160. return false;
  161. }
  162. })
  163. self.list = res.data.data
  164. }
  165. });
  166. },
  167. getReSectionList(chapterId,courseId,moduleId) {
  168. let self = this
  169. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,rebuild:1,moduleId:moduleId}).then(res => {
  170. if(res.data.code==200){
  171. for(let i=0;i<res.data.data.length;i++){
  172. let item = res.data.data[i]
  173. item.id = item.sectionId
  174. //判断是否试听
  175. item.tryListen = false
  176. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  177. item.tryListen = true
  178. }
  179. }
  180. let newArr = res.data.data.filter(item => {
  181. console.log(item)
  182. return item.type != 2;
  183. })
  184. this.canLearn = newArr.every(item => {
  185. console.log(item)
  186. if(item.learning == 1) {
  187. return true;
  188. } else {
  189. return false;
  190. }
  191. })
  192. self.list = res.data.data
  193. }
  194. });
  195. },
  196. getBuySectionList(chapterId,courseId,moduleId) {
  197. let self = this
  198. this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,moduleId:moduleId}).then(res => {
  199. if(res.data.code==200){
  200. for(let i=0;i<res.data.data.length;i++){
  201. let item = res.data.data[i]
  202. item.id = item.sectionId
  203. //判断是否试听
  204. item.tryListen = false
  205. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  206. item.tryListen = true
  207. }
  208. }
  209. let newArr = res.data.data.filter(item => {
  210. console.log(item)
  211. return item.type != 2;
  212. })
  213. this.canLearn = newArr.every(item => {
  214. console.log(item)
  215. if(item.learning == 1) {
  216. return true;
  217. } else {
  218. return false;
  219. }
  220. })
  221. self.list = res.data.data
  222. }
  223. });
  224. },
  225. },computed: { ...mapGetters(['goodsAuditionConfigIdList']) },
  226. };
  227. </script>
  228. <style scoped>
  229. .tagRe{
  230. width: 80rpx;
  231. height: 28rpx;
  232. background: #FF3B30;
  233. border-radius: 8rpx;
  234. font-size: 20rpx;
  235. color: #FFFFFF;
  236. text-align: center;
  237. }
  238. .tagGreen{
  239. width: 80rpx;
  240. height: 28rpx;
  241. background: #34C759;
  242. border-radius: 8rpx;
  243. font-size: 20rpx;
  244. color: #FFFFFF;
  245. text-align: center;
  246. }
  247. .eTag{
  248. width: 56rpx;
  249. height: 28rpx;
  250. background: #007AFF;
  251. border-radius: 8rpx;
  252. color: #FFFFFF;
  253. font-size: 20rpx;
  254. text-align: center;
  255. line-height: 28rpx;
  256. }
  257. .examBox{
  258. display: flex;
  259. align-items: center;
  260. justify-content: space-between;
  261. }
  262. .exam{
  263. display: flex;
  264. align-items: center;
  265. margin: 20rpx 0;
  266. }
  267. .icon_up{
  268. width: 24rpx;
  269. height: 24rpx;
  270. }
  271. .title{
  272. font-size: 24rpx;
  273. font-family: PingFang SC;
  274. font-weight: bold;
  275. color: #666666;
  276. white-space:nowrap;
  277. overflow:hidden;
  278. text-overflow:ellipsis;
  279. }
  280. </style>