courseModule.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <!-- style="margin: 20rpx 0;" -->
  3. <view>
  4. <view class="title" @click="openModule(menuItem)">
  5. <text class="title_name" style="margin-left: 10rpx;">{{menuItem.name}}</text>
  6. <view>
  7. <image src="/static/icon/up.png" class="icon_up" v-if="down"></image>
  8. <image src="/static/icon/down.png" class="icon_up" v-if="!down"></image>
  9. </view>
  10. </view>
  11. <view v-show="!down">
  12. <view v-for="(itemM,indexM) in list" :key="indexM">
  13. <!-- v-if='itemM.type != 2' -->
  14. <courseChapter v-if='itemM.type != 2' :orderGoodsId="orderGoodsId"
  15. :isLive="isLive" :preItem="list[indexM - 1] || preItem" :sectionMaxNum="sectionMaxNum" :needOpen="needOpen" @playEnd="playEnd($event)"
  16. @toDo="toDo($event)" :courseId="courseId" :learningOrder="learningOrder" :goodsId="goodsId" :isBuy="isBuy" :gradeId="gradeId"
  17. :isRebuild="isRebuild" :menuItem="itemM" :levelId="levelId+'-'+itemM.chapterId">
  18. </courseChapter>
  19. <u-line v-if="indexM<list.length-1"></u-line>
  20. <view v-if="itemM.type == 2">
  21. <view
  22. class="examBox"
  23. @click="
  24. toDoModuleExam(
  25. itemM.typeId,
  26. goodsId,
  27. itemM.moduleId,
  28. itemM.chapterId,
  29. itemM,
  30. indexM
  31. )
  32. "
  33. >
  34. <view class="exam">
  35. <view class="eTag">{{
  36. itemM.doType == 1 ? "练习" : "考试"
  37. }}</view>
  38. <view style="margin-left: 15rpx; flex: 1">{{ itemM.name }}</view>
  39. </view>
  40. <view>
  41. <view
  42. :class="{
  43. tagGreen: itemM.learning == 1,
  44. tagRe: itemM.learning == 0 || itemM.rebuild > 0,
  45. }"
  46. >
  47. <text v-if="itemM.learning == 1">合格</text>
  48. <text v-else-if="itemM.learning == 0">不合格</text>
  49. <!-- <text v-else>不合格</text> -->
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import { mapGetters } from "vuex";
  60. import courseChapter from "@/components/course/courseChapter.vue";
  61. export default {
  62. name: 'courseModule',
  63. props: {
  64. isLive:false,
  65. orderGoodsId:{
  66. default:0
  67. },
  68. preItem:{
  69. default:undefined
  70. },
  71. learningOrder:{ //是否设置学习顺序 1 章节顺序 0不设置 2从头学到尾顺序
  72. type:Number,
  73. defaule:0
  74. },
  75. needOpen:{ //是否默认展开
  76. type:Boolean,
  77. default:false,
  78. },
  79. menuItem: {
  80. type: Object,
  81. default: {}
  82. },
  83. goodsId: {
  84. type: Number,
  85. default: 0
  86. },
  87. courseId: {
  88. type: Number,
  89. default: 0
  90. },
  91. isBuy: { //是否是已购买商品
  92. type: Boolean,
  93. default: false
  94. },
  95. levelId: {
  96. type: String,
  97. default: ""
  98. },
  99. isRebuild: { //是否重修目录
  100. type: Boolean,
  101. default: false
  102. },
  103. gradeId: { //重修需要班级ID
  104. type: Number,
  105. default: 0
  106. },
  107. sectionMaxNum:{
  108. default:undefined
  109. },
  110. // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
  111. goodsType: {
  112. type: [Number, String],
  113. default: 0,
  114. },
  115. },
  116. components: {
  117. courseChapter
  118. },
  119. data() {
  120. return {
  121. down:true,
  122. list:[],
  123. };
  124. },
  125. mounted() {
  126. if(this.needOpen && this.chapterOpen) {
  127. this.openModule(this.menuItem)
  128. }
  129. },
  130. methods: {
  131. playEnd(isRebuild) {
  132. this.$emit('playEnd',{isRebuild:isRebuild.isRebuild})
  133. },
  134. toDo(item) {
  135. this.$emit('toDo',item)
  136. },
  137. openModule(item){
  138. this.down = !this.down
  139. if(!this.down&&this.list.length==0){
  140. if(this.isBuy){
  141. if(this.isRebuild){
  142. this.getReChapterList(item.id,item.courseId)
  143. }else{
  144. this.getBuyChapterList(item.id,item.courseId) //已购买目录
  145. }
  146. }else{
  147. this.getChapterList(item.id) //未购买目录
  148. }
  149. }
  150. },
  151. getChapterList(moduleId) {
  152. let self = this
  153. // url: '/app/common/course/chapterList/'+data,
  154. this.$api.chapterList(moduleId).then(res => {
  155. if(res.data.code==200){
  156. for(let i=0;i<res.data.data.length;i++){
  157. let item = res.data.data[i]
  158. item.id = item.chapterId
  159. item.menuType = 2;
  160. }
  161. self.list = res.data.data
  162. }
  163. });
  164. },
  165. getReChapterList(moduleId,courseId) {
  166. let self = this
  167. this.$api.reChapterList({moduleId:moduleId,gradeId:this.gradeId,courseId:courseId,rebuild:1}).then(res => {
  168. if(res.data.code==200){
  169. for(let i=0;i<res.data.data.length;i++){
  170. let item = res.data.data[i]
  171. item.id = item.chapterId
  172. }
  173. self.list = res.data.data
  174. }
  175. });
  176. },
  177. getBuyChapterList(moduleId,courseId) {
  178. let self = this
  179. this.$api.reChapterList({moduleId:moduleId,gradeId:this.gradeId,courseId:courseId}).then(res => {
  180. if(res.data.code==200){
  181. for(let i=0;i<res.data.data.length;i++){
  182. let item = res.data.data[i]
  183. item.id = item.chapterId
  184. item.menuType = 2;
  185. }
  186. self.list = res.data.data
  187. }
  188. });
  189. console.log('-----------list', this.list)
  190. },
  191. /**
  192. * 去做题
  193. */
  194. async toDoModuleExam(id, goodsId = 0, moduleId = 0, chapterId = 0, item, index) {
  195. uni.navigateTo({
  196. url:
  197. "/pages2/class/questionBank?courseId=" +
  198. this.courseId +
  199. "&gradeId=" +
  200. this.gradeId +
  201. "&isFromVideo=1&id=" +
  202. id +
  203. "&goodsid=" +
  204. goodsId +
  205. "&moduleId=" +
  206. moduleId +
  207. "&chapterId=" +
  208. chapterId +
  209. "&orderGoodsId=" +
  210. this.orderGoodsId +
  211. "&type=3",
  212. })
  213. },
  214. },
  215. computed: { ...mapGetters(['chapterOpen']) },
  216. };
  217. </script>
  218. <style lang="scss" scoped>
  219. .title{
  220. height: 70rpx;
  221. display: flex;
  222. justify-content: space-between;
  223. align-items: center;
  224. border-bottom: 1rpx solid #EEEEEE;
  225. .title_name {
  226. font-size: 24rpx;
  227. font-weight: 500;
  228. color: #333333;
  229. white-space:nowrap;
  230. overflow:hidden;
  231. text-overflow:ellipsis;
  232. }
  233. .icon_up{
  234. width: 24rpx;
  235. height: 24rpx;
  236. }
  237. }
  238. .examBox {
  239. display: flex;
  240. align-items: center;
  241. justify-content: space-between;
  242. .exam {
  243. font-size: 30rpx;
  244. display: flex;
  245. align-items: center;
  246. margin: 20rpx 0;
  247. }
  248. .eTag {
  249. width: 64rpx;
  250. height: 36rpx;
  251. text-align: center;
  252. line-height: 36rpx;
  253. font-size: 20rpx;
  254. background: #007aff;
  255. border-radius: 8rpx;
  256. color: #ffffff;
  257. }
  258. }
  259. .tagRe {
  260. width: 80rpx;
  261. height: 28rpx;
  262. background: #ff3b30;
  263. border-radius: 8rpx;
  264. font-size: 20rpx;
  265. color: #ffffff;
  266. text-align: center;
  267. }
  268. .tagGreen {
  269. width: 80rpx;
  270. height: 28rpx;
  271. background: #34c759;
  272. border-radius: 8rpx;
  273. font-size: 20rpx;
  274. color: #ffffff;
  275. text-align: center;
  276. }
  277. </style>