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