courseTree.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. :isRebuild="isRebuild"
  23. ></courseModule
  24. ></view>
  25. <!--章 -->
  26. <view v-if="item.type == 2">
  27. <courseChapter
  28. :orderGoodsId="orderGoodsId"
  29. :sectionMaxNum="sectionMaxNum"
  30. :needOpen="
  31. !sectionItem.moduleId && sectionItem.chapterId == item.menuId
  32. "
  33. :courseId="courseId"
  34. :preItem="menuList[index - 1]"
  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. :isRebuild="isRebuild"
  45. ></courseChapter
  46. ></view>
  47. <!--节 -->
  48. <view v-if="item.type == 3">
  49. <courseSection
  50. ref="MoudleSection"
  51. :orderGoodsId="orderGoodsId"
  52. :sectionMaxNum="sectionMaxNum"
  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. :isRebuild="isRebuild"
  65. :sectionItem="sectionItem"
  66. ></courseSection
  67. ></view>
  68. </view>
  69. </template>
  70. </view>
  71. </template>
  72. <script>
  73. import courseModule from "@/components/course/courseModule.vue";
  74. import courseChapter from "@/components/course/courseChapter.vue";
  75. import courseSection from "@/components/course/courseSection.vue";
  76. export default {
  77. name: "SaasMiniprogramCourseTree",
  78. props: {
  79. isLive: false,
  80. orderGoodsId: {
  81. default: 0,
  82. },
  83. preItem: {
  84. default: undefined,
  85. },
  86. learningOrder: {
  87. //是否设置学习顺序 1 章节顺序 0不设置 2从头学到尾顺序
  88. type: Number,
  89. defaule: 0,
  90. },
  91. needOpen: {
  92. //是否默认展开
  93. type: Boolean,
  94. default: false,
  95. },
  96. goodsId: {
  97. type: Number,
  98. default: 0,
  99. },
  100. courseId: {
  101. type: [Number, String],
  102. default: 0,
  103. },
  104. isBuy: {
  105. //是否是已购买商品
  106. type: Boolean,
  107. default: false,
  108. },
  109. levelId: {
  110. type: [Number, String],
  111. default: "",
  112. },
  113. isRebuild: {
  114. //是否重修目录
  115. type: Boolean,
  116. default: false,
  117. },
  118. gradeId: {
  119. //重修需要班级ID
  120. type: [Number, String],
  121. },
  122. sectionMaxNum: {
  123. default: undefined,
  124. },
  125. // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
  126. goodsType: {
  127. type: [Number, String],
  128. default: 0,
  129. },
  130. menuAllList: {
  131. // 课程所有子目录结构列表
  132. type: Array,
  133. default: () => [],
  134. },
  135. sectionItem: {
  136. // 用户最后一次看的录播的信息
  137. type: Object,
  138. default: () => {},
  139. },
  140. },
  141. data() {
  142. return {
  143. menuList: [],
  144. };
  145. },
  146. mounted() {},
  147. methods: {
  148. getMenuList() {
  149. this.$api
  150. .reMenuList({
  151. courseId: this.courseId,
  152. gradeId: this.gradeId,
  153. orderGoodsId: this.orderGoodsId,
  154. })
  155. .then((res) => {
  156. if (res.data.code == 200) {
  157. for (let i = 0; i < res.data.rows.length; i++) {
  158. let item = res.data.rows[i];
  159. item.down = true;
  160. item.id = item.menuId;
  161. item.name = item.menuName;
  162. item.menuType = item.type;
  163. }
  164. this.menuList = res.data.rows;
  165. }
  166. });
  167. },
  168. },
  169. watch: {
  170. courseId: {
  171. handler(val) {
  172. this.menuList = [];
  173. this.getMenuList();
  174. },
  175. immediate: true,
  176. },
  177. },
  178. components: {
  179. courseModule,
  180. courseChapter,
  181. courseSection,
  182. },
  183. };
  184. </script>
  185. <style lang="scss" scoped>
  186. .top {
  187. &__header {
  188. position: relative;
  189. width: 100%;
  190. height: 150rpx;
  191. padding: 24rpx 150rpx 24rpx 24rpx;
  192. .img {
  193. position: absolute;
  194. left: 0;
  195. top: 0;
  196. width: 100%;
  197. }
  198. .note {
  199. position: relative;
  200. z-index: 10;
  201. font-size: 24rpx;
  202. font-family: PingFang SC;
  203. font-weight: bold;
  204. color: #efdbff;
  205. }
  206. .title {
  207. position: relative;
  208. z-index: 10;
  209. font-size: 26rpx;
  210. font-family: PingFang SC;
  211. font-weight: bold;
  212. color: #ffffff;
  213. }
  214. }
  215. }
  216. .menuBox {
  217. width: 100%;
  218. background: #ffffff;
  219. border-radius: 16rpx;
  220. padding: 0rpx 20rpx;
  221. margin-bottom: 20rpx;
  222. }
  223. </style>