details.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <SimplePageContentLoader :loader="contentLoader">
  3. <FlexCol v-if="contentLoader.loadStatus.value == 'finished'">
  4. <swiper
  5. circular
  6. :indicator-dots="false"
  7. :autoplay="true"
  8. :interval="2000"
  9. :duration="1000"
  10. :style="{
  11. width: '100%',
  12. height: '500rpx',
  13. }"
  14. >
  15. <swiper-item v-for="(item, k) in data.images" :key="k">
  16. <Image
  17. :src="item"
  18. :radius="20"
  19. :height="500"
  20. :width="750"
  21. mode="aspectFill"
  22. touchable
  23. @click="onPreviewImage(k)"
  24. />
  25. </swiper-item>
  26. </swiper>
  27. <FlexCol :padding="20" :radius="20" :gap="20">
  28. <Height :height="20" />
  29. <FlexCol>
  30. <SubTitle :title="data.villageName" />
  31. <IntroBlock
  32. small
  33. :descItems="[
  34. {
  35. label: '保护级别',
  36. value: data.historyLevelText ,
  37. },
  38. {
  39. label: '年份时间',
  40. value: data.ageText,
  41. },
  42. {
  43. label: '所属区域',
  44. value: data.regionText ,
  45. },
  46. ]"
  47. />
  48. <FlexCol :margin="[20, 0, 0, 0]">
  49. <Parse :content="data.overview" />
  50. <Text v-if="!data.overview" fontConfig="subText">无内容,请添加内容! </Text>
  51. </FlexCol>
  52. </FlexCol>
  53. <FlexRow :margin="[40, 0, 40, 0]" :gap="[20, 0]" wrap>
  54. <Touchable
  55. v-for="(tag, key) in tagsData"
  56. :key="key"
  57. width="20%"
  58. align="center"
  59. justify="center"
  60. direction="column"
  61. @click="goList(tag)"
  62. >
  63. <Image :src="tag.image" width="65%" mode="widthFix"></Image>
  64. <Text fontConfig="subText" textAlign="center">{{ tag.title }}</Text>
  65. </Touchable>
  66. </FlexRow>
  67. <FlexCol :margin="[20, 0, 30, 0]">
  68. <SubTitle title="地理位置" />
  69. <FlexCol :radius="20" backgroundColor="white" :margin="[20, 0, 0, 0]">
  70. <map
  71. id="map"
  72. :latitude="center[1]"
  73. :longitude="center[0]"
  74. :markers="markers"
  75. :scale="15"
  76. :style="{
  77. width: '100%',
  78. height: '350rpx',
  79. }"
  80. />
  81. <Touchable
  82. v-if="data.address"
  83. :title="data.address"
  84. touchable
  85. :padding="20"
  86. @click="goAddress"
  87. >
  88. <IconTextBlock
  89. icon="map-filling"
  90. :iconProps="{ size: 27 }"
  91. :title="data.address"
  92. extra="去这里"
  93. :extraProps="{
  94. color: 'primary',
  95. }"
  96. />
  97. </Touchable>
  98. </FlexCol>
  99. </FlexCol>
  100. <template
  101. v-for="(tag, index) in tagsDataRecommend"
  102. :key="index"
  103. >
  104. <Height :height="20" />
  105. <SubTitle :title="tag.title" showMore @moreClicked="tag.goList()" />
  106. <SimplePageContentLoader :loader="tag.loader" >
  107. <FlexCol :gap="20">
  108. <Box2LineLargeImageUserShadow
  109. v-for="(item, i) in tag.loader.content.value"
  110. :key="i"
  111. :title="item.title"
  112. :desc="item.desc"
  113. :image="item.image"
  114. :likes="item.likes"
  115. :comment="item.comments"
  116. @click="tag.goDetail(item.id)"
  117. />
  118. </FlexCol>
  119. </SimplePageContentLoader>
  120. </template>
  121. </FlexCol>
  122. </FlexCol>
  123. </SimplePageContentLoader>
  124. </template>
  125. <script setup lang="ts">
  126. import { ref, toRefs, type Ref } from 'vue';
  127. import { useLoadQuerys } from '@/common/composeabe/LoadQuerys';
  128. import { useSwiperImagePreview } from '@/common/composeabe/SwiperImagePreview';
  129. import { navTo } from '@/components/utils/PageAction';
  130. import { onShareTimeline, onShareAppMessage } from '@dcloudio/uni-app';
  131. import { useSimpleDataLoader } from '@/common/composeabe/SimpleDataLoader';
  132. import { useHomePageMiniCommonListGoMoreAndGoDetail, type IHomePageMiniCommonListGoMoreAndGoDetail } from '@/pages/article/common/CommonContent';
  133. import IntroBlock from '@/pages/article/common/IntroBlock.vue';
  134. import Parse from '@/components/display/parse/Parse.vue';
  135. import SimplePageContentLoader from '@/common/components/SimplePageContentLoader.vue';
  136. import Box2LineLargeImageUserShadow from '@/common/components/parts/Box2LineLargeImageUserShadow.vue';
  137. import VillageApi from '@/api/inhert/VillageApi';
  138. import ImagesUrls from '@/common/config/ImagesUrls';
  139. import SubTitle from '@/components/display/title/SubTitle.vue';
  140. import FlexCol from '@/components/layout/FlexCol.vue';
  141. import Image from '@/components/basic/Image.vue';
  142. import Text from '@/components/basic/Text.vue';
  143. import FlexRow from '@/components/layout/FlexRow.vue';
  144. import Cell from '@/components/basic/Cell.vue';
  145. import Touchable from '@/components/feedback/Touchable.vue';
  146. import Height from '@/components/layout/space/Height.vue';
  147. import IconTextBlock from '@/components/display/block/IconTextBlock.vue';
  148. const EmptyImage = 'https://mncdn.wenlvti.net/app_static/minnan/EmptyImage.png';
  149. interface TagDataItem {
  150. image: string,
  151. title: string,
  152. modelId?: number,
  153. mainBodyColumnId?: number,
  154. }
  155. interface TagDataRecommendItem extends TagDataItem, IHomePageMiniCommonListGoMoreAndGoDetail {
  156. }
  157. const center = ref([118.15723, 24.48147]);
  158. const markers = ref<any>([]);
  159. const tagsData = ref<TagDataItem[]>([]);
  160. const tagsDataRecommend = ref<TagDataRecommendItem[]>([]) as unknown as Ref<TagDataRecommendItem[]>;
  161. const { querys } = useLoadQuerys({
  162. id: 0,
  163. }, () => contentLoader.loadData());
  164. const data = ref<Record<string, any>>({
  165. images: [],
  166. overview: '',
  167. longitude: 0,
  168. latitude: 0,
  169. region: 0,
  170. address: '',
  171. villageName: '',
  172. })
  173. function goAddress() {
  174. uni.openLocation({
  175. latitude: data.value.latitude,
  176. longitude: data.value.longitude,
  177. })
  178. }
  179. const { onPreviewImage } = useSwiperImagePreview(() => data.value.images || [])
  180. function goList(tag: TagDataItem) {
  181. navTo('/pages/article/common/list', {
  182. title: tag.title,
  183. modelId: tag.modelId,
  184. mainBodyColumnId: tag.mainBodyColumnId,
  185. region: data.value.region,
  186. });
  187. }
  188. const contentLoader = useSimpleDataLoader(async () => {
  189. data.value = {
  190. ...data.value,
  191. ...JSON.parse(uni.getStorageSync('VillageTemp') || '{}'),
  192. };
  193. console.log(data.value);
  194. if (data.value.longitude && data.value.latitude) {
  195. center.value = [Number(data.value.longitude), Number(data.value.latitude)];
  196. } else {
  197. center.value = [118.11593, 24.467580];
  198. }
  199. markers.value = [
  200. {
  201. id: 1,
  202. latitude: center.value[1],
  203. longitude: center.value[0],
  204. iconPath: ImagesUrls.IconMarker,
  205. width: 40,
  206. height: 40,
  207. }
  208. ];
  209. const menu = await VillageApi.getVillageMenuList(querys.value.id);
  210. tagsData.value = menu.map((item, index) => {
  211. return {
  212. title: item.name,
  213. image: item.logo || EmptyImage,
  214. modelId: item.modelId as number,
  215. mainBodyColumnId: item.mainBodyColumnId as number,
  216. };
  217. });
  218. tagsDataRecommend.value = tagsData.value.slice(0, 2).map((t) => {
  219. return {
  220. ...t,
  221. ...(toRefs(useHomePageMiniCommonListGoMoreAndGoDetail({
  222. title: t.title,
  223. mainBodyColumnId: t.mainBodyColumnId,
  224. modelId: t.modelId,
  225. itemType: 'article-common',
  226. detailsPage: '/pages/article/details',
  227. })))
  228. }
  229. }) as any;
  230. tagsDataRecommend.value.forEach(e => {
  231. e.loader.loadData();
  232. });
  233. }, false);
  234. function getPageShareData() {
  235. return {
  236. title: data.value.villageName,
  237. imageUrl: data.value.images[0],
  238. }
  239. }
  240. onShareTimeline(() => {
  241. return getPageShareData();
  242. })
  243. onShareAppMessage(() => {
  244. return getPageShareData();
  245. })
  246. </script>