AboutView.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <!-- 关于页 -->
  3. <div class="about main-background main-background-type0">
  4. <!-- 轮播 -->
  5. <Carousel v-bind="carouselConfig" class="main-header-box small carousel-light">
  6. <Slide class="main-header-box small">
  7. <img src="@/assets/images/about/Banner.jpg" />
  8. </Slide>
  9. <template #addons>
  10. <Navigation />
  11. <Pagination />
  12. </template>
  13. </Carousel>
  14. <!-- 新闻 -->
  15. <section class="main-section main-background main-background-type0">
  16. <div class="content news-list">
  17. <!-- 新闻列表 -->
  18. <SimplePageContentLoader :loader="newsLoader">
  19. <div
  20. v-for="(item, k) in newsLoader.list.value"
  21. :key="item.id"
  22. class="item"
  23. @click="router.push({ name: 'news-detail', query: { id: item.id }})"
  24. >
  25. <img :src="item.image" alt="新闻图片" />
  26. <TitleDescBlock
  27. :title="item.title"
  28. :desc="item.desc || item.title"
  29. :date="DateUtils.formatDate(item.publish_at, DateUtils.FormatStrings.YearCommon)"
  30. />
  31. </div>
  32. </SimplePageContentLoader>
  33. <!-- 分页 -->
  34. <Pagination2
  35. v-model:currentPage="newsLoader.page.value"
  36. :totalPages="newsLoader.totalPages.value"
  37. />
  38. </div>
  39. </section>
  40. </div>
  41. </template>
  42. <script setup lang="ts">
  43. import { Carousel, Slide, Pagination, Navigation } from 'vue3-carousel'
  44. import { onMounted, ref } from 'vue';
  45. import { useSimplePagerDataLoader } from '@/composeable/SimplePagerDataLoader';
  46. import Pagination2 from '@/components/controls/Pagination.vue';
  47. import TitleDescBlock from '@/components/parts/TitleDescBlock.vue';
  48. import SimplePageContentLoader from '@/components/content/SimplePageContentLoader.vue';
  49. import CommonContent, { GetContentListParams } from '@/api/CommonContent';
  50. import DateUtils from '@/common/utils/DateUtils';
  51. import { useRouter } from 'vue-router';
  52. const carouselConfig = {
  53. itemsToShow: 1,
  54. wrapAround: true,
  55. autoPlay: 5000,
  56. }
  57. const router = useRouter();
  58. const newsLoader = useSimplePagerDataLoader(10, async (page, pageSize) => {
  59. const res = await CommonContent.getContentList(new GetContentListParams()
  60. .setModelId(17)
  61. .setMainBodyColumnId([ 255, 256, 283, 284, ])
  62. , page, pageSize);
  63. return {
  64. data: res.list,
  65. total: res.total,
  66. };
  67. });
  68. onMounted(async () => {
  69. newsLoader.loadData(undefined, true);
  70. })
  71. </script>
  72. <style lang="scss">
  73. @media (max-width: 425px) {
  74. }
  75. </style>