info.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="main">
  3. <div class="content">
  4. <sub-header />
  5. <div class="left">
  6. <n-tabs type="line" pane-class="tab-content" v-model:value="currentTab">
  7. <template #prefix>
  8. <span class="meta-title">
  9. <img src="@/assets/subtitle_1.png" />
  10. </span>
  11. </template>
  12. <n-tab-pane
  13. name="exhibition"
  14. tab="展览"
  15. v-infinite-scroll="onLoadMore"
  16. >
  17. <n-grid :x-gap="XGap" :y-gap="YGap" :cols="3" class="tab-grid">
  18. <template v-for="item in exhibitions">
  19. <n-gi>
  20. <info-box
  21. :id="item.id"
  22. :title="item.name"
  23. :cover="domain + item.thumb"
  24. :time="item.publishDate"
  25. />
  26. </n-gi>
  27. </template>
  28. </n-grid>
  29. <empty :show="exhibitions.length === 0" :height="500" />
  30. </n-tab-pane>
  31. <n-tab-pane name="activity" tab="活动">
  32. <n-grid :x-gap="XGap" :y-gap="YGap" :cols="3" class="tab-grid">
  33. <template v-for="item in activates">
  34. <n-gi>
  35. <info-box
  36. :id="item.id"
  37. :title="item.name"
  38. :cover="domain + item.thumb"
  39. :time="item.publishDate"
  40. />
  41. </n-gi>
  42. </template>
  43. </n-grid>
  44. <empty :show="activates.length === 0" :height="500" />
  45. </n-tab-pane>
  46. <n-tab-pane name="news" tab="新闻">
  47. <n-grid :x-gap="XGap" :y-gap="YGap" :cols="3" class="tab-grid">
  48. <template v-for="item in news">
  49. <n-gi>
  50. <info-box
  51. :id="item.id"
  52. :title="item.name"
  53. :cover="domain + item.thumb"
  54. :time="item.publishDate"
  55. />
  56. </n-gi>
  57. </template>
  58. </n-grid>
  59. <empty :show="news.length === 0" :height="500" />
  60. </n-tab-pane>
  61. <n-tab-pane name="notice" tab="通知">
  62. <n-grid :y-gap="YGap" :cols="1" class="tab-grid">
  63. <template v-for="item in notices">
  64. <n-gi>
  65. <notice-box
  66. :id="item.id"
  67. :title="item.name"
  68. :content="item.richText"
  69. :time="item.publishDate"
  70. />
  71. </n-gi>
  72. </template>
  73. </n-grid>
  74. <empty :show="notices.length === 0" :height="500" />
  75. </n-tab-pane>
  76. </n-tabs>
  77. </div>
  78. <side-menu />
  79. </div>
  80. </div>
  81. </template>
  82. <script setup>
  83. import { onMounted, watch, computed } from "vue";
  84. import { vInfiniteScroll } from "@vueuse/components";
  85. import infoBox from "../components/infoBox";
  86. import subHeader from "../components/subHeader";
  87. import sideMenu from "../components/sideMenu";
  88. import noticeBox from "../components/noticeBox";
  89. import empty from "../components/empty.vue";
  90. import { useInfoStore } from "../store/info";
  91. const infoStore = useInfoStore();
  92. const domain = ref(import.meta.env.VITE_DOMAIN_URL);
  93. const currentTab = ref("exhibition");
  94. const news = computed(() => infoStore.news);
  95. const notices = computed(() => infoStore.notices);
  96. const activates = computed(() => infoStore.activates);
  97. const exhibitions = computed(() => infoStore.exhibitions);
  98. const handleTabFetch = (type) => {
  99. switch (type) {
  100. case "exhibition":
  101. infoStore.getExhibition();
  102. break;
  103. case "activity":
  104. infoStore.getActivity();
  105. break;
  106. case "news":
  107. infoStore.getNews();
  108. break;
  109. case "notice":
  110. infoStore.getNotices();
  111. break;
  112. }
  113. };
  114. watch(
  115. currentTab,
  116. (val) => {
  117. console.log("currentTab", val);
  118. handleTabFetch(val);
  119. },
  120. {
  121. immediate: true,
  122. }
  123. );
  124. const XGap = ref(50);
  125. const YGap = ref(50);
  126. const onLoadMore = (type) => {
  127. // console.log("type", type);
  128. console.log("onLoadMore");
  129. };
  130. </script>
  131. <style lang="scss" scoped></style>