courseTree.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="menuBox">
  3. <template>
  4. <view v-for="(item, index) in menuList" :key="index">
  5. <!--模块 -->
  6. <view v-if="item.type == 1">
  7. <courseModule
  8. :orderGoodsId="orderGoodsId"
  9. :sectionMaxNum="sectionMaxNum"
  10. :needOpen="sectionItem.moduleId == item.menuId"
  11. :courseId="courseId"
  12. :preItem="menuList[index - 1]"
  13. :learningOrder="learningOrder"
  14. :goodsId="goodsId"
  15. :gradeId="gradeId"
  16. :isBuy="true"
  17. :menuItem="item"
  18. :levelId="item.menuId"
  19. :goodsType="1"
  20. :menuAllList="menuAllList"
  21. :sectionItem="sectionItem"
  22. ></courseModule
  23. ></view>
  24. <!--章 -->
  25. <view v-if="item.type == 2">
  26. <courseChapter
  27. :orderGoodsId="orderGoodsId"
  28. :sectionMaxNum="sectionMaxNum"
  29. :needOpen="
  30. !sectionItem.moduleId && sectionItem.chapterId == item.menuId
  31. "
  32. :courseId="courseId"
  33. :preItem="menuList[index - 1]"
  34. @playEnd="sectionPlayEnd($event, index)"
  35. :learningOrder="learningOrder"
  36. :goodsId="goodsId"
  37. :gradeId="gradeId"
  38. :isBuy="true"
  39. :menuItem="item"
  40. :levelId="'0-' + item.menuId"
  41. :goodsType="1"
  42. :menuAllList="menuAllList"
  43. :sectionItem="sectionItem"
  44. ></courseChapter
  45. ></view>
  46. <!--节 -->
  47. <view v-if="item.type == 3">
  48. <courseSection
  49. ref="MoudleSection"
  50. :orderGoodsId="orderGoodsId"
  51. :sectionMaxNum="sectionMaxNum"
  52. @playEnd="sectionPlayEnd($event, index)"
  53. :courseId="courseId"
  54. :preItem="menuList[index - 1]"
  55. :learningOrder="learningOrder"
  56. :goodsId="goodsId"
  57. :gradeId="gradeId"
  58. :isBuy="true"
  59. :menuItem="item"
  60. :levelId="'0-0-' + item.menuId"
  61. :goodsType="1"
  62. :testType="3"
  63. :menuAllList="menuAllList"
  64. ></courseSection
  65. ></view>
  66. </view>
  67. </template>
  68. </view>
  69. </template>
  70. <script>
  71. import courseModule from "@/components/course/courseModule.vue";
  72. import courseChapter from "@/components/course/courseChapter.vue";
  73. import courseSection from "@/components/course/courseSection.vue";
  74. export default {
  75. name: "SaasMiniprogramCourseTree",
  76. props: {
  77. isLive: false,
  78. orderGoodsId: {
  79. default: 0,
  80. },
  81. preItem: {
  82. default: undefined,
  83. },
  84. learningOrder: {
  85. //是否设置学习顺序 1 章节顺序 0不设置 2从头学到尾顺序
  86. type: Number,
  87. defaule: 0,
  88. },
  89. needOpen: {
  90. //是否默认展开
  91. type: Boolean,
  92. default: false,
  93. },
  94. goodsId: {
  95. type: Number,
  96. default: 0,
  97. },
  98. courseId: {
  99. type: [Number, String],
  100. default: 0,
  101. },
  102. isBuy: {
  103. //是否是已购买商品
  104. type: Boolean,
  105. default: false,
  106. },
  107. levelId: {
  108. type: [Number, String],
  109. default: "",
  110. },
  111. isRebuild: {
  112. //是否重修目录
  113. type: Boolean,
  114. default: false,
  115. },
  116. gradeId: {
  117. //重修需要班级ID
  118. type: [Number, String],
  119. },
  120. sectionMaxNum: {
  121. default: undefined,
  122. },
  123. // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
  124. goodsType: {
  125. type: [Number, String],
  126. default: 0,
  127. },
  128. menuAllList: {
  129. // 课程所有子目录结构列表
  130. type: Array,
  131. default: () => [],
  132. },
  133. sectionItem: {
  134. // 用户最后一次看的录播的信息
  135. type: Object,
  136. default: () => {},
  137. },
  138. },
  139. data() {
  140. return {
  141. menuList: [],
  142. };
  143. },
  144. mounted() {},
  145. methods: {
  146. getMenuList() {
  147. this.$api
  148. .reMenuList({
  149. courseId: this.courseId,
  150. gradeId: this.gradeId,
  151. orderGoodsId: this.orderGoodsId,
  152. })
  153. .then((res) => {
  154. if (res.data.code == 200) {
  155. for (let i = 0; i < res.data.rows.length; i++) {
  156. let item = res.data.rows[i];
  157. item.down = true;
  158. item.id = item.menuId;
  159. item.name = item.menuName;
  160. item.menuType = item.type;
  161. }
  162. this.menuList = res.data.rows;
  163. }
  164. });
  165. },
  166. },
  167. watch: {
  168. courseId: {
  169. handler(val) {
  170. this.menuList = [];
  171. this.getMenuList();
  172. },
  173. immediate: true,
  174. },
  175. },
  176. components: {
  177. courseModule,
  178. courseChapter,
  179. courseSection,
  180. },
  181. };
  182. </script>
  183. <style lang="scss" scoped>
  184. .menuBox {
  185. width: 100%;
  186. background: #ffffff;
  187. border-radius: 16rpx;
  188. padding: 0rpx 20rpx;
  189. margin-bottom: 20rpx;
  190. }
  191. </style>