page-learn-child.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <div class="contentBody" v-if="learnChildList.length > 0">
  3. <van-tabs
  4. :active="active"
  5. type="line"
  6. line-width="30px"
  7. line-height="1px"
  8. @click="childChange"
  9. >
  10. <!-- 子目录 -->
  11. <van-tab
  12. v-for="(tabItem, tabIndex) in learnChildList"
  13. :key="tabIndex"
  14. :title="tabItem.name"
  15. :title-style="titleStyle"
  16. >
  17. <van-list
  18. v-model="loading"
  19. :finished="finished"
  20. finished-text="没有更多了"
  21. @load="onLoad"
  22. >
  23. <!-- <van-cell></van-cell> -->
  24. <van-cell
  25. v-for="(contentItem, contentIndex) in contentList"
  26. :key="contentIndex"
  27. @click="chooseContent(contentIndex)"
  28. >
  29. <div slot="default" class="contentItemDiv">
  30. <div class="contentItemTitle">{{ contentItem.name }}</div>
  31. <div class="contentItemDescription">
  32. <div class="contentItemDescriptionTime">
  33. {{
  34. formateDateTimeFun(contentItem.createdTime) ||
  35. contentItem.createdTime
  36. }}
  37. </div>
  38. <div>
  39. 所需学习时间:{{
  40. getTimeHoursMinuteSecondsFun(contentItem.readTimeInSec)
  41. }}
  42. </div>
  43. </div>
  44. </div>
  45. </van-cell>
  46. </van-list>
  47. </van-tab>
  48. </van-tabs>
  49. </div>
  50. </template>
  51. <script>
  52. export default {
  53. name: "page-learn-child",
  54. components: {},
  55. props: {
  56. learnChildList: {
  57. type: Array,
  58. default: () => []
  59. }
  60. },
  61. data() {
  62. return {
  63. active: 0,
  64. choosedChildIndex: 0,
  65. titleStyle: {
  66. fontSize: "10px"
  67. },
  68. contentList: [],
  69. loading: false,
  70. finished: false
  71. };
  72. },
  73. computed: {},
  74. created() {},
  75. mounted() {},
  76. watch: {
  77. // 第一次加载内容
  78. "learnChildList.length": {
  79. handler(newValue, oldValue) {
  80. if (oldValue === 0 && newValue !== 0) {
  81. this.getContentList();
  82. }
  83. }
  84. },
  85. active(val, oldVal) {
  86. if (val !== oldVal) {
  87. this.getContentList();
  88. }
  89. }
  90. },
  91. methods: {
  92. childChange(index) {
  93. this.finished = false;
  94. this.choosedChildIndex = index;
  95. this.getContentList();
  96. },
  97. // 查询子目录
  98. getContentList() {
  99. let path = {
  100. categoryId: this.learnChildList[this.choosedChildIndex].id
  101. };
  102. this.$_http
  103. .get(
  104. this.$pathParams(
  105. this.$_API.JTXT_GET_CATEGORIES_CATEGROYID_MATERIALS,
  106. path
  107. )
  108. )
  109. .then(res => {
  110. this.contentList = res.data;
  111. this.finished = true;
  112. })
  113. .catch(() => {
  114. this.$store.commit("toggleLoading", false);
  115. });
  116. },
  117. onLoad() {},
  118. chooseContent(index) {
  119. this.$router.push({
  120. name: "learn-content",
  121. params: { materialId: this.contentList[index].id }
  122. });
  123. }
  124. }
  125. };
  126. </script>
  127. <style lang="scss" scoped>
  128. @import "~@/styles/mixin";
  129. .contentBody {
  130. background-color: #fff;
  131. .contentItemDiv {
  132. .contentItemTitle {
  133. font-size: 0.65rem;
  134. }
  135. .contentItemDescription {
  136. margin-top: 0.25rem;
  137. display: flex;
  138. justify-content: space-between;
  139. align-items: center;
  140. color: #0088e9;
  141. .contentItemDescriptionTime {
  142. color: #999;
  143. }
  144. }
  145. }
  146. }
  147. </style>