index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <FlexCol :gap="20" :padding="20">
  3. <FlexCol :radius="15" overflow="hidden">
  4. <ImageSwiper
  5. :height="300"
  6. :images="[
  7. 'https://mncdn.wenlvti.net/app_static/xiangyuan/images/causel/1.webp',
  8. 'https://mncdn.wenlvti.net/app_static/xiangyuan/images/causel/2.jpg',
  9. 'https://mncdn.wenlvti.net/app_static/xiangyuan/images/causel/3.jpg',
  10. 'https://mncdn.wenlvti.net/app_static/xiangyuan/images/causel/4.jpg',
  11. 'https://mncdn.wenlvti.net/app_static/xiangyuan/images/causel/5.jpg',
  12. ]"
  13. />
  14. </FlexCol>
  15. <Box title="村社分布" icon="/static/images/home/icon-pin-distance.png">
  16. <map
  17. id="prevMap"
  18. map-id="prevMap"
  19. :style="{ width: '100%', height: '400rpx', borderRadius: '10rpx', overflow: 'hidden' }"
  20. :markers="mapLoader.content.value || []"
  21. :scale="10"
  22. :longitude="AppCofig.defaultLonLat[0]"
  23. :latitude="AppCofig.defaultLonLat[1]"
  24. @markertap="goVillageDetails($event)"
  25. />
  26. </Box>
  27. <Box title="线上史馆展示" icon="/static/images/home/icon-ancient-gate.png">
  28. <SimplePageContentLoader :loader="recommendLoader">
  29. <FlexRow justify="space-between" align="center" wrap :gap="25">
  30. <Touchable
  31. v-for="(item, i) in recommendLoader.content.value"
  32. :key="i"
  33. :gap="20"
  34. flex="0 0 48%"
  35. align="center"
  36. direction="column"
  37. @click="goVillageDetails(item)"
  38. >
  39. <Image
  40. :src="item.thumbnail || item.image"
  41. width="100%"
  42. height="200rpx"
  43. :radius="15"
  44. mode="aspectFill"
  45. round
  46. />
  47. <Text :text="item.title" />
  48. </Touchable>
  49. </FlexRow>
  50. </SimplePageContentLoader>
  51. </Box>
  52. <Box title="发现" icon="/static/images/home/icon-compass.png" showMore @moreClicked="$emit('goDiscover')">
  53. <SimplePageContentLoader :loader="discoverLoader">
  54. <FlexCol :gap="25">
  55. <Touchable
  56. v-for="(item, i) in discoverLoader.content.value"
  57. :key="i"
  58. justify="space-between"
  59. align="center"
  60. direction="row"
  61. @click="goDiscoverDetails(item)"
  62. >
  63. <FlexCol flex="1" :gap="20">
  64. <Text :text="item.title" fontConfig="h5" />
  65. <Text :text="item.desc" fontConfig="subText" />
  66. </FlexCol>
  67. <Width :width="25" />
  68. <Image
  69. :src="item.image"
  70. :failedImage="AppCofig.defaultImage"
  71. :width="120"
  72. :height="120"
  73. :radius="15"
  74. mode="aspectFill"
  75. round
  76. />
  77. </Touchable>
  78. </FlexCol>
  79. </SimplePageContentLoader>
  80. </Box>
  81. <Loadmore status="nomore" />
  82. <Height :height="150" />
  83. </FlexCol>
  84. </template>
  85. <script setup lang="ts">
  86. import { navTo } from '@/components/utils/PageAction';
  87. import { getCurrentInstance } from 'vue';
  88. import { useSimpleDataLoader } from '@/common/composeabe/SimpleDataLoader';
  89. import VillageApi from '@/api/inhert/VillageApi';
  90. import VillageInfoApi from '@/api/inhert/VillageInfoApi';
  91. import Box from '@/common/components/parts/Box.vue';
  92. import ImageSwiper from '@/common/components/parts/ImageSwiper.vue';
  93. import SimplePageContentLoader from '@/common/components/SimplePageContentLoader.vue';
  94. import AppCofig from '@/common/config/AppCofig';
  95. import Image from '@/components/basic/Image.vue';
  96. import Text from '@/components/basic/Text.vue';
  97. import Loadmore from '@/components/display/loading/Loadmore.vue';
  98. import Touchable from '@/components/feedback/Touchable.vue';
  99. import FlexCol from '@/components/layout/FlexCol.vue';
  100. import FlexRow from '@/components/layout/FlexRow.vue';
  101. import Height from '@/components/layout/space/Height.vue';
  102. import Width from '@/components/layout/space/Width.vue';
  103. const instance = getCurrentInstance();
  104. const mapCtx = uni.createMapContext('prevMap', instance);
  105. const mapLoader = useSimpleDataLoader(async () => {
  106. const res = (await VillageApi.getVallageList(undefined, 1)).map((p, i) => ({
  107. ...p,
  108. id: p.id ?? i,
  109. title: p.villageName,
  110. longitude: Number(p.longitude),
  111. latitude: Number(p.latitude),
  112. width: 30,
  113. height: 30,
  114. iconPath: p.thumbnail || p.image,
  115. }));
  116. setTimeout(() => {
  117. mapCtx.includePoints({
  118. points: res.map(p => {
  119. if (!p.longitude || !p.latitude) {
  120. p.longitude = AppCofig.defaultLonLat[0];
  121. p.latitude = AppCofig.defaultLonLat[1];
  122. }
  123. return {
  124. latitude: p.latitude,
  125. longitude: p.longitude,
  126. }
  127. }),
  128. padding: [20, 20, 20, 20],
  129. });
  130. }, 200);
  131. return res;
  132. });
  133. function goVillageDetails(e: any) {
  134. const id = typeof e.markerId == 'number' ? e.markerId : e.id;
  135. uni.setStorageSync('VillageTemp', JSON.stringify(mapLoader.content.value?.find(p => p.id == id)));
  136. setTimeout(() => {
  137. navTo('/pages/home/village/details', { id: id });
  138. }, 200);
  139. }
  140. const recommendLoader = useSimpleDataLoader(async () => {
  141. //const category = (await CommonContent.getCategoryList(151)).find(p => p.title == '省级');
  142. return (await VillageApi.getVallageList(undefined, 1));
  143. });
  144. const discoverLoader = useSimpleDataLoader(async () => {
  145. return (await VillageInfoApi.getListForDiscover(1, 10)).list.map((item) => {
  146. return {
  147. ...item,
  148. image: (item.thumbnail || item.image) as string,
  149. desc: item.desc || '',
  150. title: item.title,
  151. }
  152. })
  153. });
  154. function goDiscoverDetails(item: any) {
  155. navTo('/pages/home/discover/details', {
  156. id: item.id,
  157. collectModelId: item.collectModuleId,
  158. collectModelInternalName: item.collectModuleInternalName,
  159. });
  160. }
  161. </script>