index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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 absolute light fit-small-header">
  16. <div class="content row">
  17. <div class="col-md-12 col-lg-8 col-xl-6">
  18. <div class="main-header-title d-flex flex-column">
  19. </div>
  20. </div>
  21. <div class="col-md-12 col-lg-4 col-xl-6">
  22. </div>
  23. </div>
  24. <!-- 头部TAB -->
  25. <div class="main-header-tab">
  26. <div class="list">
  27. <div
  28. v-for="(tab, k) in mainTabs"
  29. :key="k"
  30. :class="[ mainTabActive === tab.value ? 'active' : '' ]"
  31. @click="handleTabClick(tab.value)"
  32. >
  33. {{ tab.title }}
  34. </div>
  35. </div>
  36. </div>
  37. </section>
  38. <!-- 闽南文化生态保护区概况 -->
  39. <section v-if="mainTabActive == 0" class="main-section main-background main-background-type0">
  40. <div class="content">
  41. <SimplePageContentLoader :loader="introdLoader">
  42. <div class="d-flex justify-content-center">
  43. <h2>{{ introdLoader.content.value?.introd1?.title }}</h2>
  44. </div>
  45. <LeftRightBox
  46. class="mt-4"
  47. :title="introdLoader.content.value?.introd1?.title"
  48. :desc="introdLoader.content.value?.introd1?.content"
  49. :image="introdLoader.content.value?.introd1?.image"
  50. :rightItems="introdLoader.content.value?.list"
  51. :moreLink="router.resolve({ path: '/introduction/about' }).href"
  52. />
  53. <div class="d-flex justify-content-center mt-5">
  54. <h2>{{ introdLoader.content.value?.introd2?.title }}</h2>
  55. </div>
  56. <LeftRightBox
  57. class="mt-4"
  58. :title="introdLoader.content.value?.introd2?.title"
  59. :desc="introdLoader.content.value?.introd2?.content"
  60. :image="introdLoader.content.value?.introd2?.image"
  61. :moreLink="router.resolve({ path: '/introduction/about' }).href"
  62. />
  63. <div class="d-flex justify-content-center mt-5">
  64. <h2>{{ introdLoader.content.value?.introd3?.title }}</h2>
  65. </div>
  66. <LeftRightBox
  67. class="mt-4"
  68. :title="introdLoader.content.value?.introd3?.title"
  69. :desc="introdLoader.content.value?.introd3?.content"
  70. :image="introdLoader.content.value?.introd3?.image"
  71. :showMore="false"
  72. left
  73. />
  74. </SimplePageContentLoader>
  75. </div>
  76. </section>
  77. <!-- 新闻 -->
  78. <section v-if="mainTabActive == 1" class="main-section main-background main-background-type0">
  79. <div class="content news-list">
  80. <!-- 新闻列表 -->
  81. <SimplePageContentLoader :loader="newsLoader">
  82. <NuxtLink
  83. v-for="(item, k) in newsLoader.list.value"
  84. :key="item.id"
  85. class="item"
  86. :to="{ path: 'news/detail', query: { id: item.id }}"
  87. >
  88. <ImageTitleBlock
  89. :image="item.thumbnail || item.image"
  90. />
  91. <TitleDescBlock
  92. :title="item.title"
  93. :desc="item.desc || item.title"
  94. />
  95. </NuxtLink>
  96. </SimplePageContentLoader>
  97. <!-- 分页 -->
  98. <Pagination2
  99. v-model:currentPage="newsLoader.page.value"
  100. :totalPages="newsLoader.totalPages.value"
  101. :ssrUrl="router.resolve(route).href"
  102. />
  103. </div>
  104. </section>
  105. <!-- 法律法规 -->
  106. <section v-if="mainTabActive == 2" class="main-section">
  107. <div class="content">
  108. <div class="title left-right">
  109. <h2>政策法规</h2>
  110. <div class="small-more">
  111. <NuxtLink :to="{ path: '/introduction/policy' }">
  112. <span>更多信息</span>
  113. <img src="@/assets/images/index/ButtonMore.png" alt="更多" />
  114. </NuxtLink>
  115. </div>
  116. </div>
  117. <SimplePageContentLoader :loader="lawsData">
  118. <NuxtLink
  119. v-for="(item, index) in lawsData.content.value"
  120. :key="index"
  121. :to="{ path: '/news/detail', query: { id: item.id } }"
  122. >
  123. <ImageTextSmallBlock
  124. :title="item.title"
  125. :image="item.image"
  126. :date="item.date"
  127. />
  128. </NuxtLink>
  129. </SimplePageContentLoader>
  130. </div>
  131. </section>
  132. </div>
  133. </template>
  134. <script setup lang="ts">
  135. import { Carousel, Slide, Pagination, Navigation } from 'vue3-carousel'
  136. import { onMounted, ref, watch } from 'vue';
  137. import { useSSrSimplePagerDataLoader } from '@/composeable/SimplePagerDataLoader';
  138. import { useRouter } from 'vue-router';
  139. import { useSSrSimpleDataLoader } from '@/composeable/SimpleDataLoader';
  140. import { DateUtils } from '@imengyu/imengyu-utils';
  141. import Pagination2 from '@/components/controls/Pagination.vue';
  142. import TitleDescBlock from '@/components/parts/TitleDescBlock.vue';
  143. import ImageTextSmallBlock from '@/components/parts/ImageTextSmallBlock.vue';
  144. import SimplePageContentLoader from '@/components/content/SimplePageContentLoader.vue';
  145. import CommonContent, { GetContentListParams } from '@/api/CommonContent';
  146. import PolicyContent from '@/api/introduction/PolicyContent';
  147. import LawsTest from '@/assets/images/inheritor/LawsTest.jpg'
  148. import LeftRightBox from '@/components/parts/LeftRightBox.vue';
  149. import NewsIndexContent from '@/api/news/NewsIndexContent';
  150. const router = useRouter();
  151. const route = useRoute();
  152. const carouselConfig = {
  153. itemsToShow: 1,
  154. wrapAround: true,
  155. autoPlay: 5000,
  156. }
  157. const mainTabs = [
  158. { title: '闽南文化生态保护区概况', value: 0 },
  159. { title: '世界闽南文化交流中心', value: 1 },
  160. //{ title: '政策法规', value: 2 },
  161. ]
  162. const mainTabActive = ref(0);
  163. function handleTabClick(value: number) {
  164. mainTabActive.value = value;
  165. }
  166. const introdLoader = await useSSrSimpleDataLoader('introd', async () => {
  167. const res = await CommonContent.getContentList(new GetContentListParams()
  168. .setModelId(17)
  169. .setMainBodyColumnId([ 256, 283, 284 ])
  170. , 1, 10);
  171. const res2 = await CommonContent.getContentList(new GetContentListParams()
  172. .setModelId(17)
  173. .setMainBodyColumnId([ 234 ])
  174. , 1, 10);
  175. const id1 = res2.list.find(item => item.title.includes('厦门'))?.id;
  176. const id2 = res2.list.find(item => item.title.includes('闽南') && !item.title.includes('厦门'))?.id;
  177. const id3 = res2.list.find(item => item.title.includes('全国'))?.id;
  178. const introd1 = id1 ? (await NewsIndexContent.getContentDetail(id1)).toJSON() : undefined;
  179. const introd2 = id2 ? (await NewsIndexContent.getContentDetail(id2)).toJSON() : undefined;
  180. const introd3 = id3 ? (await NewsIndexContent.getContentDetail(id3)).toJSON() : undefined;
  181. return {
  182. introd1,
  183. introd2,
  184. introd3,
  185. list: res.list.map(p => ({
  186. id: p.id,
  187. title: p.title,
  188. desc: p.desc,
  189. image: p.thumbnail || p.image,
  190. link: router.resolve({ path: '/news/detail', query: { id: p.id } }).href,
  191. })),
  192. };
  193. })
  194. const newsLoader = await useSSrSimplePagerDataLoader('news', Number(route.query.page as string || 1), 10, async (page, pageSize) => {
  195. let res;
  196. switch (mainTabActive.value) {
  197. default:
  198. case 1:
  199. res = await CommonContent.getContentList(new GetContentListParams()
  200. .setModelId(18)
  201. .setMainBodyColumnId([ 232 ])
  202. , page, pageSize);
  203. break;
  204. }
  205. return {
  206. data: res.list.map(p => p.toJSON()),
  207. total: res.total,
  208. };
  209. });
  210. const lawsData = await useSSrSimpleDataLoader('laws', async () =>
  211. (await PolicyContent.getContentList(new GetContentListParams(), 1, 8))
  212. .list?.map(item => ({
  213. id: item.id,
  214. title: item.title,
  215. image: item.thumbnail || item.image || LawsTest,
  216. date: DateUtils.formatDate(item.publishAt, DateUtils.FormatStrings.ShortDate),
  217. link: router.resolve({ path: '/news/detail', query: { id: item.id } }).href,
  218. }))
  219. )
  220. watch(mainTabActive, () => newsLoader.loadData(undefined, true))
  221. onMounted(async () => {
  222. newsLoader.loadData(undefined, true);
  223. })
  224. </script>
  225. <style lang="scss">
  226. @media (max-width: 425px) {
  227. }
  228. </style>