courseModule.vue 6.1 KB

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