courseModule.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <!-- style="margin: 20rpx 0;" -->
  3. <view>
  4. <view class="title" @click="openModule(menuItem)">
  5. <!-- <image src="/static/icon/up1.png" class="icon_up" v-if="down"></image>
  6. <image src="/static/icon/down1.png" class="icon_up" v-if="!down"></image> -->
  7. <text class="title_name" style="margin-left: 10rpx;">{{menuItem.name}}</text>
  8. <view>
  9. <image src="/static/icon/up.png" class="icon_up" v-if="down"></image>
  10. <image src="/static/icon/down.png" class="icon_up" v-if="!down"></image>
  11. </view>
  12. </view>
  13. <view v-show="!down">
  14. <view v-for="(itemM,indexM) in list" :key="indexM">
  15. <!-- v-if='itemM.type != 2' -->
  16. <courseChapter v-if='itemM.type != 2' :orderGoodsId="orderGoodsId"
  17. :isLive="isLive" :preItem="list[indexM - 1] || preItem" :sectionMaxNum="sectionMaxNum" :needOpen="needOpen" @playEnd="playEnd($event)"
  18. @toDo="toDo($event)" :courseId="courseId" :learningOrder="learningOrder" :goodsId="goodsId" :isBuy="isBuy" :gradeId="gradeId"
  19. :isRebuild="isRebuild" :menuItem="itemM" :levelId="levelId+'-'+itemM.chapterId">
  20. </courseChapter>
  21. <u-line v-if="indexM<list.length-1"></u-line>
  22. <view v-if="itemM.type == 2">
  23. <view
  24. class="examBox"
  25. @click="
  26. toDoModuleExam(
  27. itemM.typeId,
  28. goodsId,
  29. itemM.moduleId,
  30. itemM.chapterId,
  31. itemM,
  32. indexM
  33. )
  34. "
  35. >
  36. <view class="exam">
  37. <view class="eTag">{{
  38. itemM.doType == 1 ? "练习" : "考试"
  39. }}</view>
  40. <view style="margin-left: 15rpx; flex: 1">{{ itemM.name }}</view>
  41. </view>
  42. <view>
  43. <view
  44. :class="{
  45. tagGreen: itemM.learning == 1,
  46. tagRe: itemM.learning == 0 || itemM.rebuild > 0,
  47. }"
  48. >
  49. <text v-if="itemM.learning == 1">合格</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. onLoad() {},
  127. created() {
  128. },
  129. mounted() {
  130. if(this.needOpen && this.chapterOpen) {
  131. this.openModule(this.menuItem)
  132. }
  133. },
  134. methods: {
  135. playEnd(isRebuild) {
  136. this.$emit('playEnd',{isRebuild:isRebuild.isRebuild})
  137. },
  138. toDo(item) {
  139. this.$emit('toDo',item)
  140. },
  141. openModule(item){
  142. this.down = !this.down
  143. if(!this.down&&this.list.length==0){
  144. if(this.isBuy){
  145. if(this.isRebuild){
  146. this.getReChapterList(item.id,item.courseId)
  147. }else{
  148. this.getBuyChapterList(item.id,item.courseId) //已购买目录
  149. }
  150. }else{
  151. this.getChapterList(item.id) //未购买目录
  152. }
  153. }
  154. },
  155. getChapterList(moduleId) {
  156. let self = this
  157. // url: '/app/common/course/chapterList/'+data,
  158. this.$api.chapterList(moduleId).then(res => {
  159. if(res.data.code==200){
  160. for(let i=0;i<res.data.data.length;i++){
  161. let item = res.data.data[i]
  162. item.id = item.chapterId
  163. item.menuType = 2;
  164. }
  165. self.list = res.data.data
  166. }
  167. });
  168. },
  169. getReChapterList(moduleId,courseId) {
  170. let self = this
  171. this.$api.reChapterList({moduleId:moduleId,gradeId:this.gradeId,courseId:courseId,rebuild:1}).then(res => {
  172. if(res.data.code==200){
  173. for(let i=0;i<res.data.data.length;i++){
  174. let item = res.data.data[i]
  175. item.id = item.chapterId
  176. }
  177. self.list = res.data.data
  178. }
  179. });
  180. },
  181. getBuyChapterList(moduleId,courseId) {
  182. let self = this
  183. this.$api.reChapterList({moduleId:moduleId,gradeId:this.gradeId,courseId:courseId}).then(res => {
  184. if(res.data.code==200){
  185. for(let i=0;i<res.data.data.length;i++){
  186. let item = res.data.data[i]
  187. item.id = item.chapterId
  188. item.menuType = 2;
  189. }
  190. self.list = res.data.data
  191. }
  192. });
  193. },
  194. /**
  195. * 去做题
  196. */
  197. async toDoModuleExam(id, goodsId = 0, moduleId = 0, chapterId = 0, item, index) {
  198. uni.navigateTo({
  199. url:
  200. "/pages2/class/questionBank?courseId=" +
  201. this.courseId +
  202. "&gradeId=" +
  203. this.gradeId +
  204. "&isFromVideo=1&id=" +
  205. id +
  206. "&goodsid=" +
  207. goodsId +
  208. "&moduleId=" +
  209. moduleId +
  210. "&chapterId=" +
  211. chapterId +
  212. "&orderGoodsId=" +
  213. this.orderGoodsId +
  214. "&types=3",
  215. })
  216. },
  217. },
  218. computed: { ...mapGetters(['chapterOpen']) },
  219. };
  220. </script>
  221. <style lang="scss" scoped>
  222. .title{
  223. height: 70rpx;
  224. font-family: PingFang SC;
  225. // margin-bottom:30rpx;
  226. display: flex;
  227. justify-content: space-between;
  228. align-items: center;
  229. border-bottom: 1rpx solid #EEEEEE;
  230. .title_name {
  231. font-size: 24rpx;
  232. font-weight: 500;
  233. color: #333333;
  234. white-space:nowrap;
  235. overflow:hidden;
  236. text-overflow:ellipsis;
  237. }
  238. .icon_up{
  239. width: 24rpx;
  240. height: 24rpx;
  241. }
  242. }
  243. .examBox {
  244. display: flex;
  245. align-items: center;
  246. justify-content: space-between;
  247. .exam {
  248. font-size: 30rpx;
  249. display: flex;
  250. align-items: center;
  251. margin: 20rpx 0;
  252. }
  253. .eTag {
  254. width: 56rpx;
  255. height: 42rpx;
  256. text-align: center;
  257. line-height: 42rpx;
  258. font-size: 20rpx;
  259. background: #007aff;
  260. border-radius: 8rpx;
  261. color: #ffffff;
  262. }
  263. }
  264. .tagRe {
  265. width: 80rpx;
  266. height: 28rpx;
  267. background: #ff3b30;
  268. border-radius: 8rpx;
  269. font-size: 20rpx;
  270. color: #ffffff;
  271. text-align: center;
  272. }
  273. .tagGreen {
  274. width: 80rpx;
  275. height: 28rpx;
  276. background: #34c759;
  277. border-radius: 8rpx;
  278. font-size: 20rpx;
  279. color: #ffffff;
  280. text-align: center;
  281. }
  282. </style>