index.vue 8.7 KB

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