courseTree.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. :sectionMaxNum="sectionMaxNum"
  9. :needOpen="sectionItem.moduleId == item.menuId"
  10. :preItem="menuList[index - 1]"
  11. :isBuy="isBuy"
  12. :menuItem="item"
  13. :levelId="item.menuId"
  14. :goodsType="goodsType"
  15. :isRebuild="isRebuild"
  16. ></courseModule
  17. ></view>
  18. <!--章 -->
  19. <view v-if="item.type == 2">
  20. <courseChapter
  21. :sectionMaxNum="sectionMaxNum"
  22. :needOpen="
  23. !sectionItem.moduleId && sectionItem.chapterId == item.menuId
  24. "
  25. :preItem="menuList[index - 1]"
  26. :isBuy="isBuy"
  27. :menuItem="item"
  28. :levelId="'0-' + item.menuId"
  29. :goodsType="goodsType"
  30. :isRebuild="isRebuild"
  31. ></courseChapter
  32. ></view>
  33. <!--节 -->
  34. <view v-if="item.type == 3">
  35. <courseSection
  36. ref="MoudleSection"
  37. :sectionMaxNum="sectionMaxNum"
  38. :preItem="menuList[index - 1]"
  39. :isBuy="isBuy"
  40. :menuItem="item"
  41. :levelId="'0-0-' + item.menuId"
  42. :goodsType="goodsType"
  43. :testType="3"
  44. :isRebuild="isRebuild"
  45. ></courseSection
  46. ></view>
  47. </view>
  48. </template>
  49. </view>
  50. </template>
  51. <script>
  52. import courseModule from "@/components/course/courseModule.vue";
  53. import courseChapter from "@/components/course/courseChapter.vue";
  54. import courseSection from "@/components/course/courseSection.vue";
  55. export default {
  56. name: "SaasMiniprogramCourseTree",
  57. inject: ["paramsFn"],
  58. props: {
  59. isBuy: {
  60. //是否是已购买商品
  61. type: Boolean,
  62. default: true,
  63. },
  64. isRebuild: {
  65. //是否重修目录
  66. type: Boolean,
  67. default: false,
  68. },
  69. sectionMaxNum: {
  70. default: undefined,
  71. },
  72. // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
  73. goodsType: {
  74. type: [Number, String],
  75. default: 1,
  76. },
  77. },
  78. data() {
  79. return {
  80. menuList: [],
  81. };
  82. },
  83. mounted() {},
  84. methods: {
  85. getMenuList() {
  86. const fn = this.isBuy ? "reMenuList" : "menuList";
  87. this.$api[fn](
  88. this.isBuy
  89. ? {
  90. ...this.params,
  91. rebuild: +this.isRebuild,
  92. }
  93. : { courseId: this.courseId }
  94. ).then((res) => {
  95. if (res.data.code == 200) {
  96. for (let i = 0; i < res.data.rows.length; i++) {
  97. let item = res.data.rows[i];
  98. // 显示重修目录
  99. if (item.rebuild) {
  100. this.$emit("isHaverebuild");
  101. }
  102. item.down = true;
  103. item.id = item.menuId;
  104. item.name = item.menuName;
  105. item.menuType = item.type;
  106. }
  107. this.menuList = res.data.rows;
  108. }
  109. });
  110. },
  111. },
  112. computed: {
  113. params() {
  114. return this.paramsFn(["orderGoodsId", "gradeId", "courseId"]);
  115. },
  116. sectionItem() {
  117. return this.paramsFn(["sectionItem"]);
  118. },
  119. courseId() {
  120. return this.params.courseId;
  121. },
  122. },
  123. watch: {
  124. courseId: {
  125. handler(val) {
  126. this.menuList = [];
  127. this.getMenuList();
  128. },
  129. immediate: true,
  130. deep: true,
  131. },
  132. },
  133. components: {
  134. courseModule,
  135. courseChapter,
  136. courseSection,
  137. },
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. .top {
  142. &__header {
  143. position: relative;
  144. width: 100%;
  145. height: 150rpx;
  146. padding: 24rpx 150rpx 24rpx 24rpx;
  147. .img {
  148. position: absolute;
  149. left: 0;
  150. top: 0;
  151. width: 100%;
  152. }
  153. .note {
  154. position: relative;
  155. z-index: 10;
  156. font-size: 24rpx;
  157. font-family: PingFang SC;
  158. font-weight: bold;
  159. color: #efdbff;
  160. }
  161. .title {
  162. position: relative;
  163. z-index: 10;
  164. font-size: 26rpx;
  165. font-family: PingFang SC;
  166. font-weight: bold;
  167. color: #ffffff;
  168. }
  169. }
  170. }
  171. .menuBox {
  172. width: 100%;
  173. background: #ffffff;
  174. border-radius: 16rpx;
  175. padding: 0rpx 20rpx;
  176. margin-bottom: 20rpx;
  177. }
  178. </style>