Tree.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <script setup name="Tree">
  2. import Tree from "./Tree.vue";
  3. const props = defineProps({
  4. chaptersList: {
  5. type: Array,
  6. default: () => [],
  7. },
  8. keys: {
  9. type: Object,
  10. default: () => ({
  11. value: "id",
  12. label: "name",
  13. children: "children",
  14. process: "isStudied",
  15. }),
  16. },
  17. leave: {
  18. type: Number,
  19. default: 1,
  20. },
  21. });
  22. const emit = defineEmits(["onChnage", "onClickButton"]);
  23. </script>
  24. <template>
  25. <template v-for="items in chaptersList" :key="items[keys.value]">
  26. <uni-collapse
  27. class="class-content"
  28. @change="emit('onChnage')"
  29. v-if="items?.[keys.children]?.length"
  30. >
  31. <uni-collapse-item
  32. :title="items[keys.label]"
  33. :key="items[keys.value]"
  34. class="text"
  35. :leave="leave"
  36. >
  37. <view class="-mt-20">
  38. <Tree
  39. :chaptersList="items[keys.children]"
  40. :leave="leave + 1"
  41. @onClickButton="emit('onClickButton', items)"
  42. @change="emit('onChnage')"
  43. />
  44. </view>
  45. </uni-collapse-item>
  46. </uni-collapse>
  47. <view v-else>
  48. <view
  49. class="content"
  50. :style="{
  51. paddingLeft: `${leave * 5 * 2 + 10}rpx`,
  52. }"
  53. >
  54. <view class="text"> {{ items[keys.label] }}</view>
  55. <view class="buttons">
  56. <view
  57. @click="emit('onClickButton', items)"
  58. class="comment"
  59. v-if="items[keys.process] === 0"
  60. >开始学习</view
  61. >
  62. <view
  63. @click="emit('onClickButton', items)"
  64. class="comment warning"
  65. v-if="items[keys.process] > 0 && items[keys.process] < 100"
  66. >继续学习</view
  67. >
  68. <view
  69. @click="emit('onClickButton', i)"
  70. class="comment"
  71. v-if="items[keys.process] === 100"
  72. >去练习</view
  73. >
  74. <view
  75. @click="emit('onClickButton', items)"
  76. class="comment success"
  77. v-if="items[keys.process] === 100"
  78. >已学习</view
  79. >
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. </template>
  85. <style lang="scss" scoped>
  86. @import "@/uni.scss";
  87. .text {
  88. font-family: PingFang SC, PingFang SC;
  89. font-weight: 500;
  90. font-size: 28rpx;
  91. color: #000000;
  92. }
  93. .content {
  94. display: flex;
  95. justify-content: space-between;
  96. align-items: center;
  97. padding: 0 20rpx 10rpx 0;
  98. .buttons {
  99. display: flex;
  100. gap: 10rpx;
  101. }
  102. .comment {
  103. width: 132rpx;
  104. height: 48rpx;
  105. display: flex;
  106. align-items: center;
  107. justify-content: center;
  108. background-color: #fff;
  109. color: $primary;
  110. border: 1px solid $primary;
  111. font-family: "PingFang SC, PingFang SC";
  112. font-weight: 500;
  113. font-size: 28rpx;
  114. color: $primary;
  115. border-radius: 4rpx;
  116. }
  117. .comment.success {
  118. color: $success;
  119. border: 1px solid $success;
  120. }
  121. .comment.warning {
  122. color: $warning;
  123. border: 1px solid $warning;
  124. }
  125. }
  126. .unlock {
  127. font-family: PingFang SC, PingFang SC;
  128. font-weight: 500;
  129. font-size: 28rpx;
  130. color: #000000;
  131. margin: 100rpx 0;
  132. display: block;
  133. }
  134. .class-content {
  135. height: 100%;
  136. }
  137. .pay-content {
  138. flex: 1;
  139. position: relative;
  140. .modal-mask {
  141. background-color: rgba($color: #858585, $alpha: 0.8);
  142. position: absolute;
  143. height: 100%;
  144. z-index: 9999;
  145. left: -24rpx;
  146. display: flex;
  147. align-items: center;
  148. flex-direction: column;
  149. justify-content: center;
  150. gap: 34rpx;
  151. }
  152. }
  153. .modal-wrapper {
  154. width: 685rpx;
  155. height: 64rpx;
  156. background: #dfdfdf;
  157. font-family: PingFang SC, PingFang SC;
  158. font-weight: 500;
  159. font-size: 28rpx;
  160. color: #000000;
  161. display: flex;
  162. align-items: center;
  163. justify-content: center;
  164. }
  165. </style>